Advertisement
Dolly2315

Test at Consumer side

Nov 27th, 2018
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. describe('Taxonomy Service pact with Search App', () => {
  2. const provider = pact({
  3. consumer: 'flex-search-app',
  4. provider: SERVICE_NAME,
  5. port: 18149,
  6. log: path.join(process.cwd(), '../', 'pact', 'logs', `${SERVICE_NAME}.log`),
  7. dir: path.join(process.cwd(), '../', 'pact', SERVICE_NAME),
  8. logLevel: 'INFO',
  9. spec: 2
  10. });
  11.  
  12. before(() => {
  13. return provider.setup();
  14. });
  15.  
  16. describe('Listing taxonomies', () => {
  17. before(() => {
  18. return provider.addInteraction({
  19. given: 'GET call for taxonomies',
  20. uponReceiving: 'Get object for listing taxonomies',
  21. withRequest: {
  22. method: 'GET',
  23. path: '/api/taxonomies',
  24. query: {
  25. accountId: term({
  26. generate: '4',
  27. matcher: '4'
  28. }),
  29. enabled: term({
  30. generate: 'true',
  31. matcher: 'true'
  32. })
  33. }
  34. },
  35. willRespondWith: {
  36. status: 200,
  37. body: [
  38. like ({
  39. 'id': like(8061159),
  40. 'name': like('Country'),
  41. 'displayName': like('Country'),
  42. 'description': like(''),
  43. 'enabled': like(true),
  44. 'accountId': like(4),
  45. 'visibilityIds': like([
  46. 4,
  47. 10329,
  48. 10323,
  49. 10240,
  50. 17575
  51. ]),
  52. 'userId': like(5),
  53. 'created': like('31 Jan 2018 11:56:48 +00:00'),
  54. 'lastModified': like('01 Feb 2018 11:58:49 +00:00')
  55. })
  56. ]
  57. }
  58. });
  59. });
  60.  
  61. it('should generate a list of taxonomies', () => {
  62. return request.get(`http://localhost:${PORT}/api/taxonomies?accountId=4&enabled=true`)
  63. .set({ 'Accept': 'application/json' }).then((response) => {
  64. return expect(Promise.resolve(response.status)).to.eventually.equals(200);
  65.  
  66. }).catch(err => {
  67. console.log("Error in taxonomy listing", err);
  68.  
  69. });
  70. });
  71. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement