From 6bcbf2b2ba3fb35380990adefa58d2b64a1e7097 Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Fri, 15 Oct 2021 13:40:14 -0700 Subject: [PATCH] Simplify conditionals with a switch --- ui/desktop/tests/end2end/test-helpers.js | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ui/desktop/tests/end2end/test-helpers.js b/ui/desktop/tests/end2end/test-helpers.js index 80282aaf6..ff6902143 100644 --- a/ui/desktop/tests/end2end/test-helpers.js +++ b/ui/desktop/tests/end2end/test-helpers.js @@ -25,21 +25,18 @@ exports.generateScreenshotPath = (screenshotTestDirectory, fileName) => { */ exports.returnExecutablePath = (platform, arch) => { try { - // Just mac - if (platform === 'darwin') { - if (arch === 'x64') { - // Intel chips - return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; - } else if (arch === 'arm64') { - // M1 chips - return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; - } else { - throw new Error('The test suite is not compatible with your arch.'); - } - } else { - throw new Error( - 'The test suite is not compatible with your Platform or Architecture.' - ); + switch (platform) { + case 'darwin': + switch (arch) { + case 'x64': // Intel chips + return 'electron-app/out/Boundary-darwin-x64/Boundary.app/Contents/MacOS/Boundary'; + case 'arm64': // M1 chips + return 'electron-app/out/Boundary-darwin-arm64/Boundary.app/Contents/MacOS/Boundary'; + default: + throw new Error('The test suite is not compatible with your arch.'); + } + default: + throw new Error('The test suite is not compatible with your platform.'); } } catch (error) { console.error(error);