github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/integration/services/repository/policy-test.js (about) 1 import { moduleFor, test, skip } from 'ember-qunit'; 2 const NAME = 'policy'; 3 import repo from 'consul-ui/tests/helpers/repo'; 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 = 'policy-name'; 10 test('findByDatacenter returns the correct data for list endpoint', function(assert) { 11 return repo( 12 'Policy', 13 'findAllByDatacenter', 14 this.subject(), 15 function retrieveStub(stub) { 16 return stub(`/v1/acl/policies?dc=${dc}`, { 17 CONSUL_POLICY_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 'Policy', 41 'findBySlug', 42 this.subject(), 43 function retrieveStub(stub) { 44 return stub(`/v1/acl/policy/${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; 54 return Object.assign({}, item, { 55 Datacenter: dc, 56 uid: `["${dc}","${item.ID}"]`, 57 }); 58 }) 59 ); 60 } 61 ); 62 }); 63 skip('translate returns the correct data for the translate enpoint');