github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/integration/services/repository/node-test.js (about) 1 import { moduleFor, test } from 'ember-qunit'; 2 import repo from 'consul-ui/tests/helpers/repo'; 3 const NAME = 'node'; 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 const id = 'token-name'; 11 test('findByDatacenter returns the correct data for list endpoint', function(assert) { 12 return repo( 13 'Node', 14 'findAllByDatacenter', 15 this.subject(), 16 function retrieveStub(stub) { 17 return stub(`/v1/internal/ui/nodes?dc=${dc}`, { 18 CONSUL_NODE_COUNT: '100', 19 }); 20 }, 21 function performTest(service) { 22 return service.findAllByDatacenter(dc); 23 }, 24 function performAssertion(actual, expected) { 25 assert.deepEqual( 26 actual, 27 expected(function(payload) { 28 return payload.map(item => 29 Object.assign({}, item, { 30 Datacenter: dc, 31 uid: `["${dc}","${item.ID}"]`, 32 }) 33 ); 34 }) 35 ); 36 } 37 ); 38 }); 39 test('findBySlug returns the correct data for item endpoint', function(assert) { 40 return repo( 41 'Node', 42 'findBySlug', 43 this.subject(), 44 function(stub) { 45 return stub(`/v1/internal/ui/node/${id}?dc=${dc}`); 46 }, 47 function(service) { 48 return service.findBySlug(id, dc); 49 }, 50 function(actual, expected) { 51 assert.deepEqual( 52 actual, 53 expected(function(payload) { 54 const item = payload; 55 return Object.assign({}, item, { 56 Datacenter: dc, 57 uid: `["${dc}","${item.ID}"]`, 58 }); 59 }) 60 ); 61 } 62 ); 63 });