open-nomad/ui/tests/unit/serializers/network-test.js
Buck Doyle 34603b8bdf
UI: Add IPv6 bracket-wrapping to network serializer (#6007)
This addresses the issue raised by @pznamensky in #5966.
2019-07-30 16:58:01 -05:00

32 lines
923 B
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import NetworkModel from 'nomad-ui/models/network';
module('Unit | Serializer | Network', function(hooks) {
setupTest(hooks);
hooks.beforeEach(function() {
this.store = this.owner.lookup('service:store');
this.subject = () => this.store.serializerFor('network');
});
test('v4 IPs are passed through', async function(assert) {
const ip = '10.0.13.12';
const original = {
IP: ip,
};
const { data } = this.subject().normalize(NetworkModel, original);
assert.equal(data.attributes.ip, ip);
});
test('v6 IPs are wrapped in square brackets', async function(assert) {
const ip = '2001:0dac:aba3:0000:0000:8a2e:0370:7334';
const original = {
IP: ip,
};
const { data } = this.subject().normalize(NetworkModel, original);
assert.equal(data.attributes.ip, `[${ip}]`);
});
});