-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bluepints/model-test: Add RFC232 variants
- Loading branch information
1 parent
763c5da
commit 9c24224
Showing
6 changed files
with
74 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
blueprints/model-test/qunit-files/tests/unit/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
blueprints/model-test/qunit-rfc-232-files/tests/unit/__path__/__test__.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('model:<%= dasherizedModuleName %>', '<%= friendlyTestDescription %>', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = run(() => store.createRecord('<%= dasherizedModuleName %>', {})); | ||
assert.ok(model); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,22 @@ const fixture = require('../helpers/fixture'); | |
describe('Acceptance: generate and destroy model blueprints', function() { | ||
setupTestHooks(this); | ||
|
||
beforeEach(function() { | ||
return emberNew(); | ||
}); | ||
|
||
|
||
it('model', function() { | ||
let args = ['model', 'foo']; | ||
|
||
return emberNew() | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('app/models/foo.js')) | ||
.to.contain('import DS from \'ember-data\';') | ||
.to.contain('export default DS.Model.extend('); | ||
|
||
expect(_file('tests/unit/models/foo-test.js')) | ||
.to.equal(fixture('model-test/foo-default.js')); | ||
})); | ||
}); | ||
}); | ||
|
||
it('model with attrs', function() { | ||
|
@@ -44,8 +48,7 @@ describe('Acceptance: generate and destroy model blueprints', function() { | |
'customAttr:custom-transform' | ||
]; | ||
|
||
return emberNew() | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('app/models/foo.js')) | ||
.to.contain('import DS from \'ember-data\';') | ||
.to.contain('export default DS.Model.extend(') | ||
|
@@ -60,14 +63,13 @@ describe('Acceptance: generate and destroy model blueprints', function() { | |
|
||
expect(_file('tests/unit/models/foo-test.js')) | ||
.to.equal(fixture('model-test/foo-default.js')); | ||
})); | ||
}); | ||
}); | ||
|
||
it('model with belongsTo', function() { | ||
let args = ['model', 'comment', 'post:belongs-to', 'author:belongs-to:user']; | ||
|
||
return emberNew() | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('app/models/comment.js')) | ||
.to.contain('import DS from \'ember-data\';') | ||
.to.contain('export default DS.Model.extend(') | ||
|
@@ -76,14 +78,13 @@ describe('Acceptance: generate and destroy model blueprints', function() { | |
|
||
expect(_file('tests/unit/models/comment-test.js')) | ||
.to.equal(fixture('model-test/comment-default.js')); | ||
})); | ||
}); | ||
}); | ||
|
||
it('model with hasMany', function() { | ||
let args = ['model', 'post', 'comments:has-many', 'otherComments:has-many:comment']; | ||
|
||
return emberNew() | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('app/models/post.js')) | ||
.to.contain('import DS from \'ember-data\';') | ||
.to.contain('export default DS.Model.extend(') | ||
|
@@ -92,31 +93,48 @@ describe('Acceptance: generate and destroy model blueprints', function() { | |
|
||
expect(_file('tests/unit/models/post-test.js')) | ||
.to.equal(fixture('model-test/post-default.js')); | ||
})); | ||
}); | ||
}); | ||
|
||
it('model-test', function() { | ||
let args = ['model-test', 'foo']; | ||
|
||
return emberNew() | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('tests/unit/models/foo-test.js')) | ||
.to.equal(fixture('model-test/foo-default.js')); | ||
})); | ||
}); | ||
}); | ||
|
||
it('model-test for mocha v0.12+', function() { | ||
let args = ['model-test', 'foo']; | ||
describe('model-test with [email protected]', function() { | ||
beforeEach(function() { | ||
generateFakePackageManifest('ember-cli-qunit', '4.2.0'); | ||
}); | ||
|
||
it('model-test-test foo', function() { | ||
return emberGenerateDestroy(['model-test', 'foo'], _file => { | ||
expect(_file('tests/unit/models/foo-test.js')) | ||
.to.equal(fixture('model-test/rfc232.js')); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
describe('with ember-cli-mocha v0.12+', function() { | ||
beforeEach(function() { | ||
modifyPackages([ | ||
{ name: 'ember-cli-qunit', delete: true }, | ||
{ name: 'ember-cli-mocha', dev: true } | ||
]); | ||
generateFakePackageManifest('ember-cli-mocha', '0.12.0'); | ||
}); | ||
|
||
it('model-test for mocha v0.12+', function() { | ||
let args = ['model-test', 'foo']; | ||
|
||
return emberNew() | ||
.then(() => modifyPackages([ | ||
{name: 'ember-cli-qunit', delete: true}, | ||
{name: 'ember-cli-mocha', dev: true} | ||
])) | ||
.then(() => generateFakePackageManifest('ember-cli-mocha', '0.12.0')) | ||
.then(() => emberGenerateDestroy(args, _file => { | ||
return emberGenerateDestroy(args, _file => { | ||
expect(_file('tests/unit/models/foo-test.js')) | ||
.to.equal(fixture('model-test/foo-mocha-0.12.js')); | ||
})); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('model:foo', 'Unit | Model | foo', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = run(() => store.createRecord('foo', {})); | ||
assert.ok(model); | ||
}); | ||
}); |