From 232c0839e1357627d95ebbe7a929cbff9157e3d5 Mon Sep 17 00:00:00 2001 From: Tanner Barlow Date: Thu, 30 May 2019 10:08:05 -0700 Subject: [PATCH 1/3] Stub --- src/index.test.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/index.test.ts diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 00000000..b3fb11f2 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,5 @@ +import { AzureIndex } from "./index"; + +describe("Azure Index", () => { + +}); \ No newline at end of file From deef999eeb17b0fa3b77904baff717882f2feea4 Mon Sep 17 00:00:00 2001 From: Tanner Barlow Date: Fri, 31 May 2019 09:48:03 -0700 Subject: [PATCH 2/3] Add test for azure index --- src/index.test.ts | 27 ++++++++++++++++++++++++++- src/index.ts | 2 +- src/test/mockFactory.ts | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/index.test.ts b/src/index.test.ts index b3fb11f2..9d08eafe 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,5 +1,30 @@ -import { AzureIndex } from "./index"; +import AzureIndex from "./index"; +import { MockFactory } from "./test/mockFactory" +import { AzureInvoke } from "./plugins/invoke/azureInvoke"; +import { AzureLogs } from "./plugins/logs/azureLogs"; +import { AzureRemove } from "./plugins/remove/azureRemove"; +import { AzurePackage } from "./plugins/package/azurePackage"; +import { AzureDeployPlugin } from "./plugins/deploy/azureDeployPlugin"; +import { AzureLoginPlugin } from "./plugins/login/loginPlugin"; +import { AzureApimServicePlugin } from "./plugins/apim/apimServicePlugin"; +import { AzureApimFunctionPlugin } from "./plugins/apim/apimFunctionPlugin"; +import AzureProvider from "./provider/azureProvider"; describe("Azure Index", () => { + it("contains all registered plugins", () => { + const sls = MockFactory.createTestServerless(); + const options = MockFactory.createTestServerlessOptions(); + const index = new AzureIndex(sls, options); + expect(sls.setProvider).toBeCalledWith("azure", new AzureProvider(sls)); + + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzurePackage); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureInvoke); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureLogs); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureRemove); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureLoginPlugin); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureDeployPlugin); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureApimServicePlugin); + expect(sls.pluginManager.addPlugin).toBeCalledWith(AzureApimFunctionPlugin); + }); }); \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1dcbbbc5..6ae345fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ import { AzureLoginPlugin } from "./plugins/login/loginPlugin"; import { AzureApimServicePlugin } from "./plugins/apim/apimServicePlugin"; import { AzureApimFunctionPlugin } from "./plugins/apim/apimFunctionPlugin"; -export class AzureIndex { +export default class AzureIndex { public constructor(private serverless: Serverless, private options) { this.serverless.setProvider(AzureProvider.getProviderName(), new AzureProvider(serverless) as any); diff --git a/src/test/mockFactory.ts b/src/test/mockFactory.ts index c415baf1..59149a60 100644 --- a/src/test/mockFactory.ts +++ b/src/test/mockFactory.ts @@ -12,6 +12,7 @@ export class MockFactory { sls.cli = MockFactory.createTestCli(); sls.pluginManager = MockFactory.createTestPluginManager(); sls.variables = {}; + sls.setProvider = jest.fn(); return sls; } From 578fa62ce3adcb43dd1c3ea9b1c2004f6a893f16 Mon Sep 17 00:00:00 2001 From: Tanner Barlow Date: Mon, 3 Jun 2019 09:39:45 -0700 Subject: [PATCH 3/3] Add jest function for setting provider --- package-lock.json | 28 +++++++++++++++++++++------- src/index.test.ts | 1 + 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 679c8e26..9795f4d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3490,11 +3490,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3507,15 +3509,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -3618,7 +3623,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -3628,6 +3634,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3640,17 +3647,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3667,6 +3677,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -3739,7 +3750,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -3749,6 +3761,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -3854,6 +3867,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/index.test.ts b/src/index.test.ts index 9d08eafe..0547521a 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -15,6 +15,7 @@ describe("Azure Index", () => { const sls = MockFactory.createTestServerless(); const options = MockFactory.createTestServerlessOptions(); const index = new AzureIndex(sls, options); + sls.setProvider = jest.fn(); expect(sls.setProvider).toBeCalledWith("azure", new AzureProvider(sls));