github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/integration/services/repository/dc-test.js (about)

     1  import { moduleFor, test } from 'ember-qunit';
     2  import { skip } from 'qunit';
     3  import repo from 'consul-ui/tests/helpers/repo';
     4  const NAME = 'dc';
     5  moduleFor(`service:repository/${NAME}`, `Integration | Service | ${NAME}`, {
     6    // Specify the other units that are required for this test.
     7    integration: true,
     8  });
     9  skip("findBySlug (doesn't interact with the API) but still needs an int test");
    10  test('findAll returns the correct data for list endpoint', function(assert) {
    11    return repo(
    12      'Dc',
    13      'findAll',
    14      this.subject(),
    15      function retrieveStub(stub) {
    16        return stub(`/v1/catalog/datacenters`, {
    17          CONSUL_DATACENTER_COUNT: '100',
    18        });
    19      },
    20      function performTest(service) {
    21        return service.findAll();
    22      },
    23      function performAssertion(actual, expected) {
    24        assert.deepEqual(
    25          actual,
    26          expected(function(payload) {
    27            return payload.map(item => ({ Name: item })).sort(function(a, b) {
    28              if (a.Name < b.Name) return -1;
    29              if (a.Name > b.Name) return 1;
    30              return 0;
    31            });
    32          })
    33        );
    34      }
    35    );
    36  });