|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const expect = require('chai').expect; |
| 4 | +const Serverless = require('serverless/lib/Serverless'); |
| 5 | +const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider'); |
| 6 | +const ServerlessStepFunctions = require('./index'); |
| 7 | + |
| 8 | +describe('ServerlessStepFunctions', () => { |
| 9 | + let serverless; |
| 10 | + let serverlessStepFunctions; |
| 11 | + |
| 12 | + beforeEach(() => { |
| 13 | + serverless = new Serverless(); |
| 14 | + serverless.servicePath = true; |
| 15 | + |
| 16 | + serverless.service.functions = { |
| 17 | + first: { |
| 18 | + handler: true, |
| 19 | + }, |
| 20 | + }; |
| 21 | + const options = { |
| 22 | + stage: 'dev', |
| 23 | + region: 'us-east-1', |
| 24 | + function: 'first', |
| 25 | + functionObj: { |
| 26 | + name: 'first', |
| 27 | + }, |
| 28 | + }; |
| 29 | + serverless.init(); |
| 30 | + serverless.setProvider('aws', new AwsProvider(serverless)); |
| 31 | + serverlessStepFunctions = new ServerlessStepFunctions(serverless, options); |
| 32 | + }); |
| 33 | + |
| 34 | + describe('#constructor()', () => { |
| 35 | + it('should have hooks', () => expect(serverlessStepFunctions.hooks).to.be.not.empty); |
| 36 | + |
| 37 | + it('should set the provider variable to an instance of AwsProvider', () => |
| 38 | + expect(serverlessStepFunctions.provider).to.be.instanceof(AwsProvider)); |
| 39 | + |
| 40 | + it('should set the iamRoleName variable', () => |
| 41 | + expect(serverlessStepFunctions.iamRoleName).to.be |
| 42 | + .equal('serverless-step-functions-executerole-us-east-1')); |
| 43 | + |
| 44 | + it('should set the iamPolicyName variable', () => |
| 45 | + expect(serverlessStepFunctions.iamPolicyName).to.be |
| 46 | + .equal('serverless-step-functions-executepolicy-us-east-1')); |
| 47 | + |
| 48 | + it('should set an empty options object if no options are given', () => { |
| 49 | + const serverlessStepFunctionsWithEmptyOptions = new ServerlessStepFunctions(serverless); |
| 50 | + |
| 51 | + expect(serverlessStepFunctionsWithEmptyOptions.options).to.deep.equal({}); |
| 52 | + }); |
| 53 | + }); |
| 54 | +}); |
0 commit comments