Add some more tests for requests-item component, fix builds-item tests
This commit is contained in:
parent
e1bb8a2e41
commit
f8470cd231
|
@ -1,8 +1,8 @@
|
||||||
`import { test, moduleForComponent } from 'ember-qunit'`
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
moduleForComponent 'builds-item', {
|
moduleForComponent 'builds-item', {
|
||||||
# specify the other units that are required for this test
|
needs: ['helper:format-sha', 'helper:format-duration', 'helper:format-time',
|
||||||
# needs: ['component:foo', 'helper:bar']
|
'helper:format-message']
|
||||||
}
|
}
|
||||||
|
|
||||||
test 'it renders', (assert) ->
|
test 'it renders', (assert) ->
|
||||||
|
|
|
@ -1,17 +1,53 @@
|
||||||
`import { test, moduleForComponent } from 'ember-qunit'`
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
moduleForComponent 'requests-item', {
|
moduleForComponent 'requests-item', {
|
||||||
# specify the other units that are required for this test
|
needs: ['helper:format-message', 'helper:format-time', 'helper:github-commit-link']
|
||||||
# needs: ['component:foo', 'helper:bar']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test 'it renders', (assert) ->
|
test 'it renders request data', (assert) ->
|
||||||
assert.expect 2
|
yesterday = new Date()
|
||||||
|
yesterday.setDate(yesterday.getDate() - 1)
|
||||||
|
|
||||||
# creates the component instance
|
request = {
|
||||||
component = @subject()
|
id: 1,
|
||||||
assert.equal component._state, 'preRender'
|
branchName: 'dev',
|
||||||
|
commit: {
|
||||||
|
sha: 'abcdef123',
|
||||||
|
message: 'Bam! :bomb:'
|
||||||
|
},
|
||||||
|
repo: {
|
||||||
|
slug: 'travis-ci/travis-ci'
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
number: 10
|
||||||
|
}
|
||||||
|
created_at: yesterday,
|
||||||
|
isAccepted: true
|
||||||
|
}
|
||||||
|
|
||||||
# renders the component to the page
|
component = @subject(request: request)
|
||||||
@render()
|
@render()
|
||||||
assert.equal component._state, 'inDOM'
|
|
||||||
|
assert.equal component.$('.requests-branch').text().trim().replace(/[\s]+/, ' '),
|
||||||
|
'dev abcdef1'
|
||||||
|
assert.equal component.$('.requests-time').text().trim(), 'a day ago'
|
||||||
|
assert.ok component.$('.tile-status > .icon').hasClass('accepted'), 'icon should have accepted class'
|
||||||
|
assert.equal component.$('.requests-commit').text().trim(), 'Bam!'
|
||||||
|
assert.equal component.$('.requests-commit .emoji').length, 1, 'there should be an emoji icon in commit message'
|
||||||
|
assert.equal component.$('.requests-commit .emoji').attr('title'), ':bomb:'
|
||||||
|
assert.equal component.$('.requests-build a').text().trim(), '10', 'build number should be displayed'
|
||||||
|
|
||||||
|
test 'it renders PR number if a request is a PR', (assert) ->
|
||||||
|
# creates the component instance
|
||||||
|
request = {
|
||||||
|
id: 1,
|
||||||
|
isPullRequest: true,
|
||||||
|
pullRequestNumber: 20,
|
||||||
|
build: null
|
||||||
|
}
|
||||||
|
|
||||||
|
component = @subject(request: request)
|
||||||
|
@render()
|
||||||
|
|
||||||
|
assert.equal component.$('.requests-branch').text().trim(), '#20'
|
||||||
|
assert.equal component.$('.requests-build').text().trim(), '-'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user