open-nomad/ui/tests/unit/serializers/job-test.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
2017-09-19 14:47:10 +00:00
import JobModel from 'nomad-ui/models/job';
module('Unit | Serializer | Job', function(hooks) {
setupTest(hooks);
hooks.beforeEach(function() {
this.store = this.owner.lookup('service:store');
this.subject = () => this.store.serializerFor('job');
});
2017-09-19 14:47:10 +00:00
test('`default` is used as the namespace in the job ID when there is no namespace in the payload', async function(assert) {
const original = {
ID: 'example',
Name: 'example',
};
const { data } = this.subject().normalize(JobModel, original);
assert.equal(data.id, JSON.stringify([data.attributes.name, 'default']));
});
test('The ID of the record is a composite of both the name and the namespace', async function(assert) {
const original = {
ID: 'example',
Name: 'example',
Namespace: 'special-namespace',
};
const { data } = this.subject().normalize(JobModel, original);
assert.equal(
data.id,
JSON.stringify([data.attributes.name, data.relationships.namespace.data.id])
);
});
});