github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/tests/unit/serializers/network-test.js (about) 1 import { module, test } from 'qunit'; 2 import { setupTest } from 'ember-qunit'; 3 import NetworkModel from 'nomad-ui/models/network'; 4 5 module('Unit | Serializer | Network', function(hooks) { 6 setupTest(hooks); 7 hooks.beforeEach(function() { 8 this.store = this.owner.lookup('service:store'); 9 this.subject = () => this.store.serializerFor('network'); 10 }); 11 12 test('v4 IPs are passed through', async function(assert) { 13 const ip = '10.0.13.12'; 14 const original = { 15 IP: ip, 16 }; 17 18 const { data } = this.subject().normalize(NetworkModel, original); 19 assert.equal(data.attributes.ip, ip); 20 }); 21 22 test('v6 IPs are wrapped in square brackets', async function(assert) { 23 const ip = '2001:0dac:aba3:0000:0000:8a2e:0370:7334'; 24 const original = { 25 IP: ip, 26 }; 27 28 const { data } = this.subject().normalize(NetworkModel, original); 29 assert.equal(data.attributes.ip, `[${ip}]`); 30 }); 31 });