|
5 | 5 |
|
6 | 6 | import vscode = require('vscode');
|
7 | 7 | import assert from 'assert';
|
8 |
| -import { shouldShowGoWelcomePage } from '../../src/welcome'; |
| 8 | +import { hasNewsForNewVersion } from '../../src/welcome'; |
9 | 9 | import { extensionId } from '../../src/const';
|
10 | 10 | import { WelcomePanel } from '../../src/welcome';
|
11 |
| -import sinon = require('sinon'); |
12 |
| -import * as config from '../../src/config'; |
13 |
| -import { MockCfg } from '../mocks/MockCfg'; |
14 | 11 |
|
15 | 12 | suite('WelcomePanel Tests', () => {
|
16 |
| - let sandbox: sinon.SinonSandbox; |
17 |
| - setup(() => { |
18 |
| - sandbox = sinon.createSandbox(); |
19 |
| - }); |
20 |
| - teardown(() => sandbox.restore()); |
21 |
| - |
22 |
| - // 0:showVersions, 1:newVersion, 2:oldVersion, 3: showWelcome, 4:expected |
23 |
| - // |
24 |
| - // If showWelcome is false, then expected has to be false. |
25 |
| - // Otherwise, expected is true if (and only if) newVersion occurs in showVersions |
26 |
| - // and is newer than oldVersion (as semantic versions). |
27 |
| - type testCase = [string[], string, string, boolean, boolean]; |
| 13 | + // 0:showVersions, 1:newVersion, 2:oldVersion, 3:expected |
| 14 | + type testCase = [string[], string, string, boolean]; |
28 | 15 | const testCases: testCase[] = [
|
29 |
| - [[], '0.22.0', '0.0.0', true, false], |
30 |
| - [[], '0.22.0', '0.21.0', true, false], |
31 |
| - [[], '0.22.0', '0.22.0-rc.1', true, false], |
32 |
| - [[], '0.22.0', '0.22.0', true, false], |
33 |
| - [[], '0.22.0', '0.23.0', true, false], |
| 16 | + [[], '0.22.0', '0.0.0', false], |
| 17 | + [[], '0.22.0', '0.21.0', false], |
| 18 | + [[], '0.22.0', '0.22.0-rc.1', false], |
| 19 | + [[], '0.22.0', '0.22.0', false], |
| 20 | + [[], '0.22.0', '0.23.0', false], |
34 | 21 |
|
35 |
| - [['0.22.0'], '0.22.0', '0.0.0', true, true], |
36 |
| - [['0.22.0'], '0.22.0', '0.0.0', false, false], |
37 |
| - [['0.22.0'], '0.22.0', '0.21.0-rc.1', true, true], |
38 |
| - [['0.22.0'], '0.22.0', '0.21.0', true, true], |
39 |
| - [['0.22.0'], '0.22.0', '0.22.0-rc.1', true, true], |
40 |
| - [['0.22.0'], '0.22.0', '0.22.0', true, false], |
41 |
| - [['0.22.0'], '0.22.0', '0.22.1', true, false], |
42 |
| - [['0.22.0'], '0.22.0', '0.23.0', true, false], |
43 |
| - [['0.22.0'], '0.22.0', '1.0.0', true, false], |
44 |
| - [['0.22.0'], '0.22.0', '2021.1.100', true, false], |
| 22 | + [['0.22.0'], '0.22.0', '0.0.0', true], |
| 23 | + [['0.22.0'], '0.22.0', '0.21.0-rc.1', true], |
| 24 | + [['0.22.0'], '0.22.0', '0.21.0', true], |
| 25 | + [['0.22.0'], '0.22.0', '0.22.0-rc.1', true], |
| 26 | + [['0.22.0'], '0.22.0', '0.22.0', false], |
| 27 | + [['0.22.0'], '0.22.0', '0.22.1', false], |
| 28 | + [['0.22.0'], '0.22.0', '0.23.0', false], |
| 29 | + [['0.22.0'], '0.22.0', '1.0.0', false], |
| 30 | + [['0.22.0'], '0.22.0', '2021.1.100', false], |
45 | 31 |
|
46 |
| - [['0.22.0'], '0.22.0-rc.2', '0.0.0', true, true], |
47 |
| - [['0.22.0'], '0.22.0-rc.2', '0.21.0-rc.1', true, true], |
48 |
| - [['0.22.0'], '0.22.0-rc.2', '0.21.0', true, true], |
49 |
| - [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.1', true, true], |
50 |
| - [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.2', true, false], |
51 |
| - [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.3', true, true], |
52 |
| - [['0.22.0'], '0.22.0-rc.2', '0.22.0', true, true], |
53 |
| - [['0.22.0'], '0.22.0-rc.2', '0.22.1', true, false], |
54 |
| - [['0.22.0'], '0.22.0-rc.2', '0.23.0', true, false], |
55 |
| - [['0.22.0'], '0.22.0-rc.2', '1.0.0', true, false], |
56 |
| - [['0.22.0'], '0.22.0-rc.2', '2021.1.100', true, false], |
| 32 | + [['0.22.0'], '0.22.0-rc.2', '0.0.0', true], |
| 33 | + [['0.22.0'], '0.22.0-rc.2', '0.21.0-rc.1', true], |
| 34 | + [['0.22.0'], '0.22.0-rc.2', '0.21.0', true], |
| 35 | + [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.1', true], |
| 36 | + [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.2', false], |
| 37 | + [['0.22.0'], '0.22.0-rc.2', '0.22.0-rc.3', true], |
| 38 | + [['0.22.0'], '0.22.0-rc.2', '0.22.0', true], |
| 39 | + [['0.22.0'], '0.22.0-rc.2', '0.22.1', false], |
| 40 | + [['0.22.0'], '0.22.0-rc.2', '0.23.0', false], |
| 41 | + [['0.22.0'], '0.22.0-rc.2', '1.0.0', false], |
| 42 | + [['0.22.0'], '0.22.0-rc.2', '2021.1.100', false], |
57 | 43 |
|
58 |
| - [['0.22.0'], '0.22.1', '0.0.0', true, false], |
59 |
| - [['0.22.0'], '0.22.1', '0.21.0-rc.1', true, false], |
60 |
| - [['0.22.0'], '0.22.1', '0.21.0', true, false], |
61 |
| - [['0.22.0'], '0.22.1', '0.22.0-rc.1', true, false], |
62 |
| - [['0.22.0'], '0.22.1', '0.22.0', true, false], |
63 |
| - [['0.22.0'], '0.22.1', '0.23.0', true, false], |
64 |
| - [['0.22.0'], '0.22.1', '1.0.0', true, false], |
65 |
| - [['0.22.0'], '0.22.1', '2021.1.100', true, false] |
| 44 | + [['0.22.0'], '0.22.1', '0.0.0', false], |
| 45 | + [['0.22.0'], '0.22.1', '0.21.0-rc.1', false], |
| 46 | + [['0.22.0'], '0.22.1', '0.21.0', false], |
| 47 | + [['0.22.0'], '0.22.1', '0.22.0-rc.1', false], |
| 48 | + [['0.22.0'], '0.22.1', '0.22.0', false], |
| 49 | + [['0.22.0'], '0.22.1', '0.23.0', false], |
| 50 | + [['0.22.0'], '0.22.1', '1.0.0', false], |
| 51 | + [['0.22.0'], '0.22.1', '2021.1.100', false] |
66 | 52 | ];
|
67 | 53 | testCases.forEach((c: testCase) => {
|
68 |
| - const [showVersions, newVersion, oldVersion, showWelcome, expected] = c; |
69 |
| - test(`shouldShowGoWelcomePage(${JSON.stringify( |
70 |
| - showVersions |
71 |
| - )}, ${newVersion}, ${oldVersion}, (showWelcome=${showWelcome}))`, () => { |
72 |
| - const goConfig = new MockCfg([]); |
73 |
| - sandbox.stub(config, 'getGoConfig').returns(goConfig); |
74 |
| - sinon.stub(goConfig, 'get').withArgs('showWelcome').returns(showWelcome); |
75 |
| - assert.strictEqual(shouldShowGoWelcomePage(showVersions, newVersion, oldVersion), expected); |
| 54 | + const [showVersions, newVersion, oldVersion, expected] = c; |
| 55 | + |
| 56 | + test(`shouldShowGoWelcomePage(${JSON.stringify(showVersions)}, ${newVersion}, ${oldVersion})`, () => { |
| 57 | + assert.strictEqual(hasNewsForNewVersion(showVersions, newVersion, oldVersion), expected); |
76 | 58 | });
|
77 | 59 | });
|
78 | 60 | });
|
|
0 commit comments