Skip to content

Commit

Permalink
Upgrade tests to be QUnit 2.0 compatible
Browse files Browse the repository at this point in the history
As noted in [this
issue](ember-cli/ember-cli#3197),
assert is now to be prepended to assertions and passed in to
the test function.

This commit was generated by ember-watson.
  • Loading branch information
clekstro committed Jan 31, 2016
1 parent 4b9d9fd commit a56b854
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 111 deletions.
10 changes: 5 additions & 5 deletions tests/unit/components/branch-row-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions tests/unit/components/build-repo-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/components/builds-item-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/unit/components/caches-item-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/unit/components/hooks-list-item-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions tests/unit/components/job-repo-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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();
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/components/jobs-item-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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');
});
10 changes: 5 additions & 5 deletions tests/unit/components/jobs-list-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/components/loading-indicator-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/unit/components/owner-repo-tile-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/unit/components/repo-actions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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');
});
8 changes: 4 additions & 4 deletions tests/unit/components/travis-status-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');
});
Loading

0 comments on commit a56b854

Please sign in to comment.