github.com/hernad/nomad@v1.6.112/ui/tests/unit/serializers/network-test.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { module, test } from 'qunit';
     7  import { setupTest } from 'ember-qunit';
     8  import NetworkModel from 'nomad-ui/models/network';
     9  
    10  module('Unit | Serializer | Network', function (hooks) {
    11    setupTest(hooks);
    12    hooks.beforeEach(function () {
    13      this.store = this.owner.lookup('service:store');
    14      this.subject = () => this.store.serializerFor('network');
    15    });
    16  
    17    test('v4 IPs are passed through', async function (assert) {
    18      const ip = '10.0.13.12';
    19      const original = {
    20        IP: ip,
    21      };
    22  
    23      const { data } = this.subject().normalize(NetworkModel, original);
    24      assert.equal(data.attributes.ip, ip);
    25    });
    26  
    27    test('v6 IPs are wrapped in square brackets', async function (assert) {
    28      const ip = '2001:0dac:aba3:0000:0000:8a2e:0370:7334';
    29      const original = {
    30        IP: ip,
    31      };
    32  
    33      const { data } = this.subject().normalize(NetworkModel, original);
    34      assert.equal(data.attributes.ip, `[${ip}]`);
    35    });
    36  });