github.com/outbrain/consul@v1.4.5/ui-v2/tests/integration/adapters/acl/url-test.js (about)

     1  import { module, test } from 'qunit';
     2  import { setupTest } from 'ember-qunit';
     3  import makeAttrable from 'consul-ui/utils/makeAttrable';
     4  module('Integration | Adapter | acl | url', function(hooks) {
     5    setupTest(hooks);
     6    const dc = 'dc-1';
     7    const id = 'token-name';
     8    test('urlForQuery returns the correct url', function(assert) {
     9      const adapter = this.owner.lookup('adapter:acl');
    10      const expected = `/v1/acl/list?dc=${dc}`;
    11      const actual = adapter.urlForQuery({
    12        dc: dc,
    13      });
    14      assert.equal(actual, expected);
    15    });
    16    test('urlForQueryRecord returns the correct url', function(assert) {
    17      const adapter = this.owner.lookup('adapter:acl');
    18      const expected = `/v1/acl/info/${id}?dc=${dc}`;
    19      const actual = adapter.urlForQueryRecord({
    20        dc: dc,
    21        id: id,
    22      });
    23      assert.equal(actual, expected);
    24    });
    25    test("urlForQueryRecord throws if you don't specify an id", function(assert) {
    26      const adapter = this.owner.lookup('adapter:acl');
    27      assert.throws(function() {
    28        adapter.urlForQueryRecord({
    29          dc: dc,
    30        });
    31      });
    32    });
    33    test('urlForCreateRecord returns the correct url', function(assert) {
    34      const adapter = this.owner.lookup('adapter:acl');
    35      const expected = `/v1/acl/create?dc=${dc}`;
    36      const actual = adapter.urlForCreateRecord(
    37        'acl',
    38        makeAttrable({
    39          Datacenter: dc,
    40          ID: id,
    41        })
    42      );
    43      assert.equal(actual, expected);
    44    });
    45    test('urlForUpdateRecord returns the correct url', function(assert) {
    46      const adapter = this.owner.lookup('adapter:acl');
    47      const expected = `/v1/acl/update?dc=${dc}`;
    48      const actual = adapter.urlForUpdateRecord(
    49        id,
    50        'acl',
    51        makeAttrable({
    52          Datacenter: dc,
    53          ID: id,
    54        })
    55      );
    56      assert.equal(actual, expected);
    57    });
    58    test('urlForDeleteRecord returns the correct url', function(assert) {
    59      const adapter = this.owner.lookup('adapter:acl');
    60      const expected = `/v1/acl/destroy/${id}?dc=${dc}`;
    61      const actual = adapter.urlForDeleteRecord(
    62        id,
    63        'acl',
    64        makeAttrable({
    65          Datacenter: dc,
    66          ID: id,
    67        })
    68      );
    69      assert.equal(actual, expected);
    70    });
    71    test('urlForCloneRecord returns the correct url', function(assert) {
    72      const adapter = this.owner.lookup('adapter:acl');
    73      const expected = `/v1/acl/clone/${id}?dc=${dc}`;
    74      const actual = adapter.urlForCloneRecord(
    75        'acl',
    76        makeAttrable({
    77          Datacenter: dc,
    78          ID: id,
    79        })
    80      );
    81      assert.equal(actual, expected);
    82    });
    83  });