fixed merge conflict in tests/index
This commit is contained in:
commit
8730b6659f
116 changed files with 1793 additions and 1106 deletions
76
tests/acceptance/strains-test.js
Normal file
76
tests/acceptance/strains-test.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
import Ember from 'ember';
|
||||
import { module, test } from 'qunit';
|
||||
import startApp from '../helpers/start-app';
|
||||
import { authenticateSession } from '../helpers/ember-simple-auth';
|
||||
|
||||
module('Acceptance | strains', {
|
||||
beforeEach: function() {
|
||||
this.application = startApp();
|
||||
authenticateSession(this.application, {
|
||||
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
|
||||
});
|
||||
server.create('users', { role: 'A', canEdit: true });
|
||||
},
|
||||
|
||||
afterEach: function() {
|
||||
Ember.run(this.application, 'destroy');
|
||||
}
|
||||
});
|
||||
|
||||
test('visiting /strains', function(assert) {
|
||||
const species = server.create('species');
|
||||
const strains = server.createList('strains', 20, { species: species.id });
|
||||
visit('/strains');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), '/strains');
|
||||
assert.equal(find(".flakes-table > tbody > tr").length, strains.length);
|
||||
assert.equal(find("#total-strains").text(), "Total strains: 20");
|
||||
});
|
||||
});
|
||||
|
||||
test('visiting /strains/:id', function(assert) {
|
||||
const species = server.create('species');
|
||||
const strain = server.create('strains', { species: species.id });
|
||||
visit(`/strains/${strain.id}`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/strains/${strain.id}`);
|
||||
const typeStrain = strain.typeStrain ? 'T' : '';
|
||||
assert.equal(find(".flakes-information-box > legend").text().trim(), `${strain.strainName}${typeStrain}`);
|
||||
});
|
||||
});
|
||||
|
||||
test('editing /strains/:id/edit', function(assert) {
|
||||
const species = server.create('species');
|
||||
const strain = server.create('strains', { canEdit: true , species: species.id });
|
||||
visit(`/strains/${strain.id}/edit`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/strains/${strain.id}/edit`);
|
||||
|
||||
fillIn('.strain-name', 'Revised Strain Name');
|
||||
click('.save-strain');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/strains/${strain.id}`);
|
||||
const typeStrain = strain.typeStrain ? 'T' : '';
|
||||
assert.equal(find(".flakes-information-box > legend").text().trim(), `Revised Strain Name${typeStrain}`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('creating /strains/new', function(assert) {
|
||||
visit(`/strains/new`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/strains/new`);
|
||||
fillIn('.strain-name', 'New Strain Name');
|
||||
click('.save-strain');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(find(".flakes-information-box > legend").text().trim(), `New Strain Name`);
|
||||
assert.equal(server.db.strains.length, 1);
|
||||
});
|
||||
});
|
||||
});
|
77
tests/acceptance/users-test.js
Normal file
77
tests/acceptance/users-test.js
Normal file
|
@ -0,0 +1,77 @@
|
|||
import Ember from 'ember';
|
||||
import { module, test } from 'qunit';
|
||||
import startApp from '../helpers/start-app';
|
||||
import { invalidateSession, authenticateSession } from '../helpers/ember-simple-auth';
|
||||
|
||||
module('Acceptance | users', {
|
||||
beforeEach: function() {
|
||||
this.application = startApp();
|
||||
authenticateSession(this.application, {
|
||||
access_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJiYWN0ZGIiLCJzdWIiOiIxIiwiZXhwIjoxNDQ2NTAyMjI2LCJpYXQiOjE0NDY0OTg2MjZ9.vIjKHAsp2TkCV505EbtCo2xQT-2oQkB-Nv5y0b6E7Mg"
|
||||
});
|
||||
server.create('users', { role: 'A', canEdit: true });
|
||||
},
|
||||
|
||||
afterEach: function() {
|
||||
Ember.run(this.application, 'destroy');
|
||||
}
|
||||
});
|
||||
|
||||
test('visiting /users', function(assert) {
|
||||
const users = server.createList('users', 19); // We already created one user in beforeEach
|
||||
visit('/users');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), '/users');
|
||||
assert.equal(find(".flakes-table > tbody > tr").length, users.length + 1);
|
||||
assert.equal(find("#total-users").text(), "Total users: 20");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('visiting /users/:id', function(assert) {
|
||||
const user = server.create('users');
|
||||
visit(`/users/${user.id}`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/users/${user.id}`);
|
||||
assert.equal(find(".flakes-information-box > legend").text().trim(), user.name);
|
||||
});
|
||||
});
|
||||
|
||||
test('editing /users/:id/edit', function(assert) {
|
||||
const user = server.create('users', { 'canEdit': true });
|
||||
visit(`/users/${user.id}/edit`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/users/${user.id}/edit`);
|
||||
|
||||
fillIn('.user-name', 'Revised User Name');
|
||||
click('.save-user');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/users/${user.id}`);
|
||||
assert.equal(find(".flakes-information-box > legend").text().trim(), 'Revised User Name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('creating /users/new', function(assert) {
|
||||
invalidateSession(this.application);
|
||||
visit(`/users/new`);
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/users/new`);
|
||||
fillIn('.user-name', 'New User Name');
|
||||
fillIn('.email', 'example@example.com');
|
||||
fillIn('.password', 'Password1');
|
||||
fillIn('.password-verify', 'Password1');
|
||||
click('.save-user');
|
||||
|
||||
andThen(function() {
|
||||
assert.equal(currentURL(), `/login`);
|
||||
assert.equal(find(".flakes-message").text().trim(), `✖ You have successfully signed up.
|
||||
Please check your email for further instructions.`);
|
||||
});
|
||||
});
|
||||
});
|
5
tests/helpers/destroy-app.js
Normal file
5
tests/helpers/destroy-app.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default function destroyApp(application) {
|
||||
Ember.run(application, 'destroy');
|
||||
}
|
23
tests/helpers/module-for-acceptance.js
Normal file
23
tests/helpers/module-for-acceptance.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { module } from 'qunit';
|
||||
import startApp from '../helpers/start-app';
|
||||
import destroyApp from '../helpers/destroy-app';
|
||||
|
||||
export default function(name, options = {}) {
|
||||
module(name, {
|
||||
beforeEach() {
|
||||
this.application = startApp();
|
||||
|
||||
if (options.beforeEach) {
|
||||
options.beforeEach.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
destroyApp(this.application);
|
||||
|
||||
if (options.afterEach) {
|
||||
options.afterEach.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import Resolver from 'ember/resolver';
|
||||
import config from '../../config/environment';
|
||||
|
||||
var resolver = Resolver.create();
|
||||
const resolver = Resolver.create();
|
||||
|
||||
resolver.namespace = {
|
||||
modulePrefix: config.modulePrefix,
|
||||
|
|
|
@ -3,12 +3,12 @@ import Application from '../../app';
|
|||
import config from '../../config/environment';
|
||||
|
||||
export default function startApp(attrs) {
|
||||
var application;
|
||||
let application;
|
||||
|
||||
var attributes = Ember.merge({}, config.APP);
|
||||
let attributes = Ember.merge({}, config.APP);
|
||||
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
|
||||
|
||||
Ember.run(function() {
|
||||
Ember.run(() => {
|
||||
application = Application.create(attributes);
|
||||
application.setupForTesting();
|
||||
application.injectTestHelpers();
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
{{content-for 'test-head-footer'}}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{content-for 'body'}}
|
||||
{{content-for 'test-body'}}
|
||||
|
||||
<script src="assets/vendor.js"></script>
|
||||
<script src="assets/test-support.js"></script>
|
||||
<script src="assets/clostridiumdotinfo.js"></script>
|
||||
<script src="testem.js"></script>
|
||||
<script src="testem.js" integrity=""></script>
|
||||
<script src="assets/tests.js"></script>
|
||||
<script src="assets/test-loader.js"></script>
|
||||
|
||||
{{content-for 'body-footer'}}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
import Ember from 'ember';
|
||||
import { initialize } from '../../../initializers/component-store';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
var container, application;
|
||||
|
||||
module('Unit | Initializer | component store', {
|
||||
beforeEach: function() {
|
||||
Ember.run(function() {
|
||||
application = Ember.Application.create();
|
||||
container = application.__container__;
|
||||
application.deferReadiness();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it works', function(assert) {
|
||||
initialize(container, application);
|
||||
|
||||
// you would normally confirm the results of the initializer here
|
||||
assert.ok(true);
|
||||
});
|
Reference in a new issue