|
8 | 8 | getPasscode, |
9 | 9 | getRandomInt, |
10 | 10 | verifyAppDirectory, |
| 11 | + getMiddleware, |
11 | 12 | } = require('../../src/helpers'); |
12 | 13 | const { getListOfFunctionsAndAssets } = require('@twilio-labs/serverless-api/dist/utils/fs'); |
13 | 14 | const path = require('path'); |
@@ -43,7 +44,7 @@ function getMockTwilioInstance(options) { |
43 | 44 | }; |
44 | 45 |
|
45 | 46 | const mockAppInstance = { |
46 | | - assets: { list: () => Promise.resolve(options.hasAssets ? [{}] : []) }, |
| 47 | + assets: { list: () => Promise.resolve(options.hasWebAssets ? [{ friendlyName: 'index.html' }] : []) }, |
47 | 48 | functions: {}, |
48 | 49 | update: jest.fn(() => Promise.resolve()), |
49 | 50 | }; |
@@ -134,9 +135,11 @@ describe('the getAssets function', () => { |
134 | 135 | ]) |
135 | 136 | ); |
136 | 137 | }); |
| 138 | +}); |
137 | 139 |
|
| 140 | +describe('the getMiddleware function', () => { |
138 | 141 | it('should add the auth-handler.js as a private asset', async () => { |
139 | | - expect(await getAssets('mockFolder')).toEqual( |
| 142 | + expect(await getMiddleware('mockFolder')).toEqual( |
140 | 143 | expect.arrayContaining([ |
141 | 144 | { |
142 | 145 | name: 'auth-handler', |
@@ -200,23 +203,23 @@ describe('the getAppInfo function', () => { |
200 | 203 | expiry: 'Wed May 20 2020 18:40:00 GMT+0000', |
201 | 204 | environmentSid: 'environmentSid', |
202 | 205 | functionSid: 'tokenFunctionSid', |
203 | | - hasAssets: false, |
| 206 | + hasWebAssets: false, |
204 | 207 | passcode: '12345612345678', |
205 | 208 | sid: 'appSid', |
206 | 209 | url: `https://${APP_NAME}-1234-5678-dev.twil.io?passcode=12345612345678`, |
207 | 210 | roomType: 'group', |
208 | 211 | }); |
209 | 212 | }); |
210 | 213 |
|
211 | | - it('should return the correct information when there are assets', async () => { |
| 214 | + it('should return the correct information when there are web assets', async () => { |
212 | 215 | const result = await getAppInfo.call({ |
213 | | - twilioClient: getMockTwilioInstance({ exists: true, hasAssets: true }), |
| 216 | + twilioClient: getMockTwilioInstance({ exists: true, hasWebAssets: true }), |
214 | 217 | }); |
215 | 218 | expect(result).toEqual({ |
216 | 219 | expiry: 'Wed May 20 2020 18:40:00 GMT+0000', |
217 | 220 | environmentSid: 'environmentSid', |
218 | 221 | functionSid: 'tokenFunctionSid', |
219 | | - hasAssets: true, |
| 222 | + hasWebAssets: true, |
220 | 223 | passcode: '12345612345678', |
221 | 224 | sid: 'appSid', |
222 | 225 | url: `https://${APP_NAME}-1234-5678-dev.twil.io?passcode=12345612345678`, |
@@ -251,7 +254,7 @@ describe('the displayAppInfo function', () => { |
251 | 254 |
|
252 | 255 | it('should display the correct information when there are assets', async () => { |
253 | 256 | await displayAppInfo.call({ |
254 | | - twilioClient: getMockTwilioInstance({ exists: true, hasAssets: true }), |
| 257 | + twilioClient: getMockTwilioInstance({ exists: true, hasWebAssets: true }), |
255 | 258 | }); |
256 | 259 | expect(stdout.output).toMatchInlineSnapshot(` |
257 | 260 | "Web App URL: https://${APP_NAME}-1234-5678-dev.twil.io?passcode=12345612345678 |
|
0 commit comments