|
| 1 | +const APP_ROOT = '..'; |
| 2 | +const given = require(`${APP_ROOT}/test/steps/given`); |
| 3 | +const expect = require('chai').expect; |
| 4 | +const { restApiExists } = require(`${APP_ROOT}/src/restApiId`); |
| 5 | + |
| 6 | +describe('Finding the Rest API', () => { |
| 7 | + let result; |
| 8 | + describe('when the Rest API Id has already been defined in serverless configuration', () => { |
| 9 | + before(() => { |
| 10 | + let serverless = given.a_serverless_instance() |
| 11 | + .withPredefinedRestApiId(given.a_rest_api_id()); |
| 12 | + result = restApiExists(serverless); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should return that the Rest API exists', () => { |
| 16 | + expect(result).to.be.true; |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + describe('when the Rest API has not been defined in serverless configuration', () => { |
| 21 | + describe('and there are HTTP handler functions', () => { |
| 22 | + before(() => { |
| 23 | + let functionWithHttpEndpoint = given.a_serverless_function('get-cat-by-paw-id') |
| 24 | + .withHttpEndpoint('get', '/cat/{pawId}'); |
| 25 | + serverless = given.a_serverless_instance() |
| 26 | + .withFunction(functionWithHttpEndpoint); |
| 27 | + |
| 28 | + result = restApiExists(serverless); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should return that the Rest API does exist', () => { |
| 32 | + expect(result).to.be.true; |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + describe('and there are no HTTP handler functions', () => { |
| 37 | + before(() => { |
| 38 | + serverless = given.a_serverless_instance(); |
| 39 | + |
| 40 | + result = restApiExists(serverless); |
| 41 | + }); |
| 42 | + |
| 43 | + it('should return that the Rest API does not exist', () => { |
| 44 | + expect(result).to.be.false; |
| 45 | + }); |
| 46 | + }); |
| 47 | + }); |
| 48 | +}); |
0 commit comments