Adapter Testing:
test('it has a url for creating a record', function (assert) { const url = this.subject().urlForCreateRecord('person', { firstName: 'Bob' }); assert.equal(url, 'https://example.com/path/to/api'); });
Serializer Testing:
test('it serializes records', function (assert) { const serialized = this.subject({ foo: 'bar', }).serialize(); assert.equal(serialized.foo, 'bar'); });
To test other serializer features, I previously followed the @Knightsy integration test example, and it worked for me. Many thanks! Then I decided that this could be simplified and checked for unity (if you can call it).
My test is as follows:
moduleForModel('person', 'Unit | Serializer | person', { needs: ['serializer:person'], }); test('testing', function (assert) { const serializer = this.container.lookup('service:store').serializerFor('person'); const payload = { id: 3, }; const response = serializer.normalizeSingleResponse(null, null, payload, payload.id); assert.equal(response.data.id, 3); });
Rimian
source share