-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use Ember.get in conjunction with dynamic strings in the job-pl…
…an serializer
- Loading branch information
1 parent
f2b4fbc
commit 8909046
Showing
2 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { test } from 'ember-qunit'; | ||
import JobPlanModel from 'nomad-ui/models/job-plan'; | ||
import moduleForSerializer from '../../helpers/module-for-serializer'; | ||
|
||
moduleForSerializer('job-plan', 'Unit | Serializer | JobPlan', { | ||
needs: [ | ||
'service:token', | ||
'service:system', | ||
'serializer:job-plan', | ||
'transform:fragment-array', | ||
'model:placement-failure', | ||
], | ||
}); | ||
|
||
const normalizationTestCases = [ | ||
{ | ||
name: 'Normal', | ||
in: { | ||
ID: 'test-plan', | ||
Diff: { | ||
Arbitrary: 'Value', | ||
}, | ||
FailedTGAllocs: { | ||
taskGroup: { | ||
NodesAvailable: 10, | ||
}, | ||
}, | ||
}, | ||
out: { | ||
data: { | ||
id: 'test-plan', | ||
type: 'job-plan', | ||
attributes: { | ||
diff: { | ||
Arbitrary: 'Value', | ||
}, | ||
failedTGAllocs: [ | ||
{ | ||
name: 'taskGroup', | ||
nodesAvailable: 10, | ||
}, | ||
], | ||
}, | ||
relationships: {}, | ||
}, | ||
}, | ||
}, | ||
|
||
{ | ||
name: 'Dots in task names', | ||
in: { | ||
ID: 'test-plan', | ||
Diff: { | ||
Arbitrary: 'Value', | ||
}, | ||
FailedTGAllocs: { | ||
'one.two': { | ||
NodesAvailable: 10, | ||
}, | ||
'three.four': { | ||
NodesAvailable: 25, | ||
}, | ||
}, | ||
}, | ||
out: { | ||
data: { | ||
id: 'test-plan', | ||
type: 'job-plan', | ||
attributes: { | ||
diff: { | ||
Arbitrary: 'Value', | ||
}, | ||
failedTGAllocs: [ | ||
{ | ||
name: 'one.two', | ||
nodesAvailable: 10, | ||
}, | ||
{ | ||
name: 'three.four', | ||
nodesAvailable: 25, | ||
}, | ||
], | ||
}, | ||
relationships: {}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
normalizationTestCases.forEach(testCase => { | ||
test(`normalization: ${testCase.name}`, function(assert) { | ||
assert.deepEqual(this.subject().normalize(JobPlanModel, testCase.in), testCase.out); | ||
}); | ||
}); |