diff options
| author | Hank <hank@mullvad.net> | 2022-09-15 11:59:02 +0200 |
|---|---|---|
| committer | Hank <hank@mullvad.net> | 2022-09-20 11:34:21 +0200 |
| commit | 626df04f9ef795b531ac19e18f4464cd1eaf9bd6 (patch) | |
| tree | dc8056927ad70e3e97645a88e2bfddae24d9314a /gui/test/unit/setup | |
| parent | ed45531a88295061bf79a7a57385ad36f8901997 (diff) | |
| download | mullvadvpn-626df04f9ef795b531ac19e18f4464cd1eaf9bd6.tar.xz mullvadvpn-626df04f9ef795b531ac19e18f4464cd1eaf9bd6.zip | |
Re-arrange folder structure for tests, put unit and e2e under root test folder
Diffstat (limited to 'gui/test/unit/setup')
| -rw-r--r-- | gui/test/unit/setup/changelog.spec.ts | 65 | ||||
| -rw-r--r-- | gui/test/unit/setup/renderer.ts | 6 |
2 files changed, 71 insertions, 0 deletions
diff --git a/gui/test/unit/setup/changelog.spec.ts b/gui/test/unit/setup/changelog.spec.ts new file mode 100644 index 0000000000..912a8a3397 --- /dev/null +++ b/gui/test/unit/setup/changelog.spec.ts @@ -0,0 +1,65 @@ +import { expect } from 'chai'; +import { after, it, describe } from 'mocha'; +import { parseChangelog } from '../../../src/main/changelog'; + +// It should be handled the same no matter if the platforms are split with a space or not. +const changelogItems = [ + 'Changelog item 1', + '[Windows] Changelog item 2', + '[macOS] Changelog item 3', + '[linux] Changelog item 4', + '[Windows, macOS] Changelog item 5', + '[Windows,linux] Changelog item 6', + '[Windows, macOS,linux] Changelog item 7', +]; + +const changelogString = changelogItems.join('\n'); + +const mockPlatform = (platform: string) => { + Object.defineProperty(process, 'platform', { value: platform }); +}; + +describe('Changelog parser', () => { + const platform = process.platform; + + after(() => { + mockPlatform(platform); + }); + + it('should show Windows items', () => { + mockPlatform('win32'); + + const changelog = parseChangelog(changelogString); + + expect(changelog).to.have.length(5); + expect(changelogItems[0].endsWith(changelog[0])).to.be.true; + expect(changelogItems[1].endsWith(changelog[1])).to.be.true; + expect(changelogItems[4].endsWith(changelog[2])).to.be.true; + expect(changelogItems[5].endsWith(changelog[3])).to.be.true; + expect(changelogItems[6].endsWith(changelog[4])).to.be.true; + }); + + it('should show macOS items', () => { + mockPlatform('darwin'); + + const changelog = parseChangelog(changelogString); + + expect(changelog).to.have.length(4); + expect(changelogItems[0].endsWith(changelog[0])).to.be.true; + expect(changelogItems[2].endsWith(changelog[1])).to.be.true; + expect(changelogItems[4].endsWith(changelog[2])).to.be.true; + expect(changelogItems[6].endsWith(changelog[3])).to.be.true; + }); + + it('should show Linux items', () => { + mockPlatform('linux'); + + const changelog = parseChangelog(changelogString); + + expect(changelog).to.have.length(4); + expect(changelogItems[0].endsWith(changelog[0])).to.be.true; + expect(changelogItems[3].endsWith(changelog[1])).to.be.true; + expect(changelogItems[5].endsWith(changelog[2])).to.be.true; + expect(changelogItems[6].endsWith(changelog[3])).to.be.true; + }); +}); diff --git a/gui/test/unit/setup/renderer.ts b/gui/test/unit/setup/renderer.ts new file mode 100644 index 0000000000..65644e28d9 --- /dev/null +++ b/gui/test/unit/setup/renderer.ts @@ -0,0 +1,6 @@ +import chai from 'chai'; +import spies from 'chai-spies'; +import chaiAsPromised from 'chai-as-promised'; + +chai.use(spies); +chai.use(chaiAsPromised); |
