diff --git a/tests/unit/components/builds-item-test.coffee b/tests/unit/components/builds-item-test.coffee index c6214df8..d28a53f7 100644 --- a/tests/unit/components/builds-item-test.coffee +++ b/tests/unit/components/builds-item-test.coffee @@ -1,8 +1,8 @@ `import { test, moduleForComponent } from 'ember-qunit'` moduleForComponent 'builds-item', { - # specify the other units that are required for this test - # needs: ['component:foo', 'helper:bar'] + needs: ['helper:format-sha', 'helper:format-duration', 'helper:format-time', + 'helper:format-message'] } test 'it renders', (assert) -> diff --git a/tests/unit/components/requests-item-test.coffee b/tests/unit/components/requests-item-test.coffee index 7b8f38a9..985ccd18 100644 --- a/tests/unit/components/requests-item-test.coffee +++ b/tests/unit/components/requests-item-test.coffee @@ -1,17 +1,53 @@ `import { test, moduleForComponent } from 'ember-qunit'` moduleForComponent 'requests-item', { - # specify the other units that are required for this test - # needs: ['component:foo', 'helper:bar'] + needs: ['helper:format-message', 'helper:format-time', 'helper:github-commit-link'] } -test 'it renders', (assert) -> - assert.expect 2 +test 'it renders request data', (assert) -> + yesterday = new Date() + yesterday.setDate(yesterday.getDate() - 1) - # creates the component instance - component = @subject() - assert.equal component._state, 'preRender' + request = { + id: 1, + 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() - 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(), '-'