github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/ui/tests/unit/serializers/evaluation-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupTest } from 'ember-qunit'; 3 import EvaluationModel from 'nomad-ui/models/evaluation'; 4 5 module('Unit | Serializer | Evaluation', function(hooks) { 6 setupTest(hooks); 7 hooks.beforeEach(function() { 8 this.store = this.owner.lookup('service:store'); 9 this.subject = () => this.store.serializerFor('evaluation'); 10 }); 11 12 const normalizationTestCases = [ 13 { 14 name: 'Normal', 15 in: { 16 ID: 'test-eval', 17 FailedTGAllocs: { 18 taskGroup: { 19 NodesAvailable: 10, 20 }, 21 }, 22 JobID: 'some-job-id', 23 Job: { 24 Namespace: 'test-namespace', 25 }, 26 }, 27 out: { 28 data: { 29 id: 'test-eval', 30 type: 'evaluation', 31 attributes: { 32 failedTGAllocs: [ 33 { 34 name: 'taskGroup', 35 nodesAvailable: 10, 36 }, 37 ], 38 }, 39 relationships: { 40 job: { 41 data: { 42 id: '["some-job-id","test-namespace"]', 43 type: 'job', 44 }, 45 }, 46 }, 47 }, 48 }, 49 }, 50 51 { 52 name: 'Dots in task group names', 53 in: { 54 ID: 'test-eval', 55 FailedTGAllocs: { 56 'one.two': { 57 NodesAvailable: 10, 58 }, 59 'three.four': { 60 NodesAvailable: 25, 61 }, 62 }, 63 JobID: 'some-job-id', 64 Job: { 65 Namespace: 'test-namespace', 66 }, 67 }, 68 out: { 69 data: { 70 id: 'test-eval', 71 type: 'evaluation', 72 attributes: { 73 failedTGAllocs: [ 74 { 75 name: 'one.two', 76 nodesAvailable: 10, 77 }, 78 { 79 name: 'three.four', 80 nodesAvailable: 25, 81 }, 82 ], 83 }, 84 relationships: { 85 job: { 86 data: { 87 id: '["some-job-id","test-namespace"]', 88 type: 'job', 89 }, 90 }, 91 }, 92 }, 93 }, 94 }, 95 ]; 96 97 normalizationTestCases.forEach(testCase => { 98 test(`normalization: ${testCase.name}`, async function(assert) { 99 assert.deepEqual(this.subject().normalize(EvaluationModel, testCase.in), testCase.out); 100 }); 101 }); 102 });