Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Ember from 'ember';
- import { test, moduleFor } from 'ember-qunit';
- import run from 'ember-runloop';
- const { getOwner } = Ember;
- let store;
- moduleFor('serializer:note', {
- integration: true,
- beforeEach() {
- store = getOwner(this).lookup('service:store');
- }
- });
- test('#serialize', function(assert) {
- assert.expect(1);
- let serializer = this.subject();
- let note;
- run(() => {
- note = store.createRecord('note', {
- body: 'foo'
- });
- });
- let snapshot = note._createSnapshot();
- let json = serializer.serialize(snapshot);
- // Could do:
- // let json = note.serialize()
- // ...but that is a confusing indirect test
- assert.equal(json.content, 'foo',
- "serializes a note's body into `content`");
- });
- test('#normalize', function(assert) {
- assert.expect(1);
- let serializer = this.subject();
- let modelClass = store.modelFor('note');
- let resourceHash = { content: 'foo' };
- let json = serializer.normalize(modelClass, resourceHash);
- assert.equal(json.data.attributes.body, 'foo',
- "a note's content is interpreted as `body`");
- });
Advertisement
Add Comment
Please, Sign In to add comment