2018-03-02 20:59:39 +00:00
|
|
|
const { assert } = require('chai');
|
|
|
|
|
|
|
|
const SignalMenu = require('../../app/menu');
|
|
|
|
const { load: loadLocale } = require('../../app/locale');
|
|
|
|
|
|
|
|
const PLATFORMS = [
|
|
|
|
{
|
|
|
|
label: 'macOS',
|
|
|
|
platform: 'darwin',
|
|
|
|
fixtures: {
|
|
|
|
default: './fixtures/menu-mac-os',
|
|
|
|
setup: './fixtures/menu-mac-os-setup',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Windows',
|
|
|
|
platform: 'win32',
|
|
|
|
fixtures: {
|
|
|
|
default: './fixtures/menu-windows-linux',
|
|
|
|
setup: './fixtures/menu-windows-linux-setup',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Linux',
|
|
|
|
platform: 'linux',
|
|
|
|
fixtures: {
|
|
|
|
default: './fixtures/menu-windows-linux',
|
|
|
|
setup: './fixtures/menu-windows-linux-setup',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const INCLUDE_SETUP_OPTIONS = [false, true];
|
|
|
|
|
|
|
|
describe('SignalMenu', () => {
|
|
|
|
describe('createTemplate', () => {
|
|
|
|
PLATFORMS.forEach(({ label, platform, fixtures }) => {
|
|
|
|
context(label, () => {
|
2018-04-27 21:25:04 +00:00
|
|
|
INCLUDE_SETUP_OPTIONS.forEach(includeSetup => {
|
2018-03-02 20:59:39 +00:00
|
|
|
const prefix = includeSetup ? 'with' : 'without';
|
|
|
|
context(`${prefix} setup options`, () => {
|
|
|
|
it('should return correct template', () => {
|
|
|
|
const logger = {
|
|
|
|
error(message) {
|
|
|
|
throw new Error(message);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const options = {
|
2020-06-10 16:56:10 +00:00
|
|
|
isBeta: true,
|
|
|
|
openContactUs: null,
|
2018-03-02 20:59:39 +00:00
|
|
|
openForums: null,
|
2020-06-10 16:56:10 +00:00
|
|
|
openGithub: null,
|
|
|
|
openJoinTheBeta: null,
|
2018-03-02 20:59:39 +00:00
|
|
|
openReleaseNotes: null,
|
|
|
|
openSupportPage: null,
|
|
|
|
platform,
|
|
|
|
includeSetup,
|
|
|
|
setupAsNewDevice: null,
|
|
|
|
setupAsStandalone: null,
|
|
|
|
showAbout: null,
|
|
|
|
showDebugLog: null,
|
2019-11-07 21:36:16 +00:00
|
|
|
showKeyboardShortcuts: null,
|
2018-03-02 20:59:39 +00:00
|
|
|
showSettings: null,
|
2019-12-17 20:25:57 +00:00
|
|
|
showStickerCreator: null,
|
2018-03-02 20:59:39 +00:00
|
|
|
showWindow: null,
|
|
|
|
};
|
|
|
|
const appLocale = 'en';
|
|
|
|
const { messages } = loadLocale({ appLocale, logger });
|
|
|
|
|
|
|
|
const actual = SignalMenu.createTemplate(options, messages);
|
2018-04-27 21:25:04 +00:00
|
|
|
const fixturePath = includeSetup
|
|
|
|
? fixtures.setup
|
|
|
|
: fixtures.default;
|
2018-03-02 20:59:39 +00:00
|
|
|
// eslint-disable-next-line global-require, import/no-dynamic-require
|
|
|
|
const fixture = require(fixturePath);
|
|
|
|
assert.deepEqual(actual, fixture);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|