From 654c50792ace1ee675fe5d6843faaafe1179bc25 Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Fri, 10 Dec 2021 15:41:23 +0100 Subject: [PATCH] test(AWS Websocket): Prepare tests refactor plan --- .../compile/events/websockets/index.test.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/test/unit/lib/plugins/aws/package/compile/events/websockets/index.test.js b/test/unit/lib/plugins/aws/package/compile/events/websockets/index.test.js index 37854a19d65..c4de3c06708 100644 --- a/test/unit/lib/plugins/aws/package/compile/events/websockets/index.test.js +++ b/test/unit/lib/plugins/aws/package/compile/events/websockets/index.test.js @@ -5,6 +5,7 @@ const sinon = require('sinon'); const AwsProvider = require('../../../../../../../../../lib/plugins/aws/provider'); const AwsCompileWebsocketsEvents = require('../../../../../../../../../lib/plugins/aws/package/compile/events/websockets/index'); const Serverless = require('../../../../../../../../../lib/Serverless'); +const runServerless = require('../../../../../../../../utils/run-serverless'); describe('AwsCompileWebsocketsEvents', () => { let awsCompileWebsocketsEvents; @@ -111,3 +112,75 @@ describe('AwsCompileWebsocketsEvents', () => { }); }); }); + +describe('test/unit/lib/plugins/aws/package/compile/events/websockets/index.test.js', () => { + describe.skip('TODO: regular configuration', () => { + before(async () => { + await runServerless({ + fixture: 'function', + command: 'package', + + configExt: { + functions: { + basic: { + events: [ + { + websocket: '$connect', + }, + ], + }, + }, + }, + }); + }); + + it('should create a websocket api resource', () => { + // Replaces + // https://github.com/serverless/serverless/blob/f64f7c68abb1d6837ecaa6173f4b605cf3975acf/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js#L37-L52 + }); + + it('should configure expected IAM', () => { + // Replaces + // https://github.com/serverless/serverless/blob/f64f7c68abb1d6837ecaa6173f4b605cf3975acf/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js#L66-L91 + }); + }); + + describe.skip('TODO: external websocket API', () => { + before(async () => { + await runServerless({ + fixture: 'function', + command: 'package', + + configExt: { + provider: { + apiGateway: { + websocketApiId: '5ezys3sght', + }, + iam: { + role: 'arn:aws:iam::123456789012:role/fromProvider', + }, + }, + functions: { + basic: { + events: [ + { + websocket: '$connect', + }, + ], + }, + }, + }, + }); + }); + + it('should not create a websocket api resource', () => { + // Replaces + // https://github.com/serverless/serverless/blob/f64f7c68abb1d6837ecaa6173f4b605cf3975acf/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js#L54-L64 + }); + + it('should not configure IAM policies with custom roles', () => { + // Replaces + // https://github.com/serverless/serverless/blob/f64f7c68abb1d6837ecaa6173f4b605cf3975acf/test/unit/lib/plugins/aws/package/compile/events/websockets/lib/api.test.js#L93-L103 + }); + }); +});