Add test for `SignalMenu.createTemplate` on macOS

This commit is contained in:
Daniel Gasienica 2018-02-27 12:40:29 -05:00
parent 9638b86c0f
commit 1a0489919c
2 changed files with 198 additions and 0 deletions

View File

@ -0,0 +1,159 @@
[
{
"submenu": [
{
"label": "About Signal Desktop",
"click": null
},
{
"type": "separator"
},
{
"role": "hide"
},
{
"role": "hideothers"
},
{
"role": "unhide"
},
{
"type": "separator"
},
{
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"role": "undo"
},
{
"role": "redo"
},
{
"type": "separator"
},
{
"role": "cut"
},
{
"role": "copy"
},
{
"role": "paste"
},
{
"role": "pasteandmatchstyle"
},
{
"role": "delete"
},
{
"role": "selectall"
},
{
"type": "separator"
},
{
"label": "Speech",
"submenu": [
{
"role": "startspeaking"
},
{
"role": "stopspeaking"
}
]
}
]
},
{
"label": "&View",
"submenu": [
{
"role": "resetzoom"
},
{
"role": "zoomin"
},
{
"role": "zoomout"
},
{
"type": "separator"
},
{
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"role": "toggledevtools"
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"accelerator": "CmdOrCtrl+W",
"role": "close"
},
{
"accelerator": "CmdOrCtrl+M",
"role": "minimize"
},
{
"role": "zoom"
},
{
"label": "Show",
"click": null
},
{
"type": "separator"
},
{
"role": "front"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Go to release notes",
"click": null
},
{
"type": "separator"
},
{
"label": "Go to forums",
"click": null
},
{
"label": "Go to support page",
"click": null
},
{
"label": "File a bug",
"click": null
}
]
}
]

39
test/app/menu_test.js Normal file
View File

@ -0,0 +1,39 @@
const { assert } = require('chai');
const SignalMenu = require('../../app/menu');
const { load: loadLocale } = require('../../app/locale');
const FIXTURE_MAC_OS_MENU = require('./fixtures/menu-mac-os');
describe('SignalMenu', () => {
describe('createTemplate', () => {
context('on macOS', () => {
it('should return correct template', () => {
const logger = {
error(message) {
throw new Error(message);
},
};
const options = {
openForums: null,
openNewBugForm: null,
openReleaseNotes: null,
openSupportPage: null,
platform: 'darwin',
setupAsNewDevice: null,
setupAsStandalone: null,
setupWithImport: null,
showAbout: null,
showDebugLog: null,
showWindow: null,
};
const appLocale = 'en';
const { messages } = loadLocale({ appLocale, logger });
const actual = SignalMenu.createTemplate(options, messages);
assert.deepEqual(actual, FIXTURE_MAC_OS_MENU);
});
});
});
});