forked from ariatemplates/git-release-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
48 lines (42 loc) · 1.61 KB
/
index.test.js
File metadata and controls
48 lines (42 loc) · 1.61 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
const path = require('path');
const index = require('./index');
describe('index module', () => {
it('rejects if the template cannot be found', () => {
const OPTIONS = {};
const RANGE = 'since..to';
return expect(index(OPTIONS, RANGE, 'missing-template')).rejects.toThrow(/template file/);
});
it('rejects if the configuation in invalid', () => {
const OPTIONS = { f: 'missing-configuration' };
const RANGE = 'since..to';
return expect(index(OPTIONS, RANGE, 'markdown')).rejects.toThrow(/configuration file/);
});
it('rejects if git log range is invalid', () => {
const OPTIONS = {};
const RANGE = 'since..to';
return expect(index(OPTIONS, RANGE, 'markdown')).rejects.toThrow(/git log exited/i);
});
it('rejects if the external script fails', () => {
const OPTIONS = {
script: 'lib/__tests__/scripts/throws.js',
branch: 'testing-branch',
};
const RANGE = '7d27899..28b863e';
return expect(index(OPTIONS, RANGE, 'markdown')).rejects.toThrow(/processing external script/i);
});
it('rejects if the rendering template causes errors', () => {
const OPTIONS = {
script: 'lib/__tests__/scripts/rename.js',
branch: 'testing-branch',
};
const RANGE = '7d27899..28b863e';
return expect(index(OPTIONS, RANGE, 'lib/__tests__/templates/invalid.ejs')).rejects.toThrow(/broken is not defined/i);
});
it('resolves with the rendered template', () => {
const OPTIONS = {
branch: 'testing-branch',
};
const RANGE = '7d27899..28b863e';
return expect(index(OPTIONS, RANGE, 'markdown')).resolves.toMatch(/__2.1.0__/i);
});
});