diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-01-18 21:48:37 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-01-27 10:39:37 +0100 |
| commit | 1774a2a3d9480feff58f25dd44dbc05eb3fd0088 (patch) | |
| tree | 152ddd372761c7d4e62fef479064629a46443dd1 /gui/test/setup | |
| parent | 90ae963575524bda543a32aedcfd644dd7e2b495 (diff) | |
| download | mullvadvpn-1774a2a3d9480feff58f25dd44dbc05eb3fd0088.tar.xz mullvadvpn-1774a2a3d9480feff58f25dd44dbc05eb3fd0088.zip | |
Add tests for changelog parsing
Diffstat (limited to 'gui/test/setup')
| -rw-r--r-- | gui/test/setup/changelog.spec.ts | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gui/test/setup/changelog.spec.ts b/gui/test/setup/changelog.spec.ts new file mode 100644 index 0000000000..249c26e1db --- /dev/null +++ b/gui/test/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; + }); +}); |
