github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/tests/unit/serializers/job-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupTest } from 'ember-qunit'; 3 import JobModel from 'nomad-ui/models/job'; 4 5 module('Unit | Serializer | Job', function(hooks) { 6 setupTest(hooks); 7 hooks.beforeEach(function() { 8 this.store = this.owner.lookup('service:store'); 9 this.subject = () => this.store.serializerFor('job'); 10 }); 11 12 test('`default` is used as the namespace in the job ID when there is no namespace in the payload', async function(assert) { 13 const original = { 14 ID: 'example', 15 Name: 'example', 16 }; 17 18 const { data } = this.subject().normalize(JobModel, original); 19 assert.equal(data.id, JSON.stringify([data.attributes.name, 'default'])); 20 }); 21 22 test('The ID of the record is a composite of both the name and the namespace', async function(assert) { 23 const original = { 24 ID: 'example', 25 Name: 'example', 26 Namespace: 'special-namespace', 27 }; 28 29 const { data } = this.subject().normalize(JobModel, original); 30 assert.equal( 31 data.id, 32 JSON.stringify([data.attributes.name, data.relationships.namespace.data.id]) 33 ); 34 }); 35 });