forked from serverless-operations/serverless-step-functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaming.test.js
147 lines (127 loc) · 5.53 KB
/
naming.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'use strict';
const expect = require('chai').expect;
const Serverless = require('serverless/lib/Serverless');
const AwsProvider = require('serverless/lib/plugins/aws/provider');
const ServerlessStepFunctions = require('./index');
describe('#naming', () => {
let serverless;
let serverlessStepFunctions;
beforeEach(() => {
serverless = new Serverless();
serverless.servicePath = true;
serverless.service.service = 'step-functions';
serverless.service.provider.compiledCloudFormationTemplate = { Resources: {} };
serverless.configSchemaHandler = {
// eslint-disable-next-line no-unused-vars
defineTopLevelProperty: (propertyName, propertySchema) => {},
};
serverless.setProvider('aws', new AwsProvider(serverless));
serverlessStepFunctions = new ServerlessStepFunctions(serverless);
});
describe('#getStateMachineLogicalId()', () => {
it('should normalize the stateMachine name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineLogicalId('stateMachine')).to
.equal('StateMachineStepFunctionsStateMachine');
});
});
describe('#getStateMachineOutputLogicalId()', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine')).to
.equal('StateMachineStepFunctionsStateMachineArn');
});
});
describe('#getStateMachineLogicalId() -- Named', () => {
it('should normalize the stateMachine name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineLogicalId('stateMachine',
{ name: 'alphaNumeric' }))
.to.equal('AlphaNumeric');
});
});
describe('#getStateMachineOutputLogicalId() -- Named', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine',
{ name: 'alphaNumeric' }))
.to.equal('AlphaNumericArn');
});
});
describe('#getStateMachineLogicalId() -- With Id', () => {
it('should normalize the stateMachine name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineLogicalId('stateMachine',
{ id: 'foo', name: 'alphaNumeric' }))
.to.equal('Foo');
});
});
describe('#getStateMachineOutputLogicalId() -- With Id', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine',
{ id: 'foo', name: 'alphaNumeric' }))
.to.equal('FooArn');
});
});
describe('#getStateMachineLogicalId() -- With Only Id', () => {
it('should normalize the stateMachine name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineLogicalId('stateMachine', { id: 'foo' })).to
.equal('Foo');
});
});
describe('#getStateMachineOutputLogicalId() -- With Only Id', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getStateMachineOutputLogicalId('stateMachine', { id: 'foo' }))
.to.equal('FooArn');
});
});
describe('#getActivityLogicalId()', () => {
it('should normalize the activity name and add the standard suffix', () => {
expect(serverlessStepFunctions.getActivityLogicalId('activity')).to
.equal('ActivityStepFunctionsActivity');
});
});
describe('#getActivityOutputLogicalId()', () => {
it('should normalize the activity output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getActivityOutputLogicalId('activity')).to
.equal('ActivityStepFunctionsActivityArn');
});
});
describe('#getStateMachinePolicyName()', () => {
it('should use the stage and service name', () => {
expect(serverlessStepFunctions.getStateMachinePolicyName()).to
.equal('dev-step-functions-statemachine');
});
});
describe('#getRestApiLogicalId()', () => {
it('should return restApiLogicalId', () => {
expect(serverlessStepFunctions.getRestApiLogicalId()).to
.equal('ApiGatewayRestApiStepFunctions');
});
});
describe('#getApiGatewayName()', () => {
it('should return apiGatewayName', () => {
expect(serverlessStepFunctions.getApiGatewayName()).to
.equal('dev-step-functions-stepfunctions');
});
});
describe('#getScheduleId()', () => {
it('should normalize the stateMachine output name', () => {
expect(serverlessStepFunctions.getScheduleId('stateMachine')).to
.equal('stateMachineStepFunctionsSchedule');
});
});
describe('#getScheduleLogicalId()', () => {
it('should normalize the stateMachine output name and add the standard suffix', () => {
expect(serverlessStepFunctions.getScheduleLogicalId('stateMachine', 1)).to
.equal('StateMachineStepFunctionsEventsRuleSchedule1');
});
});
describe('#getScheduleToStepFunctionsIamRoleLogicalId()', () => {
it('should normalize the stateMachine output name', () => {
expect(serverlessStepFunctions.getScheduleToStepFunctionsIamRoleLogicalId('stateMachine')).to
.equal('StateMachineScheduleToStepFunctionsRole');
});
});
describe('#getSchedulePolicyName()', () => {
it('should use the stage and service name', () => {
expect(serverlessStepFunctions.getSchedulePolicyName('stateMachine')).to
.equal('dev-us-east-1-step-functions-stateMachine-schedule');
});
});
});