improve specs
This commit is contained in:
parent
37523b3c07
commit
82117d5730
|
@ -46,9 +46,12 @@ Ember.ENV.RAISE_ON_DEPRECATION = true
|
|||
view.appendTo(@get('rootElement') || 'body')
|
||||
|
||||
connectLayout: (name) ->
|
||||
layout = Travis["#{$.camelize(name)}Controller"].create(parent: @controller)
|
||||
layout.connect(@controller)
|
||||
layout
|
||||
unless @getPath('layout.name') == name
|
||||
name = $.camelize(name)
|
||||
viewClass = Travis["#{name}Layout"]
|
||||
@layout = Travis["#{name}Controller"].create(parent: @controller)
|
||||
@controller.connectOutlet(outletName: 'layout', controller: @layout, viewClass: viewClass)
|
||||
@layout
|
||||
|
||||
|
||||
require 'controllers'
|
||||
|
|
|
@ -5,16 +5,7 @@ Travis.Controller = Em.Controller.extend
|
|||
klass = Travis[$.camelize(name)] || Em.Controller
|
||||
this[name] = klass.create(parent: this, namespace: Travis, controllers: this)
|
||||
|
||||
connect: (parent) ->
|
||||
parent.connectOutlet
|
||||
outletName: 'layout'
|
||||
controller: this
|
||||
viewClass: Travis["#{$.camelize(@get('name'))}Layout"]
|
||||
|
||||
connectTop: ->
|
||||
@connectOutlet
|
||||
outletName: 'top'
|
||||
controller: @topController
|
||||
viewClass: Travis.TopView
|
||||
@connectOutlet(outletName: 'top', controller: @topController, viewClass: Travis.TopView)
|
||||
@topController.set('tab', @get('name'))
|
||||
|
||||
|
|
|
@ -7,13 +7,10 @@ Travis.HomeController = Travis.Controller.extend
|
|||
init: ->
|
||||
@_super('top', 'repositories', 'repository', 'sidebar')
|
||||
|
||||
@connectTop()
|
||||
@connectOutlet outletName: 'left', controller: @repositoriesController, viewClass: Travis.RepositoriesView
|
||||
@connectOutlet outletName: 'main', controller: @repositoryController, viewClass: Travis.RepositoryView
|
||||
@connectOutlet outletName: 'right', controller: @sidebarController, viewClass: Travis.SidebarView
|
||||
|
||||
connect: (parent) ->
|
||||
@_super(parent)
|
||||
@connectTop()
|
||||
|
||||
activate: (action, params) ->
|
||||
@repositoryController.activate(action, params)
|
||||
|
|
|
@ -22,10 +22,10 @@ require 'travis/model'
|
|||
).property()
|
||||
|
||||
lastBuildDuration: (->
|
||||
duration = @getPath('data.lastBuildDuration')
|
||||
duration = Travis.Helpers.durationFrom(@get('lastBuildStarted_at'), @get('lastBuildFinished_at')) unless duration
|
||||
duration = @getPath('data.last_build_duration')
|
||||
duration = Travis.Helpers.durationFrom(@get('lastBuildStartedAt'), @get('lastBuildFinishedAt')) unless duration
|
||||
duration
|
||||
).property('data.lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
|
||||
).property('data.last_build_duration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
|
||||
|
||||
sortOrder: (->
|
||||
@get('lastBuildFinishedAt') || '9999'
|
||||
|
|
|
@ -3,16 +3,16 @@ require 'ext/jquery'
|
|||
responseTime = 0
|
||||
|
||||
repositories = [
|
||||
{ id: 1, owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_result: 0, last_build_finished_at: '2012-07-02T00:00:00Z', description: 'Description of travis-core' },
|
||||
{ id: 2, owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_result: 1, last_build_finished_at: '2012-07-01T00:01:00Z', description: 'Description of travis-assets'},
|
||||
{ id: 3, owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_result: undefined, last_build_finished_at: undefined, description: 'Description of travis-hub'},
|
||||
{ id: 1, owner: 'travis-ci', name: 'travis-core', slug: 'travis-ci/travis-core', build_ids: [1, 2], last_build_id: 1, last_build_number: 1, last_build_result: 0, last_build_duration: 30, last_build_started_at: '2012-07-02T00:00:00Z', last_build_finished_at: '2012-07-02T00:00:30Z', description: 'Description of travis-core' },
|
||||
{ id: 2, owner: 'travis-ci', name: 'travis-assets', slug: 'travis-ci/travis-assets', build_ids: [3], last_build_id: 3, last_build_number: 3, last_build_result: 1, last_build_duration: 30, last_build_started_at: '2012-07-02T00:01:00Z', last_build_finished_at: '2012-07-01T00:01:30Z', description: 'Description of travis-assets'},
|
||||
{ id: 3, owner: 'travis-ci', name: 'travis-hub', slug: 'travis-ci/travis-hub', build_ids: [4], last_build_id: 4, last_build_number: 4, last_build_result: undefined, last_build_duration: undefined, last_build_started_at: '2012-07-02T00:02:00Z', last_build_finished_at: undefined, description: 'Description of travis-hub'},
|
||||
]
|
||||
|
||||
builds = [
|
||||
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2], number: 1, event_type: 'push', config: { rvm: ['rbx', '1.9.3'] }, finished_at: '2012-07-02T00:00:00Z', duration: 35, result: 0 },
|
||||
{ id: 1, repository_id: '1', commit_id: 1, job_ids: [1, 2], number: 1, event_type: 'push', config: { rvm: ['rbx', '1.9.3'] }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 },
|
||||
{ id: 2, repository_id: '1', commit_id: 2, job_ids: [3], number: 2, event_type: 'push', config: { rvm: ['rbx'] } },
|
||||
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [4], number: 3, event_type: 'push', config: { rvm: ['rbx'] }, finished_at: '2012-07-01T00:01:00Z', duration: 35, result: 1 },
|
||||
{ id: 4, repository_id: '3', commit_id: 4, job_ids: [5], number: 4, event_type: 'push', config: { rvm: ['rbx'] } },
|
||||
{ id: 3, repository_id: '2', commit_id: 3, job_ids: [4], number: 3, event_type: 'push', config: { rvm: ['rbx'] }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-01T00:01:30Z', result: 1 },
|
||||
{ id: 4, repository_id: '3', commit_id: 4, job_ids: [5], number: 4, event_type: 'push', config: { rvm: ['rbx'] }, started_at: '2012-07-02T00:02:00Z' },
|
||||
]
|
||||
|
||||
commits = [
|
||||
|
@ -23,11 +23,11 @@ commits = [
|
|||
]
|
||||
|
||||
jobs = [
|
||||
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, finished_at: '2012-07-02T00:00:00Z', duration: 35, result: 0 }
|
||||
{ id: 1, repository_id: 1, build_id: 1, commit_id: 1, log_id: 1, number: '1.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:00:00Z', finished_at: '2012-07-02T00:00:30Z', result: 0 }
|
||||
{ id: 2, repository_id: 1, build_id: 1, commit_id: 1, log_id: 2, number: '1.2', config: { rvm: '1.9.3' }, allow_failure: true }
|
||||
{ id: 3, repository_id: 1, build_id: 2, commit_id: 2, log_id: 3, number: '2.1', config: { rvm: 'rbx' } }
|
||||
{ id: 4, repository_id: 2, build_id: 3, commit_id: 3, log_id: 4, number: '3.1', config: { rvm: 'rbx' }, finished_at: '2012-07-01T00:01:00Z', duration: 35, result: 1 }
|
||||
{ id: 5, repository_id: 3, build_id: 4, commit_id: 4, log_id: 5, number: '4.1', config: { rvm: 'rbx' } }
|
||||
{ id: 4, repository_id: 2, build_id: 3, commit_id: 3, log_id: 4, number: '3.1', config: { rvm: 'rbx' }, duration: 30, started_at: '2012-07-02T00:01:00Z', finished_at: '2012-07-02T00:01:30Z', result: 1 }
|
||||
{ id: 5, repository_id: 3, build_id: 4, commit_id: 4, log_id: 5, number: '4.1', config: { rvm: 'rbx' }, started_at: '2012-07-02T00:02:00Z' }
|
||||
{ id: 6, repository_id: 1, build_id: 5, commit_id: 5, log_id: 5, number: '5.1', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
|
||||
{ id: 7, repository_id: 1, build_id: 5, commit_id: 5, log_id: 5, number: '5.2', config: { rvm: 'rbx' }, state: 'created', queue: 'builds.common' }
|
||||
]
|
||||
|
|
|
@ -1,65 +1,40 @@
|
|||
describe 'The current build tab', ->
|
||||
describe 'on the "index" state', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor buildRendered
|
||||
describe 'on the "current" state', ->
|
||||
beforeEach ->
|
||||
app '!/travis-ci/travis-core'
|
||||
waitFor repositoriesRendered
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the build summary', ->
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
duration: '35 sec'
|
||||
message: 'commit message 1'
|
||||
it 'displays the expected stuff', ->
|
||||
displaysRepoList [
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
||||
|
||||
describe 'given the current build has a job matrix', ->
|
||||
it 'displays the jobs matrix table', ->
|
||||
displaysJobMatrix
|
||||
element: '#jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: /\d+ (\w+) ago/, duration: '35 sec', rvm: 'rbx' },
|
||||
]
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
finishedAt: '3 minutes ago'
|
||||
duration: '30 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
it 'displays the allowed failure jobs matrix table', ->
|
||||
displaysJobMatrix
|
||||
element: '#allowed_failure_jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
||||
displaysTabs
|
||||
current: '#!/travis-ci/travis-core'
|
||||
builds: '#!/travis-ci/travis-core/builds'
|
||||
|
||||
describe 'on the "current" state', ->
|
||||
beforeEach ->
|
||||
app '!/travis-ci/travis-core'
|
||||
waitFor repositoriesRendered
|
||||
waitFor buildRendered
|
||||
displaysJobMatrix
|
||||
element: '#jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
||||
]
|
||||
|
||||
it 'displays the build summary', ->
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
duration: '35 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
describe 'given the current build has a job matrix', ->
|
||||
it 'displays the jobs matrix table', ->
|
||||
displaysJobMatrix
|
||||
element: '#jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: /\d+ (\w+) ago/, duration: '35 sec', rvm: 'rbx' },
|
||||
]
|
||||
|
||||
it 'displays the allowed failure jobs matrix table', ->
|
||||
displaysJobMatrix
|
||||
element: '#allowed_failure_jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
||||
displaysJobMatrix
|
||||
element: '#allowed_failure_jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
||||
|
|
44
assets/javascripts/spec/index_spec.coffee
Normal file
44
assets/javascripts/spec/index_spec.coffee
Normal file
|
@ -0,0 +1,44 @@
|
|||
describe 'on the "index" state', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor buildRendered
|
||||
|
||||
it 'displays the expected stuff', ->
|
||||
displaysRepoList [
|
||||
{ slug: 'travis-ci/travis-core', build: { number: 1, url: '#!/travis-ci/travis-core/builds/1', duration: '30 sec', finishedAt: '3 minutes ago' } }
|
||||
{ slug: 'travis-ci/travis-assets', build: { number: 3, url: '#!/travis-ci/travis-assets/builds/3', duration: '30 sec', finishedAt: 'a day ago' } }
|
||||
{ slug: 'travis-ci/travis-hub', build: { number: 4, url: '#!/travis-ci/travis-hub/builds/4', duration: '1 min', finishedAt: '-' } }
|
||||
]
|
||||
|
||||
displaysRepository
|
||||
href: 'http://github.com/travis-ci/travis-core'
|
||||
|
||||
displaysBuildSummary
|
||||
id: 1
|
||||
repo: 'travis-ci/travis-core'
|
||||
commit: '1234567'
|
||||
branch: 'master'
|
||||
compare: '0123456..1234567'
|
||||
finishedAt: '3 minutes ago'
|
||||
duration: '30 sec'
|
||||
message: 'commit message 1'
|
||||
|
||||
displaysTabs
|
||||
current: '#!/travis-ci/travis-core'
|
||||
builds: '#!/travis-ci/travis-core/builds'
|
||||
|
||||
displaysJobMatrix
|
||||
element: '#jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 1, number: '1.1', repo: 'travis-ci/travis-core', finishedAt: '3 minutes ago', duration: '30 sec', rvm: 'rbx' }
|
||||
]
|
||||
|
||||
displaysJobMatrix
|
||||
element: '#allowed_failure_jobs'
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm']
|
||||
jobs: [
|
||||
{ id: 2, number: '1.2', repo: 'travis-ci/travis-core', finishedAt: '-', duration: '-', rvm: '1.9.3' }
|
||||
]
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
describe 'The repositories list', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'lists repositories', ->
|
||||
href = $('#repositories a.current').attr('href')
|
||||
expect(href).toEqual '#!/travis-ci/travis-core'
|
||||
|
||||
it "links to the repository's last build action", ->
|
||||
href = $('#repositories a.last_build').attr('href')
|
||||
expect(href).toEqual '#!/travis-ci/travis-core/builds/1'
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
describe 'The repository view', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'displays the repository header', ->
|
||||
href = $('#repository h3 a').attr('href')
|
||||
expect(href).toEqual 'http://github.com/travis-ci/travis-core'
|
|
@ -11,3 +11,7 @@ minispade.require 'app'
|
|||
Travis.run(rootElement: $('#content'))
|
||||
Em.routes.set('location', url)
|
||||
|
||||
_Date = Date
|
||||
@Date = (date) ->
|
||||
new _Date(date || '2012-07-02T00:03:00Z')
|
||||
@Date.UTC = _Date.UTC
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
@displaysRepoList = (repos) ->
|
||||
elements = $('#repositories li').toArray()
|
||||
ix = 0
|
||||
for repo in repos
|
||||
element = elements[ix]
|
||||
expect($('a.current', element).attr('href')).toEqual "#!/#{repo.slug}"
|
||||
expect($('a.last_build', element).attr('href')).toEqual repo.build.url
|
||||
expect($('.duration', element).text()).toEqual repo.build.duration
|
||||
expect($('.finished_at', element).text()).toEqual repo.build.finishedAt
|
||||
ix += 1
|
||||
|
||||
@displaysRepository = (repo) ->
|
||||
expect($('#repository h3 a').attr('href')).toEqual (repo.href)
|
||||
|
||||
@displaysTabs = (tabs) ->
|
||||
for tab, url in tabs
|
||||
expect($("#tab_#{tab} a").attr('href')).toEqual url
|
||||
|
||||
@displaysBuildSummary = (data) ->
|
||||
element = $('#summary .number a')
|
||||
expect(element.attr('href')).toEqual "#!/#{data.repo}/builds/#{data.id}"
|
||||
|
||||
element = $('#summary .finished_at')
|
||||
expect(element.text()).toMatch /\d+ (\w+) ago/
|
||||
expect(element.text()).toEqual data.finishedAt
|
||||
|
||||
element = $('#summary .duration')
|
||||
expect(element.text()).toEqual data.duration
|
||||
|
@ -40,10 +58,7 @@
|
|||
expect(element.text()).toEqual job.duration
|
||||
|
||||
element = $("#{data.element} tr:nth-child(#{ix}) td.finished_at")
|
||||
if job.finishedAt == '-'
|
||||
expect(element.text()).toEqual '-'
|
||||
else
|
||||
expect(element.text()).toMatch job.finishedAt
|
||||
expect(element.text()).toEqual job.finishedAt
|
||||
|
||||
element = $("#{data.element} tr:nth-child(#{ix}) td:nth-child(6)")
|
||||
expect(element.text()).toEqual job.rvm
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
describe 'The tabs view', ->
|
||||
describe 'on the "index" state', ->
|
||||
beforeEach ->
|
||||
app ''
|
||||
waitFor repositoriesRendered
|
||||
|
||||
it 'has a "current" tab linking to the current build', ->
|
||||
href = $('#tab_current a').attr('href')
|
||||
expect(href).toEqual '#!/travis-ci/travis-core'
|
||||
|
||||
it 'has a "history" tab linking to the builds list', ->
|
||||
href = $('#tab_builds a').attr('href')
|
||||
expect(href).toEqual '#!/travis-ci/travis-core/builds'
|
||||
|
||||
describe 'on the "current" state', ->
|
||||
beforeEach ->
|
||||
app '!/travis-ci/travis-core'
|
||||
waitFor repositoriesRendered
|
||||
waitFor buildRendered
|
||||
|
||||
it 'has a "current" tab linking to the current build', ->
|
||||
href = $('#tab_current a').attr('href')
|
||||
expect(href).toEqual '#!/travis-ci/travis-core'
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -1,107 +1,80 @@
|
|||
(function() {
|
||||
|
||||
describe('The current build tab', function() {
|
||||
describe('on the "index" state', function() {
|
||||
beforeEach(function() {
|
||||
app('');
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
it('displays the build summary', function() {
|
||||
return displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
duration: '35 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
});
|
||||
return describe('given the current build has a job matrix', function() {
|
||||
it('displays the jobs matrix table', function() {
|
||||
return displaysJobMatrix({
|
||||
element: '#jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 1,
|
||||
number: '1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: /\d+ (\w+) ago/,
|
||||
duration: '35 sec',
|
||||
rvm: 'rbx'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
return it('displays the allowed failure jobs matrix table', function() {
|
||||
return displaysJobMatrix({
|
||||
element: '#allowed_failure_jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 2,
|
||||
number: '1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('on the "current" state', function() {
|
||||
beforeEach(function() {
|
||||
app('!/travis-ci/travis-core');
|
||||
waitFor(repositoriesRendered);
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
return describe('on the "current" state', function() {
|
||||
beforeEach(function() {
|
||||
app('!/travis-ci/travis-core');
|
||||
waitFor(repositoriesRendered);
|
||||
return waitFor(buildRendered);
|
||||
return it('displays the expected stuff', function() {
|
||||
displaysRepoList([
|
||||
{
|
||||
slug: 'travis-ci/travis-core',
|
||||
build: {
|
||||
number: 1,
|
||||
url: '#!/travis-ci/travis-core/builds/1',
|
||||
duration: '30 sec',
|
||||
finishedAt: '3 minutes ago'
|
||||
}
|
||||
}, {
|
||||
slug: 'travis-ci/travis-assets',
|
||||
build: {
|
||||
number: 3,
|
||||
url: '#!/travis-ci/travis-assets/builds/3',
|
||||
duration: '30 sec',
|
||||
finishedAt: 'a day ago'
|
||||
}
|
||||
}, {
|
||||
slug: 'travis-ci/travis-hub',
|
||||
build: {
|
||||
number: 4,
|
||||
url: '#!/travis-ci/travis-hub/builds/4',
|
||||
duration: '1 min',
|
||||
finishedAt: '-'
|
||||
}
|
||||
}
|
||||
]);
|
||||
displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
finishedAt: '3 minutes ago',
|
||||
duration: '30 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
it('displays the build summary', function() {
|
||||
return displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
duration: '35 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
displaysTabs({
|
||||
current: '#!/travis-ci/travis-core',
|
||||
builds: '#!/travis-ci/travis-core/builds'
|
||||
});
|
||||
return describe('given the current build has a job matrix', function() {
|
||||
it('displays the jobs matrix table', function() {
|
||||
return displaysJobMatrix({
|
||||
element: '#jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 1,
|
||||
number: '1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: /\d+ (\w+) ago/,
|
||||
duration: '35 sec',
|
||||
rvm: 'rbx'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
return it('displays the allowed failure jobs matrix table', function() {
|
||||
return displaysJobMatrix({
|
||||
element: '#allowed_failure_jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 2,
|
||||
number: '1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
displaysJobMatrix({
|
||||
element: '#jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 1,
|
||||
number: '1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '3 minutes ago',
|
||||
duration: '30 sec',
|
||||
rvm: 'rbx'
|
||||
}
|
||||
]
|
||||
});
|
||||
return displaysJobMatrix({
|
||||
element: '#allowed_failure_jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 2,
|
||||
number: '1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -109,40 +82,90 @@
|
|||
}).call(this);
|
||||
(function() {
|
||||
|
||||
describe('The repositories list', function() {
|
||||
describe('on the "index" state', function() {
|
||||
beforeEach(function() {
|
||||
app('');
|
||||
return waitFor(repositoriesRendered);
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
it('lists repositories', function() {
|
||||
var href;
|
||||
href = $('#repositories a.current').attr('href');
|
||||
return expect(href).toEqual('#!/travis-ci/travis-core');
|
||||
});
|
||||
return it("links to the repository's last build action", function() {
|
||||
var href;
|
||||
href = $('#repositories a.last_build').attr('href');
|
||||
return expect(href).toEqual('#!/travis-ci/travis-core/builds/1');
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
describe('The repository view', function() {
|
||||
beforeEach(function() {
|
||||
app('');
|
||||
return waitFor(repositoriesRendered);
|
||||
});
|
||||
return it('displays the repository header', function() {
|
||||
var href;
|
||||
href = $('#repository h3 a').attr('href');
|
||||
return expect(href).toEqual('http://github.com/travis-ci/travis-core');
|
||||
return it('displays the expected stuff', function() {
|
||||
displaysRepoList([
|
||||
{
|
||||
slug: 'travis-ci/travis-core',
|
||||
build: {
|
||||
number: 1,
|
||||
url: '#!/travis-ci/travis-core/builds/1',
|
||||
duration: '30 sec',
|
||||
finishedAt: '3 minutes ago'
|
||||
}
|
||||
}, {
|
||||
slug: 'travis-ci/travis-assets',
|
||||
build: {
|
||||
number: 3,
|
||||
url: '#!/travis-ci/travis-assets/builds/3',
|
||||
duration: '30 sec',
|
||||
finishedAt: 'a day ago'
|
||||
}
|
||||
}, {
|
||||
slug: 'travis-ci/travis-hub',
|
||||
build: {
|
||||
number: 4,
|
||||
url: '#!/travis-ci/travis-hub/builds/4',
|
||||
duration: '1 min',
|
||||
finishedAt: '-'
|
||||
}
|
||||
}
|
||||
]);
|
||||
displaysRepository({
|
||||
href: 'http://github.com/travis-ci/travis-core'
|
||||
});
|
||||
displaysBuildSummary({
|
||||
id: 1,
|
||||
repo: 'travis-ci/travis-core',
|
||||
commit: '1234567',
|
||||
branch: 'master',
|
||||
compare: '0123456..1234567',
|
||||
finishedAt: '3 minutes ago',
|
||||
duration: '30 sec',
|
||||
message: 'commit message 1'
|
||||
});
|
||||
displaysTabs({
|
||||
current: '#!/travis-ci/travis-core',
|
||||
builds: '#!/travis-ci/travis-core/builds'
|
||||
});
|
||||
displaysJobMatrix({
|
||||
element: '#jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 1,
|
||||
number: '1.1',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '3 minutes ago',
|
||||
duration: '30 sec',
|
||||
rvm: 'rbx'
|
||||
}
|
||||
]
|
||||
});
|
||||
return displaysJobMatrix({
|
||||
element: '#allowed_failure_jobs',
|
||||
headers: ['Job', 'Duration', 'Finished', 'Rvm'],
|
||||
jobs: [
|
||||
{
|
||||
id: 2,
|
||||
number: '1.2',
|
||||
repo: 'travis-ci/travis-core',
|
||||
finishedAt: '-',
|
||||
duration: '-',
|
||||
rvm: '1.9.3'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
var _Date;
|
||||
|
||||
minispade.require('app');
|
||||
|
||||
|
@ -164,6 +187,14 @@
|
|||
});
|
||||
};
|
||||
|
||||
_Date = Date;
|
||||
|
||||
this.Date = function(date) {
|
||||
return new _Date(date || '2012-07-02T00:03:00Z');
|
||||
};
|
||||
|
||||
this.Date.UTC = _Date.UTC;
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
|
@ -182,12 +213,43 @@
|
|||
}).call(this);
|
||||
(function() {
|
||||
|
||||
this.displaysRepoList = function(repos) {
|
||||
var element, elements, ix, repo, _i, _len, _results;
|
||||
elements = $('#repositories li').toArray();
|
||||
ix = 0;
|
||||
_results = [];
|
||||
for (_i = 0, _len = repos.length; _i < _len; _i++) {
|
||||
repo = repos[_i];
|
||||
element = elements[ix];
|
||||
expect($('a.current', element).attr('href')).toEqual("#!/" + repo.slug);
|
||||
expect($('a.last_build', element).attr('href')).toEqual(repo.build.url);
|
||||
expect($('.duration', element).text()).toEqual(repo.build.duration);
|
||||
expect($('.finished_at', element).text()).toEqual(repo.build.finishedAt);
|
||||
_results.push(ix += 1);
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
this.displaysRepository = function(repo) {
|
||||
return expect($('#repository h3 a').attr('href')).toEqual(repo.href);
|
||||
};
|
||||
|
||||
this.displaysTabs = function(tabs) {
|
||||
var tab, url, _i, _len, _results;
|
||||
_results = [];
|
||||
for (url = _i = 0, _len = tabs.length; _i < _len; url = ++_i) {
|
||||
tab = tabs[url];
|
||||
_results.push(expect($("#tab_" + tab + " a").attr('href')).toEqual(url));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
this.displaysBuildSummary = function(data) {
|
||||
var element;
|
||||
element = $('#summary .number a');
|
||||
expect(element.attr('href')).toEqual("#!/" + data.repo + "/builds/" + data.id);
|
||||
element = $('#summary .finished_at');
|
||||
expect(element.text()).toMatch(/\d+ (\w+) ago/);
|
||||
expect(element.text()).toEqual(data.finishedAt);
|
||||
element = $('#summary .duration');
|
||||
expect(element.text()).toEqual(data.duration);
|
||||
element = $('#summary .commit a');
|
||||
|
@ -224,11 +286,7 @@
|
|||
element = $("" + data.element + " tr:nth-child(" + ix + ") td.duration");
|
||||
expect(element.text()).toEqual(job.duration);
|
||||
element = $("" + data.element + " tr:nth-child(" + ix + ") td.finished_at");
|
||||
if (job.finishedAt === '-') {
|
||||
expect(element.text()).toEqual('-');
|
||||
} else {
|
||||
expect(element.text()).toMatch(job.finishedAt);
|
||||
}
|
||||
expect(element.text()).toEqual(job.finishedAt);
|
||||
element = $("" + data.element + " tr:nth-child(" + ix + ") td:nth-child(6)");
|
||||
return expect(element.text()).toEqual(job.rvm);
|
||||
});
|
||||
|
@ -250,37 +308,3 @@
|
|||
this.waitFor = waitsFor;
|
||||
|
||||
}).call(this);
|
||||
(function() {
|
||||
|
||||
describe('The tabs view', function() {
|
||||
describe('on the "index" state', function() {
|
||||
beforeEach(function() {
|
||||
app('');
|
||||
return waitFor(repositoriesRendered);
|
||||
});
|
||||
it('has a "current" tab linking to the current build', function() {
|
||||
var href;
|
||||
href = $('#tab_current a').attr('href');
|
||||
return expect(href).toEqual('#!/travis-ci/travis-core');
|
||||
});
|
||||
return it('has a "history" tab linking to the builds list', function() {
|
||||
var href;
|
||||
href = $('#tab_builds a').attr('href');
|
||||
return expect(href).toEqual('#!/travis-ci/travis-core/builds');
|
||||
});
|
||||
});
|
||||
return describe('on the "current" state', function() {
|
||||
beforeEach(function() {
|
||||
app('!/travis-ci/travis-core');
|
||||
waitFor(repositoriesRendered);
|
||||
return waitFor(buildRendered);
|
||||
});
|
||||
return it('has a "current" tab linking to the current build', function() {
|
||||
var href;
|
||||
href = $('#tab_current a').attr('href');
|
||||
return expect(href).toEqual('#!/travis-ci/travis-core');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Mocha Test Runner</title>
|
||||
<link rel="stylesheet" href="stylesheets/vendor/mocha.css">
|
||||
<script src="../javascripts/vendor/mocha.js"></script>
|
||||
<script src="../javascripts/vendor/expect.js"></script>
|
||||
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
</script>
|
||||
|
||||
<script src="../app/foo.js"></script>
|
||||
<script src="foo.spec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script>
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user