-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathverify.test.js
More file actions
121 lines (87 loc) · 3.67 KB
/
verify.test.js
File metadata and controls
121 lines (87 loc) · 3.67 KB
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
const test = require('ava');
const verify = require('../lib/verify.js');
test('Throw SemanticReleaseError if "assets" option is not a String or false or an Array of Objects', (t) => {
const assets = true;
const [error] = t.throws(() => verify({assets}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDASSETS');
});
test('Throw SemanticReleaseError if "assets" option is not an Array with invalid elements', (t) => {
const assets = ['file.js', 42];
const [error] = t.throws(() => verify({assets}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDASSETS');
});
test('Verify "assets" is a String', (t) => {
const assets = 'file2.js';
t.notThrows(() => verify({assets}));
});
test('Verify "assets" is an Array of String', (t) => {
const assets = ['file1.js', 'file2.js'];
t.notThrows(() => verify({assets}));
});
test('Verify "assets" is an Object with a path property', (t) => {
const assets = {path: 'file2.js'};
t.notThrows(() => verify({assets}));
});
test('Verify "assets" is an Array of Object with a path property', (t) => {
const assets = [{path: 'file1.js'}, {path: 'file2.js'}];
t.notThrows(() => verify({assets}));
});
test('Verify disabled "assets" (set to false)', (t) => {
const assets = false;
t.notThrows(() => verify({assets}));
});
test('Verify "assets" is an Array of glob Arrays', (t) => {
const assets = [['dist/**', '!**/*.js'], 'file2.js'];
t.notThrows(() => verify({assets}));
});
test('Verify "assets" is an Array of Object with a glob Arrays in path property', (t) => {
const assets = [{path: ['dist/**', '!**/*.js']}, {path: 'file2.js'}];
t.notThrows(() => verify({assets}));
});
test('Throw SemanticReleaseError if "message" option is not a String', (t) => {
const message = 42;
const [error] = t.throws(() => verify({message}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDMESSAGE');
});
test('Throw SemanticReleaseError if "message" option is an empty String', (t) => {
const message = '';
const [error] = t.throws(() => verify({message}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDMESSAGE');
});
test('Throw SemanticReleaseError if "message" option is a whitespace String', (t) => {
const message = ' \n \r ';
const [error] = t.throws(() => verify({message}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDMESSAGE');
});
test('Verify "respectIgnoreFile" is a Boolean', (t) => {
t.notThrows(() => verify({respectIgnoreFile: true}));
t.notThrows(() => verify({respectIgnoreFile: false}));
});
test('Throw SemanticReleaseError if "respectIgnoreFile" option is a string', (t) => {
const [error] = t.throws(() => verify({respectIgnoreFile: 'foo'}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDRESPECTIGNOREFILE');
});
test('Throw SemanticReleaseError if "respectIgnoreFile" option is a number', (t) => {
const [error] = t.throws(() => verify({respectIgnoreFile: 10}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDRESPECTIGNOREFILE');
});
test('Throw SemanticReleaseError if "respectIgnoreFile" option is an array', (t) => {
const [error] = t.throws(() => verify({respectIgnoreFile: []}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDRESPECTIGNOREFILE');
});
test('Throw SemanticReleaseError if "respectIgnoreFile" option is an object', (t) => {
const [error] = t.throws(() => verify({respectIgnoreFile: {}}));
t.is(error.name, 'SemanticReleaseError');
t.is(error.code, 'EINVALIDRESPECTIGNOREFILE');
});
test('Verify undefined "message", "assets", and "respectIgnoreFile"', (t) => {
t.notThrows(() => verify({}));
});