diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-01-27 10:44:30 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-01-27 10:44:30 +0100 |
| commit | c81d787c9588800688930c88d0a69fa3ee6a06e9 (patch) | |
| tree | 30ce7697bed480c889496632882b6cf0e9d50487 /gui/test/setup | |
| parent | bc7ebf12c08b0fa9a0d8ec2ec9db026b24a57080 (diff) | |
| parent | cb0791bce695f33590db55da8a8bc9e03f07869c (diff) | |
| download | mullvadvpn-c81d787c9588800688930c88d0a69fa3ee6a06e9.tar.xz mullvadvpn-c81d787c9588800688930c88d0a69fa3ee6a06e9.zip | |
Merge branch 'add-change-view'
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; + }); +}); |
