Skip to content

Commit

Permalink
chore(test): coverage for nw.App.filteredArgv
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushmanchhabra committed Aug 17, 2024
1 parent e7a8a23 commit 94502e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tests/fixtures/nw/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('nw-app-argv').innerText = nw.App.argv;
document.getElementById('nw-app-fullargv').innerText = nw.App.fullArgv;
document.getElementById('nw-app-filteredargv').innerText = nw.App.filteredArgv;
});
</script>
<title>nw.App fixture</title>
Expand All @@ -18,11 +19,16 @@
<span>nw.App.argv: </span>
<span id="nw-app-argv"></span>
</div>

<br>
<div>
<span>nw.App.fullArgv: </span>
<span id="nw-app-fullargv"></span>
</div>
<br>
<div>
<span>nw.App.filteredArgv: </span>
<span id="nw-app-filteredargv"></span>
</div>
</body>

</html>
23 changes: 22 additions & 1 deletion tests/specs/nw/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('nw.App', { timeout: Infinity }, async function () {

it('renders nw.App.fullArgv', async () => {
/**
* `nw.App.argv` looks similar to the following:
* `nw.App.fullArgv` looks similar to the following:
*
* `"--allow-pre-commit-input,--disable-popup-blocking,--enable-automation,--enable-logging,--headless=new,--nwapp=/home/ayushmanchhabra/Git/nwutils/cli/tests/fixtures/nw/app,--remote-debugging-port=0,--user-data-dir=/tmp/.io.nwjs.Jb5Vnk"`
*
Expand All @@ -77,6 +77,27 @@ describe('nw.App', { timeout: Infinity }, async function () {
expect(argv).toContain('--user-data-dir=');
});

it('renders nw.App.filteredArgv', async () => {
/**
* `nw.App.filteredArgv` looks similar to the following:
*
* `"/^--url=/,/^--remote-debugging-port=/,/^--renderer-cmd-prefix=/,/^--nwapp=/"`
*
* @type {string}
*/
const argv = await driver.findElement(selenium.By.id('nw-app-filteredargv')).getText();

/* There should be 4 command line arguments. */
const argvLength = argv.split(',').length;
expect(argvLength).toBe(4);

/* Since order does not matter, the `.toContain` matcher is used.*/
expect(argv).toContain('--url=');
expect(argv).toContain('--remote-debugging-port=');
expect(argv).toContain('--renderer-cmd-prefix=');
expect(argv).toContain('--nwapp=');
});

afterAll(async function () {
await driver.quit();
});
Expand Down

0 comments on commit 94502e4

Please sign in to comment.