-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blueprints/serializer-test: Add RFC232 variants #5298
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('<%= friendlyTestDescription %>', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let serializer = this.owner.factoryFor('serializer:<%= dasherizedModuleName %>').create({ store }); | ||
|
||
assert.ok(serializer); | ||
}); | ||
|
||
test('it serializes records', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let record = run(() => store.createRecord('<%= dasherizedModuleName %>', {})); | ||
|
||
let serializedRecord = record.serialize(); | ||
|
||
assert.ok(serializedRecord); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably use some sort of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine with whatever -- I simply copied the old ones https://github.com/emberjs/data/blob/master/blueprints/serializer-test/qunit-files/tests/unit/__path__/__test__.js#L14 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was playing around with adding I was under the impression that generated test cases should always pass when initially generated with a new model (e.g. running |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Serializer | foo', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let serializer = this.owner.factoryFor('serializer:foo').create({ store }); | ||
|
||
assert.ok(serializer); | ||
}); | ||
|
||
test('it serializes records', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let record = run(() => store.createRecord('foo', {})); | ||
|
||
let serializedRecord = record.serialize(); | ||
|
||
assert.ok(serializedRecord); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
.lookup
(notfactoryFor().create()
) because serializers are singleton...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need the store initialized on the serializer though, which lookup doesn't automatically do
is that something that should be addressed upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, this seems sorta bonkers. I submitted #5300 to simplify greatly 😺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-alvarez - Even without #5300, we should do
store.serializerFor(<%= dasherizedModelName %>)
here as that is the public API for getting a given things serializer. There are a few fallbacks that Ember Data handles nicely for you (e.g. use application if you don't have a model specific one) and we should go through the same common API.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood 👍