github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/ui/tests/unit/serializers/job-test.js (about)

     1  import { test } from 'ember-qunit';
     2  import JobModel from 'nomad-ui/models/job';
     3  import moduleForSerializer from '../../helpers/module-for-serializer';
     4  
     5  moduleForSerializer('job', 'Unit | Serializer | Job', {
     6    needs: [
     7      'serializer:job',
     8      'model:task-group-summary',
     9      'model:task-group',
    10      'transform:fragment-array',
    11    ],
    12  });
    13  
    14  test('`default` is used as the namespace in the job ID when there is no namespace in the payload', function(assert) {
    15    const original = {
    16      ID: 'example',
    17      Name: 'example',
    18    };
    19  
    20    const { data } = this.subject().normalize(JobModel, original);
    21    assert.equal(data.id, JSON.stringify([data.attributes.name, 'default']));
    22  });
    23  
    24  test('The ID of the record is a composite of both the name and the namespace', function(assert) {
    25    const original = {
    26      ID: 'example',
    27      Name: 'example',
    28      Namespace: 'special-namespace',
    29    };
    30  
    31    const { data } = this.subject().normalize(JobModel, original);
    32    assert.equal(
    33      data.id,
    34      JSON.stringify([data.attributes.name, data.relationships.namespace.data.id])
    35    );
    36  });