Skip to content

Commit b7b85a2

Browse files
committed
test: Add simple test for NPM use
1 parent 27015cf commit b7b85a2

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/utils.spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { toBool, getDeltaText, iconForDifference, diffTable, fileExists, stripHash } from '../src/utils.js';
1+
import path from 'path';
2+
import { toBool, getDeltaText, iconForDifference, diffTable, getPackageManagerAndInstallScript, fileExists, stripHash } from '../src/utils.js';
23

34
test('toBool', () => {
45
expect(toBool('1')).toBe(true);
@@ -65,6 +66,18 @@ test('diffTable', () => {
6566
expect(diffTable([files[2]], { ...defaultOptions })).toMatchSnapshot();
6667
});
6768

69+
test('getPackageManagerAndInstallScript', async () => {
70+
let cwd = process.cwd();
71+
let { packageManager, installScript } = await getPackageManagerAndInstallScript(cwd);
72+
expect(packageManager).toBe('npm');
73+
expect(installScript).toBe('npm ci');
74+
75+
cwd = path.join(cwd, 'tests');
76+
({ packageManager, installScript } = await getPackageManagerAndInstallScript(cwd));
77+
expect(packageManager).toBe('npm');
78+
expect(installScript).toBe('npm install');
79+
});
80+
6881
test('fileExists', async () => {
6982
expect(await fileExists('package.json')).toBe(true);
7083
expect(await fileExists('file-that-does-not-exist')).toBe(false);

0 commit comments

Comments
 (0)