-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1561f50
commit 2b702ac
Showing
2 changed files
with
47 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,5 @@ describe('Exec Command With Bash', () => { | |
/verbose should be empty or one of \[info, log, warn, error, quiet\]/, | ||
) | ||
}) | ||
|
||
test('Exec Command With doubled options', async () => { | ||
await expect(execa(`${mwo} --verbose --mwUrl="https://en.wikipedia.org" --adminEmail="[email protected]" --verbose=info`, { shell: true })).rejects.toThrow( | ||
/Parameter verbose can only be used once/, | ||
) | ||
await expect(execa(`${mwo} --verbose --mwUrl="https://en.wikipedia.org" --adminEmail="[email protected]" --mwUrl="https://en.wikipedia.org"`, { shell: true })).rejects.toThrow( | ||
/Parameter mwUrl can only be used once/, | ||
) | ||
}) | ||
}) | ||
}) |
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,47 @@ | ||
import { sanitize_all } from '../../src/sanitize-argument.js' | ||
|
||
describe('Sanitize parameters', () => { | ||
test('sanitizing usage of the same parameter more than one time', async () => { | ||
// equivalent to command: node lib/cli.js --verbose --mwUrl="https://en.wikipedia.org" --adminEmail="[email protected]" --verbose=info | ||
const twoVerboseParameters = { | ||
_: [], | ||
verbose: [true, 'info'], | ||
mwUrl: 'https://en.wikipedia.org', | ||
'mw-url': 'https://en.wikipedia.org', | ||
adminEmail: '[email protected]', | ||
'admin-email': '[email protected]', | ||
$0: 'node_modules/ts-node/dist/child/child-entrypoint.js', | ||
} | ||
|
||
await expect(sanitize_all(twoVerboseParameters)).rejects.toThrow(/Parameter '--verbose' can only be used once/) | ||
|
||
// equivalent to command: node lib/cli.js --verbose --mwUrl="https://en.wikipedia.org" --adminEmail="[email protected]" --mwUrl="https://en.wikipedia.org" | ||
const twoUrlParameters = { | ||
_: [], | ||
verbose: true, | ||
mwUrl: ['https://en.wikipedia.org', 'https://en.wikipedia.org'], | ||
'mw-url': ['https://en.wikipedia.org', 'https://en.wikipedia.org'], | ||
adminEmail: '[email protected]', | ||
'admin-email': '[email protected]', | ||
$0: 'node_modules/ts-node/dist/child/child-entrypoint.js', | ||
} | ||
|
||
await expect(sanitize_all(twoUrlParameters)).rejects.toThrow(/Parameter '--mwUrl' can only be used once/) | ||
|
||
// equivalent to command: node lib/cli.js --verbose=info --adminEmail="[email protected]" --articleList="User:Kelson/MWoffliner_CI_reference" --mwUrl="https://en.m.wikipedia.org/" --format=nopic --format=nopdf --format=novid | ||
const threeFormatParameters = { | ||
_: [], | ||
verbose: 'info', | ||
adminEmail: '[email protected]', | ||
'admin-email': '[email protected]', | ||
articleList: 'User:Kelson/MWoffliner_CI_reference', | ||
'article-list': 'User:Kelson/MWoffliner_CI_reference', | ||
mwUrl: 'https://en.m.wikipedia.org/', | ||
'mw-url': 'https://en.m.wikipedia.org/', | ||
format: ['nopic', 'nopdf', 'novid'], | ||
$0: 'node_modules/ts-node/dist/child/child-entrypoint.js', | ||
} | ||
|
||
expect(await sanitize_all(threeFormatParameters)).toBeUndefined() | ||
}) | ||
}) |