forked from sid88in/serverless-appsync-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-config.test.js
110 lines (102 loc) · 2.26 KB
/
get-config.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
const getConfig = require('./src/get-config');
const path = require('path');
const servicePath = path.join(__dirname, 'example');
test('authenticationType is missing', () => {
const run = () => getConfig({}, {}, servicePath);
expect(run).toThrowErrorMatchingSnapshot();
});
test('authenticationType is missing', () => {
const run = () =>
getConfig(
{
},
{},
servicePath,
);
expect(run).toThrowErrorMatchingSnapshot();
});
test('returns valid config', () => {
expect(getConfig(
{
authenticationType: 'AWS_IAM',
dataSources: {
users: {
type: 'AMAZON_DYNAMODB',
},
tweets: {
type: 'AMAZON_DYNAMODB',
},
},
},
{ region: 'us-east-1' },
servicePath,
)).toMatchSnapshot();
});
test('datasources as array', () => {
expect(getConfig(
{
authenticationType: 'AWS_IAM',
dataSources: [
{
name: 'users',
type: 'AMAZON_DYNAMODB',
},
{
name: 'tweets',
type: 'AMAZON_DYNAMODB',
},
],
},
{ region: 'us-east-1' },
servicePath,
)).toMatchSnapshot();
});
test('datasources as array form different files (array of arrays or objects)', () => {
expect(getConfig(
{
authenticationType: 'AWS_IAM',
dataSources: [ // File one: key-based datasources
{
users: {
type: 'AMAZON_DYNAMODB',
},
tweets: {
type: 'AMAZON_DYNAMODB',
},
},
[ // file 2: array of datasources
{
name: 'foo',
type: 'AMAZON_DYNAMODB',
},
{
name: 'bar',
type: 'AMAZON_DYNAMODB',
},
],
],
},
{ region: 'us-east-1' },
servicePath,
)).toMatchSnapshot();
});
test('Schema as string', () => {
expect(getConfig(
{
authenticationType: 'AWS_IAM',
schema: 'schema.graphql',
},
{ region: 'us-east-1' },
servicePath,
)).toMatchSnapshot();
});
test('Schema as array', () => {
expect(getConfig(
{
authenticationType: 'AWS_IAM',
schema: ['_type_tweet.graphql', '_type_user.graphql'],
},
{ region: 'us-east-1' },
servicePath,
)).toMatchSnapshot();
});