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

     1  import { moduleFor, test } from 'ember-qunit';
     2  import repo from 'consul-ui/tests/helpers/repo';
     3  const NAME = 'acl';
     4  moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
     5    // Specify the other units that are required for this test.
     6    integration: true
     7  });
     8  const dc = 'dc-1';
     9  const id = 'token-name';
    10  test('findByDatacenter returns the correct data for list endpoint', function(assert) {
    11    return repo(
    12      'Acl',
    13      'findAllByDatacenter',
    14      this.subject(),
    15      function retrieveStub(stub) {
    16        return stub(`/v1/acl/list?dc=${dc}`, {
    17          CONSUL_ACL_COUNT: '100',
    18        });
    19      },
    20      function performTest(service) {
    21        return service.findAllByDatacenter(dc);
    22      },
    23      function performAssertion(actual, expected) {
    24        assert.deepEqual(
    25          actual,
    26          expected(function(payload) {
    27            return payload.map(item =>
    28              Object.assign({}, item, {
    29                Datacenter: dc,
    30                uid: `["${dc}","${item.ID}"]`,
    31              })
    32            );
    33          })
    34        );
    35      }
    36    );
    37  });
    38  test('findBySlug returns the correct data for item endpoint', function(assert) {
    39    return repo(
    40      'Acl',
    41      'findBySlug',
    42      this.subject(),
    43      function retrieveStub(stub) {
    44        return stub(`/v1/acl/info/${id}?dc=${dc}`);
    45      },
    46      function performTest(service) {
    47        return service.findBySlug(id, dc);
    48      },
    49      function performAssertion(actual, expected) {
    50        assert.deepEqual(
    51          actual,
    52          expected(function(payload) {
    53            const item = payload[0];
    54            return Object.assign({}, item, {
    55              Datacenter: dc,
    56              uid: `["${dc}","${item.ID}"]`,
    57            });
    58          })
    59        );
    60      }
    61    );
    62  });