-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy pathutils.test.js
59 lines (50 loc) · 2.06 KB
/
utils.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
'use strict';
const setDefaults = require('./utils');
const GoogleProvider = require('../provider/googleProvider');
const Serverless = require('../test/serverless');
const GoogleCommand = require('../test/googleCommand');
describe('Utils', () => {
let serverless;
let googleCommand;
beforeEach(() => {
serverless = new Serverless();
serverless.setProvider('google', new GoogleProvider(serverless));
googleCommand = new GoogleCommand(serverless, {}, setDefaults);
// mocking the standard value passed in from Serverless here
googleCommand.serverless.service.provider = {
region: 'us-east-1',
};
});
describe('#setDefaults()', () => {
it('should set default values for options if not provided', () =>
googleCommand.setDefaults().then(() => {
expect(googleCommand.options.stage).toEqual('dev');
expect(googleCommand.options.region).toEqual('us-central1');
expect(googleCommand.options.runtime).toEqual('nodejs10');
}));
it('should set the options when they are provided', () => {
googleCommand.options.stage = 'my-stage';
googleCommand.options.region = 'my-region';
googleCommand.options.runtime = 'nodejs6';
return googleCommand.setDefaults().then(() => {
expect(googleCommand.options.stage).toEqual('my-stage');
expect(googleCommand.options.region).toEqual('my-region');
expect(googleCommand.options.runtime).toEqual('nodejs6');
});
});
it('should set the provider values for stage and region if provided', () => {
googleCommand.serverless.service.provider = {
region: 'my-region',
stage: 'my-stage',
};
return googleCommand.setDefaults().then(() => {
expect(googleCommand.options.region).toEqual('my-region');
expect(googleCommand.options.stage).toEqual('my-stage');
});
});
it('shoud default to the us-central1 region when no region is provided', () =>
googleCommand.setDefaults().then(() => {
expect(googleCommand.options.region).toEqual('us-central1');
}));
});
});