github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/integration/services/repository/token-test.js (about) 1 import { moduleFor, test, skip } from 'ember-qunit'; 2 import repo from 'consul-ui/tests/helpers/repo'; 3 const NAME = 'token'; 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-id'; 10 test('findByDatacenter returns the correct data for list endpoint', function(assert) { 11 return repo( 12 'Token', 13 'findAllByDatacenter', 14 this.subject(), 15 function retrieveStub(stub) { 16 return stub(`/v1/acl/tokens?dc=${dc}`, { 17 CONSUL_TOKEN_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 CreateTime: new Date(item.CreateTime), 31 uid: `["${dc}","${item.AccessorID}"]`, 32 }) 33 ); 34 }) 35 ); 36 } 37 ); 38 }); 39 test('findBySlug returns the correct data for item endpoint', function(assert) { 40 return repo( 41 'Token', 42 'findBySlug', 43 this.subject(), 44 function retrieveStub(stub) { 45 return stub(`/v1/acl/token/${id}?dc=${dc}`); 46 }, 47 function performTest(service) { 48 return service.findBySlug(id, dc); 49 }, 50 function performAssertion(actual, expected) { 51 assert.deepEqual( 52 actual, 53 expected(function(payload) { 54 const item = payload; 55 return Object.assign({}, item, { 56 Datacenter: dc, 57 CreateTime: new Date(item.CreateTime), 58 uid: `["${dc}","${item.AccessorID}"]`, 59 }); 60 }) 61 ); 62 } 63 ); 64 }); 65 skip('clone returns the correct data for the clone endpoint');