104 lines
2.2 KiB
JavaScript
104 lines
2.2 KiB
JavaScript
|
import { test } from 'ember-qunit';
|
||
|
import JobSummaryModel from 'nomad-ui/models/job-summary';
|
||
|
import moduleForSerializer from '../../helpers/module-for-serializer';
|
||
|
|
||
|
moduleForSerializer('job-summary', 'Unit | Serializer | JobSummary', {
|
||
|
needs: [
|
||
|
'serializer:job-summary',
|
||
|
'transform:fragment-array',
|
||
|
'model:job',
|
||
|
'model:task-group-summary',
|
||
|
],
|
||
|
});
|
||
|
|
||
|
const normalizationTestCases = [
|
||
|
{
|
||
|
name: 'Normal',
|
||
|
in: {
|
||
|
JobID: 'test-summary',
|
||
|
Namespace: 'test-namespace',
|
||
|
Summary: {
|
||
|
taskGroup: {
|
||
|
Complete: 0,
|
||
|
Running: 1,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
out: {
|
||
|
data: {
|
||
|
id: '["test-summary","test-namespace"]',
|
||
|
type: 'job-summary',
|
||
|
attributes: {
|
||
|
taskGroupSummaries: [
|
||
|
{
|
||
|
name: 'taskGroup',
|
||
|
completeAllocs: 0,
|
||
|
runningAllocs: 1,
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
relationships: {
|
||
|
job: {
|
||
|
data: {
|
||
|
id: '["test-summary","test-namespace"]',
|
||
|
type: 'job',
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
|
||
|
{
|
||
|
name: 'Dots in task group names',
|
||
|
in: {
|
||
|
JobID: 'test-summary',
|
||
|
Namespace: 'test-namespace',
|
||
|
Summary: {
|
||
|
'one.two': {
|
||
|
Complete: 0,
|
||
|
Running: 1,
|
||
|
},
|
||
|
'three.four': {
|
||
|
Failed: 2,
|
||
|
Lost: 3,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
out: {
|
||
|
data: {
|
||
|
id: '["test-summary","test-namespace"]',
|
||
|
type: 'job-summary',
|
||
|
attributes: {
|
||
|
taskGroupSummaries: [
|
||
|
{
|
||
|
name: 'one.two',
|
||
|
completeAllocs: 0,
|
||
|
runningAllocs: 1,
|
||
|
},
|
||
|
{
|
||
|
name: 'three.four',
|
||
|
failedAllocs: 2,
|
||
|
lostAllocs: 3,
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
relationships: {
|
||
|
job: {
|
||
|
data: {
|
||
|
id: '["test-summary","test-namespace"]',
|
||
|
type: 'job',
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
];
|
||
|
|
||
|
normalizationTestCases.forEach(testCase => {
|
||
|
test(`normalization: ${testCase.name}`, function(assert) {
|
||
|
assert.deepEqual(this.subject().normalize(JobSummaryModel, testCase.in), testCase.out);
|
||
|
});
|
||
|
});
|