-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sindre Sorhus <[email protected]>
- Loading branch information
1 parent
c00d5c5
commit 9961bc0
Showing
5 changed files
with
47 additions
and
23 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
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
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 |
---|---|---|
@@ -1,24 +1,45 @@ | ||
import test from 'ava'; | ||
import meow from '../../source/index.js'; | ||
|
||
test('main', t => { | ||
t.notThrows(() => meow({importMeta: import.meta})); | ||
const verifyImportMeta = test.macro((t, {cli, error}) => { | ||
if (error) { | ||
t.throws(cli, {message: 'The `importMeta` option is required. Its value must be `import.meta`.'}); | ||
} else { | ||
t.notThrows(cli); | ||
} | ||
}); | ||
|
||
test('with help shortcut', t => { | ||
t.notThrows(() => ( | ||
meow(` | ||
unicorns | ||
rainbows | ||
`, { | ||
importMeta: import.meta, | ||
}) | ||
)); | ||
test('main', verifyImportMeta, { | ||
cli: () => meow({ | ||
importMeta: import.meta, | ||
}), | ||
}); | ||
|
||
test('invalid package url', t => { | ||
t.throws( | ||
() => meow({importMeta: '/path/to/package'}), | ||
{message: 'The `importMeta` option is required. Its value must be `import.meta`.'}, | ||
); | ||
test('with help shortcut', verifyImportMeta, { | ||
cli: () => meow(` | ||
unicorns | ||
rainbows | ||
`, { | ||
importMeta: import.meta, | ||
}), | ||
}); | ||
|
||
test('invalid package url', verifyImportMeta, { | ||
cli: () => meow({importMeta: '/path/to/package'}), | ||
error: true, | ||
}); | ||
|
||
test('throws if unset', verifyImportMeta, { | ||
cli: () => meow('foo', {}), | ||
error: true, | ||
}); | ||
|
||
test('throws if unset - options only', verifyImportMeta, { | ||
cli: () => meow({}), | ||
error: true, | ||
}); | ||
|
||
test('throws if unset - help shortcut only', verifyImportMeta, { | ||
cli: () => meow('foo'), | ||
error: true, | ||
}); |