Skip to content

Commit

Permalink
test cli/main
Browse files Browse the repository at this point in the history
  • Loading branch information
imcotton committed Jul 6, 2024
1 parent ea9f3d2 commit 9425639
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/cli/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { describe, it } from '@std/testing/bdd';
import * as mock from '@std/testing/mock';

import { Readable } from 'node:stream';

import {

main,

} from '../../src/cli/main.ts';





describe('main', function () {

it('collect lodash and nolyfill with extra ignore', async function () {

const input = Readable.from(`
"version": "1.2.3",
"lockfileVersion": 2,
"node_modules/@babel/core/node_modules/convert-source-map": {
"node_modules/lodash.memoize": {
"node_modules/side-channel": {
"node_modules/acorn-jsx": {
"node_modules/function-bind": {
"node_modules/lodash.merge": {
"node_modules/buffer": {
"version": "6.0.3",
},
`);

const args = [
'--lodash',
'--nolyfill',
'--ignore=lodash.merge,side-channel',
'--extra', 'buffer',
];

const print = mock.spy(() => {});

const quit = mock.spy(() => {});

await main({ args, input, print, quit });

Array.of(
'lodash.memoize',
'function-bind',
'buffer',
).forEach(function (pkg, i) {
mock.assertSpyCallArg(print, i, 0, pkg);
});

mock.assertSpyCalls(print, 3);

mock.assertSpyCallArg(quit, 0, 0, 1);
mock.assertSpyCalls(quit, 1);

});

});

0 comments on commit 9425639

Please sign in to comment.