-
Notifications
You must be signed in to change notification settings - Fork 33
/
banners.spec.js
92 lines (77 loc) · 3.3 KB
/
banners.spec.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
const banners = require('../banners.js');
const pad33 = require('../pad-33.js');
const constants = require('../../constants.js');
const bar = '=======================================\n';
const block = ']|[';
const emptyRow = `${block} ${block}\n`;
const makeExpected = (banner) => `${bar + emptyRow + block + banner + block}\n${emptyRow}${bar}`;
const _console = console;
beforeEach(() => {
console.log = jest.fn();
});
afterAll(() => {
console = _console; // eslint-disable-line no-global-assign
});
test('it contains the correct number of banners', () => {
expect(Object.keys(banners).length).toBe(constants.banners.length);
});
test('it prints the welcome banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[0]));
banners.welcome();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the addCustom banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[1]));
banners.addCustom();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the addFromPackage banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[2]));
banners.addFromPackage();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the addGlobalPackage banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[3]));
banners.addGlobalPackage();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the createPkgFromLabels banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[4]));
banners.createPkgFromLabels();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the removeLabels banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[5]));
banners.removeLabels();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the resetToken banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[6]));
banners.resetToken();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the seeYa banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[7]));
banners.seeYa();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the wrongPassword banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[8]));
banners.wrongPassword();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});
test('it prints the removeAllLabels banner to the console', () => {
const expected = makeExpected(pad33(constants.banners[9]));
banners.removeAllLabels();
expect(console.log.mock.calls.length).toBe(1);
expect(console.log.mock.calls[0][0]).toBe(expected);
});