-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for browser helper (#428)
* Add unit test for browser helper * Update * Update * Update * Update * Update
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for details. | ||
|
||
const assert = require('assert'); | ||
var browser = require('../src/browsers/browser'); | ||
|
||
suite('browserHelper', function () { | ||
const currentSystem = process.platform; | ||
const chrome = 'chrome'; | ||
const edge = 'edge'; | ||
const url = 'http://localhost:8000/index.html'; | ||
|
||
test('Will get Chrome browser target with argument correctly for each system', async () => { | ||
const browserInfo = await browser.getBrowser(chrome, undefined, url); | ||
switch (currentSystem) { | ||
case 'win32': | ||
assert.strictEqual(browserInfo.includes('chrome'), true); | ||
assert.strictEqual(browserInfo.includes(url), false); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=\%TEMP\%\\cordova_simulate_temp_chrome_user_data_dir'), true); | ||
break; | ||
case 'darwin': | ||
assert.strictEqual(browserInfo.includes('Google Chrome'), true); | ||
assert.strictEqual(browserInfo.includes(url), false); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=/tmp/cordova_simulate_temp_chrome_user_data_dir'), true); | ||
break; | ||
case 'linux': | ||
assert.strictEqual(browserInfo.includes('google-chrome'), true); | ||
assert.strictEqual(browserInfo.includes(url), false); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=/tmp/cordova_simulate_temp_chrome_user_data_dir'), true); | ||
break; | ||
} | ||
}); | ||
|
||
test('Will get Edge browser target with argument correctly for each system', async () => { | ||
const browserInfo = await browser.getBrowser(edge, undefined, url); | ||
switch (currentSystem) { | ||
case 'win32': | ||
assert.equal(browserInfo.includes('msedge'), true); | ||
assert.strictEqual(browserInfo.includes(url), true); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=\%TEMP\%\\cordova_simulate_temp_edge_user_data_dir'), true); | ||
break; | ||
case 'darwin': | ||
assert.strictEqual(browserInfo.includes('Microsoft Edge'), true); | ||
assert.strictEqual(browserInfo.includes(url), true); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=/tmp/cordova_simulate_temp_edge_user_data_dir'), true); | ||
break; | ||
case 'linux': | ||
assert.strictEqual(browserInfo.includes('microsoft-edge'), true); | ||
assert.strictEqual(browserInfo.includes(url), true); | ||
assert.strictEqual(browserInfo.includes('--user-data-dir=/tmp/cordova_simulate_temp_edge_user_data_dir'), true); | ||
break; | ||
} | ||
}); | ||
}); | ||
|