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

     1  import { moduleFor, test } from 'ember-qunit';
     2  import repo from 'consul-ui/tests/helpers/repo';
     3  const NAME = 'coordinate';
     4  moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
     5    // Specify the other units that are required for this test.
     6    integration: true
     7  });
     8  
     9  const dc = 'dc-1';
    10  test('findAllByDatacenter returns the correct data for list endpoint', function(assert) {
    11    return repo(
    12      'Coordinate',
    13      'findAllByDatacenter',
    14      this.subject(),
    15      function retrieveStub(stub) {
    16        return stub(`/v1/coordinate/nodes?dc=${dc}`, {
    17          CONSUL_NODE_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.Node}"]`,
    31              })
    32            );
    33          })
    34        );
    35      }
    36    );
    37  });