From a56b85459f847d317167b00104e0c1be05ee34b1 Mon Sep 17 00:00:00 2001 From: Curtis Ekstrom Date: Sun, 31 Jan 2016 16:22:25 +0100 Subject: [PATCH] Upgrade tests to be QUnit 2.0 compatible As noted in [this issue](https://github.com/ember-cli/ember-cli/pull/3197), assert is now to be prepended to assertions and passed in to the test function. This commit was generated by ember-watson. --- tests/unit/components/branch-row-test.js | 10 +++--- .../components/build-repo-actions-test.js | 24 ++++++------- tests/unit/components/builds-item-test.js | 4 +-- tests/unit/components/caches-item-test.js | 6 ++-- tests/unit/components/hooks-list-item-test.js | 6 ++-- .../unit/components/job-repo-actions-test.js | 24 ++++++------- tests/unit/components/jobs-item-test.js | 24 ++++++------- tests/unit/components/jobs-list-test.js | 10 +++--- .../unit/components/loading-indicator-test.js | 2 +- tests/unit/components/owner-repo-tile-test.js | 8 ++--- tests/unit/components/repo-actions-test.js | 8 ++--- tests/unit/components/travis-status-test.js | 8 ++--- tests/unit/components/user-avatar-test.js | 8 ++--- tests/unit/mixins/polling-test.js | 8 ++--- tests/unit/models/commit-test.js | 8 ++--- tests/unit/services/polling-test.js | 35 ++++++++++--------- tests/unit/utils/favicon-manager-test.js | 27 +++++++------- tests/unit/utils/status-image-formats-test.js | 5 +-- 18 files changed, 114 insertions(+), 111 deletions(-) diff --git a/tests/unit/components/branch-row-test.js b/tests/unit/components/branch-row-test.js index 082157751b..81f0719e19 100644 --- a/tests/unit/components/branch-row-test.js +++ b/tests/unit/components/branch-row-test.js @@ -4,7 +4,7 @@ moduleForComponent('branch-row', 'BranchRowComponent', { needs: ['helper:format-time', 'helper:format-duration', 'helper:pretty-date', 'helper:format-sha', 'component:build-tile', 'component:status-icon', 'component:request-icon', 'component:loading-indicator'] }); -test('it renders', function() { +test('it renders', function(assert) { var attributes, component; attributes = { name: "master", @@ -46,9 +46,9 @@ test('it renders', function() { build: attributes }); this.append(); - ok(component.$().hasClass('passed'), 'component should have state class (passed)'); - equal(component.$('.row-name .label-align').text().trim(), 'master', 'should display correct branch name'); - equal(component.$('.row-request .label-align').text().trim(), '#1 passed', 'should display build number and state'); - equal(component.$('.row-commiter .label-align').text().trim(), 'Dan Buch', 'should display correct commiter name'); + assert.ok(component.$().hasClass('passed'), 'component should have state class (passed)'); + assert.equal(component.$('.row-name .label-align').text().trim(), 'master', 'should display correct branch name'); + assert.equal(component.$('.row-request .label-align').text().trim(), '#1 passed', 'should display build number and state'); + assert.equal(component.$('.row-commiter .label-align').text().trim(), 'Dan Buch', 'should display correct commiter name'); return equal(component.$('.row-commit .label-align').text().trim(), 'a82f6ba', 'should display correct commit sha'); }); diff --git a/tests/unit/components/build-repo-actions-test.js b/tests/unit/components/build-repo-actions-test.js index 1705415015..825d787ee1 100644 --- a/tests/unit/components/build-repo-actions-test.js +++ b/tests/unit/components/build-repo-actions-test.js @@ -2,7 +2,7 @@ import { test, moduleForComponent } from 'ember-qunit'; import Ember from 'ember'; moduleForComponent('build-repo-actions', 'BuildRepoActionsComponent', {}); -test('it shows cancel button if canCancel is true', function() { +test('it shows cancel button if canCancel is true', function(assert) { var component; component = this.subject({ canCancel: true @@ -11,7 +11,7 @@ test('it shows cancel button if canCancel is true', function() { return ok(component.$('a[title="Cancel Build"]').length, 'cancel link should be visible'); }); -test('it shows restart button if canRestart is true', function() { +test('it shows restart button if canRestart is true', function(assert) { var component; component = this.subject({ canRestart: true @@ -20,7 +20,7 @@ test('it shows restart button if canRestart is true', function() { return ok(component.$('a[title="Restart Build"]').length, 'restart link should be visible'); }); -test('user can cancel if she has permissions to a repo and build is cancelable', function() { +test('user can cancel if she has permissions to a repo and build is cancelable', function(assert) { var build, component; build = Ember.Object.create({ canCancel: false, @@ -30,14 +30,14 @@ test('user can cancel if she has permissions to a repo and build is cancelable', build: build, userHasPermissionForRepo: false }); - ok(!component.get('canCancel')); + assert.ok(!component.get('canCancel')); component.set('userHasPermissionForRepo', true); - ok(!component.get('canCancel')); + assert.ok(!component.get('canCancel')); build.set('canCancel', true); return ok(component.get('canCancel')); }); -test('user can restart if she has permissions to a repo and job is restartable', function() { +test('user can restart if she has permissions to a repo and job is restartable', function(assert) { var build, component; build = Ember.Object.create({ canRestart: false, @@ -47,23 +47,23 @@ test('user can restart if she has permissions to a repo and job is restartable', build: build, userHasPermissionForRepo: false }); - ok(!component.get('canRestart')); + assert.ok(!component.get('canRestart')); component.set('userHasPermissionForRepo', true); - ok(!component.get('canRestart')); + assert.ok(!component.get('canRestart')); build.set('canRestart', true); return ok(component.get('canRestart')); }); -test('it properly checks for user permissions for a repo', function() { +test('it properly checks for user permissions for a repo', function(assert) { var component, repo, user; - expect(3); + assert.expect(3); repo = Ember.Object.create({ id: 44 }); user = Ember.Object.extend({ hasAccessToRepo: function(repo) { - ok(repo.get('id', 44)); - ok(true, 'hasAccessToRepo was called'); + assert.ok(repo.get('id', 44)); + assert.ok(true, 'hasAccessToRepo was called'); return false; } }).create(); diff --git a/tests/unit/components/builds-item-test.js b/tests/unit/components/builds-item-test.js index 9f36158d4e..e4530e83d5 100644 --- a/tests/unit/components/builds-item-test.js +++ b/tests/unit/components/builds-item-test.js @@ -27,7 +27,7 @@ test('it renders', function(assert) { component = this.subject(); component.set('build', attributes); this.append(); - ok(component.$().hasClass('passed'), 'component has right status class'); - equal(component.$('.row-branch a').text().trim(), 'foobarbranch', 'component renders branch if event is push'); + assert.ok(component.$().hasClass('passed'), 'component has right status class'); + assert.equal(component.$('.row-branch a').text().trim(), 'foobarbranch', 'component renders branch if event is push'); return equal(component.$('a[title="See the commit on GitHub"]').attr('href'), 'https://github.com/foo/bar/commit/a5e8093098f9c0fb46856b753fb8943c7fbf26f3', 'component generates right commit link'); }); diff --git a/tests/unit/components/caches-item-test.js b/tests/unit/components/caches-item-test.js index 958a9d7af5..e5ca548c2c 100644 --- a/tests/unit/components/caches-item-test.js +++ b/tests/unit/components/caches-item-test.js @@ -4,7 +4,7 @@ moduleForComponent('caches-item', 'CachesItemComponent', { needs: ['helper:format-time', 'helper:travis-mb', 'component:request-icon'] }); -test('it renders', function() { +test('it renders', function(assert) { var attributes, component; attributes = { repository_id: 10, @@ -17,7 +17,7 @@ test('it renders', function() { cache: attributes }); this.append(); - ok(component.$().hasClass('push'), 'component should have a type class (push)'); - equal(component.$('.row-item:first-child .label-align').text().trim(), 'master', 'branch name should be displayed'); + assert.ok(component.$().hasClass('push'), 'component should have a type class (push)'); + assert.equal(component.$('.row-item:first-child .label-align').text().trim(), 'master', 'branch name should be displayed'); return equal(component.$('.row-item:nth-child(3) .label-align').text().trim(), '1.00MB', 'size should be displayed'); }); diff --git a/tests/unit/components/hooks-list-item-test.js b/tests/unit/components/hooks-list-item-test.js index 236e1c5657..287ffaa949 100644 --- a/tests/unit/components/hooks-list-item-test.js +++ b/tests/unit/components/hooks-list-item-test.js @@ -4,7 +4,7 @@ moduleForComponent('hooks-list-item', 'HooksListItemComponent', { needs: ['component:hook-switch'] }); -test('it renders', function() { +test('it renders', function(assert) { var attributes, component; attributes = { id: 10000, @@ -19,7 +19,7 @@ test('it renders', function() { hook: attributes }); this.append(); - ok(component.$().hasClass('active'), 'component should have active class'); - ok(component.$('.switch--icon').hasClass('active'), 'switch should have active class'); + assert.ok(component.$().hasClass('active'), 'component should have active class'); + assert.ok(component.$('.switch--icon').hasClass('active'), 'switch should have active class'); return equal(component.$('.profile-repo span').text().trim(), 'A foo repo', 'repo description should be displayed'); }); diff --git a/tests/unit/components/job-repo-actions-test.js b/tests/unit/components/job-repo-actions-test.js index 64b1208c76..4dd591cac7 100644 --- a/tests/unit/components/job-repo-actions-test.js +++ b/tests/unit/components/job-repo-actions-test.js @@ -3,7 +3,7 @@ import Ember from 'ember'; moduleForComponent('job-repo-actions', 'JobRepoActionsComponent', {}); -test('it shows cancel button if canCancel is true', function() { +test('it shows cancel button if canCancel is true', function(assert) { var component; component = this.subject({ canCancel: true @@ -12,7 +12,7 @@ test('it shows cancel button if canCancel is true', function() { return ok(component.$('a[title="Cancel job"]').length, 'cancel link should be visible'); }); -test('it shows restart button if canRestart is true', function() { +test('it shows restart button if canRestart is true', function(assert) { var component; component = this.subject({ canRestart: true @@ -21,7 +21,7 @@ test('it shows restart button if canRestart is true', function() { return ok(component.$('a[title="Restart job"]').length, 'restart link should be visible'); }); -test('user can cancel if she has permissions to a repo and job is cancelable', function() { +test('user can cancel if she has permissions to a repo and job is cancelable', function(assert) { var component, job; job = Ember.Object.create({ canCancel: false, @@ -31,14 +31,14 @@ test('user can cancel if she has permissions to a repo and job is cancelable', f job: job, userHasPermissionForRepo: false }); - ok(!component.get('canCancel')); + assert.ok(!component.get('canCancel')); component.set('userHasPermissionForRepo', true); - ok(!component.get('canCancel')); + assert.ok(!component.get('canCancel')); job.set('canCancel', true); return ok(component.get('canCancel')); }); -test('user can restart if she has permissions to a repo and job is restartable', function() { +test('user can restart if she has permissions to a repo and job is restartable', function(assert) { var component, job; job = Ember.Object.create({ canRestart: false, @@ -48,23 +48,23 @@ test('user can restart if she has permissions to a repo and job is restartable', job: job, userHasPermissionForRepo: false }); - ok(!component.get('canRestart')); + assert.ok(!component.get('canRestart')); component.set('userHasPermissionForRepo', true); - ok(!component.get('canRestart')); + assert.ok(!component.get('canRestart')); job.set('canRestart', true); return ok(component.get('canRestart')); }); -test('it properly checks for user permissions for a repo', function() { +test('it properly checks for user permissions for a repo', function(assert) { var component, repo, user; - expect(3); + assert.expect(3); repo = Ember.Object.create({ id: 44 }); user = Ember.Object.extend({ hasAccessToRepo: function(repo) { - ok(repo.get('id', 44)); - ok(true, 'hasAccessToRepo was called'); + assert.ok(repo.get('id', 44)); + assert.ok(true, 'hasAccessToRepo was called'); return false; } }).create(); diff --git a/tests/unit/components/jobs-item-test.js b/tests/unit/components/jobs-item-test.js index 5af424db07..8865d2d70a 100644 --- a/tests/unit/components/jobs-item-test.js +++ b/tests/unit/components/jobs-item-test.js @@ -4,7 +4,7 @@ moduleForComponent('jobs-item', 'JobsItemComponent', { needs: ['helper:format-duration', 'helper:pretty-date', 'component:status-icon'] }); -test('it renders', function() { +test('it renders', function(assert) { var attributes, component, job; attributes = { id: 10, @@ -23,26 +23,26 @@ test('it renders', function() { job: job }); this.append(); - ok(component.$().hasClass('passed'), 'component should have a state class (passed)'); - equal(component.$('.job-number').text().trim(), '2', 'job number should be displayed'); - equal(component.$('.job-lang').text().trim(), 'JDK: openjdk6 Ruby: 2.1.2', 'langauges list should be displayed'); - equal(component.$('.job-env').text().trim(), 'TESTS=unit', 'env should be displayed'); - ok(component.$('.job-os').hasClass('linux'), 'OS class should be added for OS icon'); + assert.ok(component.$().hasClass('passed'), 'component should have a state class (passed)'); + assert.equal(component.$('.job-number').text().trim(), '2', 'job number should be displayed'); + assert.equal(component.$('.job-lang').text().trim(), 'JDK: openjdk6 Ruby: 2.1.2', 'langauges list should be displayed'); + assert.equal(component.$('.job-env').text().trim(), 'TESTS=unit', 'env should be displayed'); + assert.ok(component.$('.job-os').hasClass('linux'), 'OS class should be added for OS icon'); return equal(component.$('.job-duration').text().trim(), '1 min 40 sec', 'duration should be displayed'); }); -test('outputs info on not set properties', function() { +test('outputs info on not set properties', function(assert) { var component, job; job = Ember.Object.create(); component = this.subject({ job: job }); this.append(); - ok(component.$('.job-env').text().match(/no environment variables set/), 'a message for no env vars should be displayed'); + assert.ok(component.$('.job-env').text().match(/no environment variables set/), 'a message for no env vars should be displayed'); return ok(component.$('.job-lang').text().match(/no language set/), 'a message about no language being set should be displayed'); }); -test('when env is not set, gemfile is displayed in the env section', function() { +test('when env is not set, gemfile is displayed in the env section', function(assert) { var attributes, component, job; attributes = { id: 10, @@ -59,11 +59,11 @@ test('when env is not set, gemfile is displayed in the env section', function() job: job }); this.append(); - equal(component.$('.job-lang .label-align').text().trim(), 'Ruby: 2.1.2', 'langauges list should be displayed'); + assert.equal(component.$('.job-lang .label-align').text().trim(), 'Ruby: 2.1.2', 'langauges list should be displayed'); return equal(component.$('.job-env .label-align').text().trim(), 'Gemfile: foo/Gemfile', 'env should be displayed'); }); -test('when env is set, gemfile is displayed in the language section', function() { +test('when env is set, gemfile is displayed in the language section', function(assert) { var attributes, component, job; attributes = { id: 10, @@ -81,6 +81,6 @@ test('when env is set, gemfile is displayed in the language section', function() job: job }); this.append(); - equal(component.$('.job-lang .label-align').text().trim(), 'Ruby: 2.1.2 Gemfile: foo/Gemfile', 'Gemfile should be displayed in languages section'); + assert.equal(component.$('.job-lang .label-align').text().trim(), 'Ruby: 2.1.2 Gemfile: foo/Gemfile', 'Gemfile should be displayed in languages section'); return equal(component.$('.job-env .label-align').text().trim(), 'FOO=bar', 'env should be displayed'); }); diff --git a/tests/unit/components/jobs-list-test.js b/tests/unit/components/jobs-list-test.js index a0b4d07283..4fa9fb5a24 100644 --- a/tests/unit/components/jobs-list-test.js +++ b/tests/unit/components/jobs-list-test.js @@ -5,7 +5,7 @@ moduleForComponent('jobs-list', 'JobsListComponent', { needs: ['helper:format-duration', 'component:jobs-item'] }); -test('it renders a list of jobs', function() { +test('it renders a list of jobs', function(assert) { var component, jobs; jobs = [ Ember.Object.create({ @@ -21,13 +21,13 @@ test('it renders a list of jobs', function() { required: true }); this.append(); - equal(component.$('.section-title').text().trim(), 'Build Jobs'); - equal(component.$('.jobs-item').length, 2, 'there should be 2 job items'); - ok(component.$('.jobs-item:nth(0)').hasClass('passed'), 'passed class should be applied to a job'); + assert.equal(component.$('.section-title').text().trim(), 'Build Jobs'); + assert.equal(component.$('.jobs-item').length, 2, 'there should be 2 job items'); + assert.ok(component.$('.jobs-item:nth(0)').hasClass('passed'), 'passed class should be applied to a job'); return ok(component.$('.jobs-item:nth(1)').hasClass('failed'), 'failed class should be applied to a job'); }); -test('it renders "Allowed Failures" version without a `required` property', function() { +test('it renders "Allowed Failures" version without a `required` property', function(assert) { var component, jobs; jobs = [ Ember.Object.create({ diff --git a/tests/unit/components/loading-indicator-test.js b/tests/unit/components/loading-indicator-test.js index 9bc32e6387..b6fb6d0902 100644 --- a/tests/unit/components/loading-indicator-test.js +++ b/tests/unit/components/loading-indicator-test.js @@ -8,6 +8,6 @@ test('it renders', function(assert) { center: true }); this.append(); - ok(component.$('span').hasClass('loading-indicator'), 'component has loading indicator class'); + assert.ok(component.$('span').hasClass('loading-indicator'), 'component has loading indicator class'); return ok(component.$().hasClass('loading-container'), 'indicator gets parent class if centered flag is given'); }); diff --git a/tests/unit/components/owner-repo-tile-test.js b/tests/unit/components/owner-repo-tile-test.js index 75f2e145b1..689855967f 100644 --- a/tests/unit/components/owner-repo-tile-test.js +++ b/tests/unit/components/owner-repo-tile-test.js @@ -4,7 +4,7 @@ moduleForComponent('owner-repo-tile', 'OwnerRepoTileComponent', { needs: ['helper:format-time', 'helper:format-duration', 'helper:format-sha', 'component:status-icon', 'component:request-icon'] }); -test('it renders', function() { +test('it renders', function(assert) { var attributes, component; attributes = { slug: "travis-ci/travis-chat", @@ -31,8 +31,8 @@ test('it renders', function() { repo: attributes }); this.append(); - ok(component.$().hasClass('passed'), 'component should have state class (passed)'); - equal(component.$('.row-item:nth-of-type(1)').text().trim(), 'travis-chat', 'should display correct repo name'); - equal(component.$('.row-item:nth-of-type(3)').text().trim(), 'master', 'should display branch name'); + assert.ok(component.$().hasClass('passed'), 'component should have state class (passed)'); + assert.equal(component.$('.row-item:nth-of-type(1)').text().trim(), 'travis-chat', 'should display correct repo name'); + assert.equal(component.$('.row-item:nth-of-type(3)').text().trim(), 'master', 'should display branch name'); return equal(component.$('.row-item:nth-of-type(4)').text().trim(), '16fff34', 'should display correct commit sha'); }); diff --git a/tests/unit/components/repo-actions-test.js b/tests/unit/components/repo-actions-test.js index c9eb770f80..d3e9b18fee 100644 --- a/tests/unit/components/repo-actions-test.js +++ b/tests/unit/components/repo-actions-test.js @@ -5,7 +5,7 @@ moduleForComponent('repo-actions', 'RepoActionsComponent', { needs: ['component:build-repo-actions', 'component:job-repo-actions'] }); -test('it displays code climate if the repo language is ruby', function() { +test('it displays code climate if the repo language is ruby', function(assert) { var component, repo; repo = Ember.Object.create({ githubLanguage: 'Ruby' @@ -14,11 +14,11 @@ test('it displays code climate if the repo language is ruby', function() { repo: repo }); this.append(); - ok(component.get('displayCodeClimate'), 'component should try to display code climate'); + assert.ok(component.get('displayCodeClimate'), 'component should try to display code climate'); return ok(component.$('a[name=code-climate]').length, 'component should render a code climate button'); }); -test('it doesn\'t display code climate for other languages', function() { +test('it doesn\'t display code climate for other languages', function(assert) { var component, repo; repo = Ember.Object.create({ githubLanguage: 'Go' @@ -27,6 +27,6 @@ test('it doesn\'t display code climate for other languages', function() { repo: repo }); this.append(); - ok(!component.get('displayCodeClimate'), 'component should not try to display code climate'); + assert.ok(!component.get('displayCodeClimate'), 'component should not try to display code climate'); return ok(!component.$('a[name=code-climate]').length, 'component should not render a code climate button'); }); diff --git a/tests/unit/components/travis-status-test.js b/tests/unit/components/travis-status-test.js index 0b5759d473..b4ca5ca6e5 100644 --- a/tests/unit/components/travis-status-test.js +++ b/tests/unit/components/travis-status-test.js @@ -5,9 +5,9 @@ var server = null; moduleForComponent('travis-status', 'TravisStatusComponent', {}); -test('adds incident class to .status-circle', function() { +test('adds incident class to .status-circle', function(assert) { var component; - expect(3); + assert.expect(3); component = this.subject(); component.getStatus = function() { return new Ember.RSVP.Promise(function(resolve, reject) { @@ -18,8 +18,8 @@ test('adds incident class to .status-circle', function() { }); }); }; - ok(!component.get('status'), 'status is initially not set'); + assert.ok(!component.get('status'), 'status is initially not set'); this.append(); - equal(component.get('status'), 'major', 'status is updated from the API'); + assert.equal(component.get('status'), 'major', 'status is updated from the API'); return ok(component.$('.status-circle').hasClass('major'), 'status class is set on .status-circle'); }); diff --git a/tests/unit/components/user-avatar-test.js b/tests/unit/components/user-avatar-test.js index bd575f3411..565b28f3d6 100644 --- a/tests/unit/components/user-avatar-test.js +++ b/tests/unit/components/user-avatar-test.js @@ -6,7 +6,7 @@ moduleForComponent('user-avatar', 'UserAvatarComponent | Unit', { }); -test('it renders', function() { +test('it renders', function(assert) { var name = "Hello Test"; var url = "https://someurl.com/someimage.jpg"; @@ -14,8 +14,8 @@ test('it renders', function() { var component = this.subject({url: url, name: name}); this.append(); - ok(component.$().hasClass('avatar'), 'component should have right class'); - equal(component.$('.pseudo-avatar').data('initials'), 'HT', 'initials should be correct'); - equal(component.$('.real-avatar').attr('src'), 'https://someurl.com/someimage.jpg', 'avatar should be right'); + assert.ok(component.$().hasClass('avatar'), 'component should have right class'); + assert.equal(component.$('.pseudo-avatar').data('initials'), 'HT', 'initials should be correct'); + assert.equal(component.$('.real-avatar').attr('src'), 'https://someurl.com/someimage.jpg', 'avatar should be right'); }); diff --git a/tests/unit/mixins/polling-test.js b/tests/unit/mixins/polling-test.js index 76963defb1..4ef1707f85 100644 --- a/tests/unit/mixins/polling-test.js +++ b/tests/unit/mixins/polling-test.js @@ -56,7 +56,7 @@ moduleForComponent('polling-test', 'PollingMixin', { } }); -test('it properly stops polling hook without any models', function() { +test('it properly stops polling hook without any models', function(assert) { var component, expected; component = this.subject({ pollModels: null @@ -77,7 +77,7 @@ test('it properly stops polling hook without any models', function() { return deepEqual(pollingChangesHistory, expected); }); -test('it works even if one of the model is null', function() { +test('it works even if one of the model is null', function(assert) { var component, expected; component = this.subject({ model1: { @@ -110,7 +110,7 @@ test('it works even if one of the model is null', function() { return deepEqual(pollingChangesHistory, expected); }); -test('it polls for both models if they are present', function() { +test('it polls for both models if they are present', function(assert) { var component, expected; component = this.subject({ model1: { @@ -156,7 +156,7 @@ test('it polls for both models if they are present', function() { return deepEqual(pollingChangesHistory, expected); }); -test('it detects model changes', function() { +test('it detects model changes', function(assert) { var component, expected; component = this.subject({ model1: { diff --git a/tests/unit/models/commit-test.js b/tests/unit/models/commit-test.js index ee653c38b3..5dfad78aa8 100644 --- a/tests/unit/models/commit-test.js +++ b/tests/unit/models/commit-test.js @@ -5,7 +5,7 @@ moduleForModel('commit', 'Unit | Model | commit', { needs: ['model:build'] }); -test('calculation of avatar urls via Gravatar', function() { +test('calculation of avatar urls via Gravatar', function(assert) { var model; model = this.subject(); Ember.run(function() { @@ -16,11 +16,11 @@ test('calculation of avatar urls via Gravatar', function() { committerAvatarUrl: null }); }); - equal(model.get('authorAvatarUrlOrGravatar'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=blank', 'correctly sets gravatar image'); + assert.equal(model.get('authorAvatarUrlOrGravatar'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=blank', 'correctly sets gravatar image'); return equal(model.get('committerAvatarUrlOrGravatar'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=blank', 'correctly sets gravatar image'); }); -test('calculation of avatar urls via overriding parameter', function() { +test('calculation of avatar urls via overriding parameter', function(assert) { var model; model = this.subject(); Ember.run(function() { @@ -31,6 +31,6 @@ test('calculation of avatar urls via overriding parameter', function() { committerAvatarUrl: 'http://example.com/test2.jpg' }); }); - equal(model.get('authorAvatarUrlOrGravatar'), 'http://example.com/test.jpg', 'correctly sets avatar'); + assert.equal(model.get('authorAvatarUrlOrGravatar'), 'http://example.com/test.jpg', 'correctly sets avatar'); return equal(model.get('committerAvatarUrlOrGravatar'), 'http://example.com/test2.jpg', 'correctly sets avatar'); }); diff --git a/tests/unit/services/polling-test.js b/tests/unit/services/polling-test.js index 1ea5e7b28f..27fb218392 100644 --- a/tests/unit/services/polling-test.js +++ b/tests/unit/services/polling-test.js @@ -1,3 +1,4 @@ +import {module, test} from 'qunit'; import Ember from 'ember'; import Polling from 'travis/services/polling'; import config from 'travis/config/environment'; @@ -5,10 +6,10 @@ import config from 'travis/config/environment'; var service; module('PollingService', { - setup() { + beforeEach() { return config.ajaxPolling = true; }, - teardown() { + afterEach() { config.ajaxPolling = false; if (!service.get('isDestroyed')) { return Ember.run(function() { @@ -18,22 +19,22 @@ module('PollingService', { } }); -test('polls for each of the models', function() { +test('polls for each of the models', function(assert) { var history, model1, model2; - expect(3); + assert.expect(3); history = []; service = Polling.create({ pollingInterval: 20 }); model1 = { reload: function() { - ok(true); + assert.ok(true); return history.push('model1'); } }; model2 = { reload: function() { - ok(true); + assert.ok(true); return history.push('model2'); } }; @@ -42,16 +43,16 @@ test('polls for each of the models', function() { stop(); return setTimeout(function() { start(); - deepEqual(history, ['model1', 'model2']); + assert.deepEqual(history, ['model1', 'model2']); return Ember.run(function() { return service.destroy(); }); }, 30); }); -test('it will stop running any reloads after it is destroyed', function() { +test('it will stop running any reloads after it is destroyed', function(assert) { var model; - expect(1); + assert.expect(1); service = Polling.create({ pollingInterval: 20 }); @@ -72,22 +73,22 @@ test('it will stop running any reloads after it is destroyed', function() { }, 50); }); -test('it stops reloading models after they were removed from polling', function() { +test('it stops reloading models after they were removed from polling', function(assert) { var history, model1, model2; - expect(4); + assert.expect(4); history = []; service = Polling.create({ pollingInterval: 30 }); model1 = { reload: function() { - ok(true); + assert.ok(true); return history.push('model1'); } }; model2 = { reload: function() { - ok(true); + assert.ok(true); return history.push('model2'); } }; @@ -106,9 +107,9 @@ test('it stops reloading models after they were removed from polling', function( }, 40); }); -test('it runs a hook on each interval', function() { +test('it runs a hook on each interval', function(assert) { var history, source; - expect(1); + assert.expect(1); history = []; service = Polling.create({ pollingInterval: 20 @@ -131,9 +132,9 @@ test('it runs a hook on each interval', function() { }, 30); }); -test('it will not run pollHook if the source is destroyed', function() { +test('it will not run pollHook if the source is destroyed', function(assert) { var history, source; - expect(1); + assert.expect(1); history = []; service = Polling.create({ pollingInterval: 20 diff --git a/tests/unit/utils/favicon-manager-test.js b/tests/unit/utils/favicon-manager-test.js index 9c0b0262e9..de20d9745d 100644 --- a/tests/unit/utils/favicon-manager-test.js +++ b/tests/unit/utils/favicon-manager-test.js @@ -1,3 +1,4 @@ +import {module, test} from 'qunit'; import Ember from 'ember'; import FaviconManager from 'travis/utils/favicon-manager'; @@ -14,45 +15,45 @@ module("Favicon manager", { } }); -test('use tag by default', function() { +test('use tag by default', function(assert) { manager = new FaviconManager(); return equal(manager.getHeadTag(), $('head')[0]); }); -test('set favicon if there is no link tag in head', function() { +test('set favicon if there is no link tag in head', function(assert) { var link; - equal(fakeHead.find('link').length, 0, 'there should be no link tags initially'); + assert.equal(fakeHead.find('link').length, 0, 'there should be no link tags initially'); manager.setFavicon('foobar'); link = fakeHead.find('link')[0]; - ok(link, 'link tag should be added by favicon manager'); + assert.ok(link, 'link tag should be added by favicon manager'); stop(); return setTimeout(function() { start(); - equal(link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set'); - equal(link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set'); + assert.equal(link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set'); + assert.equal(link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set'); return equal(link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set'); }, 20); }); -test('replace exisiting link tag', function() { +test('replace exisiting link tag', function(assert) { var link, links; fakeHead.append($('')); - ok('foo', fakeHead.find('link').attr('id'), 'initially link should exist'); + assert.ok('foo', fakeHead.find('link').attr('id'), 'initially link should exist'); manager.setFavicon('foobar'); links = fakeHead.find('link'); - equal(links.length, 1, 'there should be only one link in head'); + assert.equal(links.length, 1, 'there should be only one link in head'); link = links[0]; - ok(!link.getAttribute('id'), 'existing link should be replaced with a new one'); + assert.ok(!link.getAttribute('id'), 'existing link should be replaced with a new one'); stop(); return setTimeout(function() { start(); - equal(link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set'); - equal(link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set'); + assert.equal(link.getAttribute('href'), 'foobar', 'href attribute for the link should be properly set'); + assert.equal(link.getAttribute('rel'), 'icon', 'rel attribute for the link should be properly set'); return equal(link.getAttribute('type'), 'image/png', 'type attribute for the link should be properly set'); }, 20); }); -test('find link with rel=icon only', function() { +test('find link with rel=icon only', function(assert) { fakeHead.append($('')); return ok(!manager.getLinkTag()); }); diff --git a/tests/unit/utils/status-image-formats-test.js b/tests/unit/utils/status-image-formats-test.js index c0001dc3a9..81fb48211b 100644 --- a/tests/unit/utils/status-image-formats-test.js +++ b/tests/unit/utils/status-image-formats-test.js @@ -1,16 +1,17 @@ +import {module, test} from 'qunit'; import Ember from 'ember'; import format from 'travis/utils/status-image-formats'; import config from 'travis/config/environment'; module('Status image formats'); -test('it generates CCTray url with a slug', function() { +test('it generates CCTray url with a slug', function(assert) { var url; url = format('CCTray', 'travis-ci/travis-web'); return equal(url, '#/repos/travis-ci/travis-web/cc.xml'); }); -test('it generates CCTray url with a slug and a branch', function() { +test('it generates CCTray url with a slug and a branch', function(assert) { var url; url = format('CCTray', 'travis-ci/travis-web', 'development'); return equal(url, '#/repos/travis-ci/travis-web/cc.xml?branch=development');