Skip to content

Commit a1e1697

Browse files
committed
add package test
1 parent 60f3262 commit a1e1697

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

packages/bson-bench/test/unit/common.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { tmpdir } from 'os';
44
import { join, sep } from 'path';
55

66
import { Package } from '../../lib/common';
7-
import { clearTestedDeps } from '../utils';
7+
import { clearTestedDeps, exists } from '../utils';
88

99
describe('common functionality', function () {
1010
const BSON_PATH = process.env.BSON_PATH;
@@ -26,6 +26,7 @@ describe('common functionality', function () {
2626
});
2727

2828
context('constructor()', function () {
29+
//github.com/mongodb-js/dbx-js-tools/pull/24/files
2930
context('when given a correctly formatted npm package', function () {
3031
it('sets computedModuleName correctly', function () {
3132
const pack = new Package('[email protected]', installDir);
@@ -96,9 +97,12 @@ describe('common functionality', function () {
9697
context('#install()', function () {
9798
context('when given a correctly formatted npm package that exists', function () {
9899
for (const lib of ['[email protected]', '[email protected]', 'bson@latest', 'bson-ext@latest']) {
99-
it(`installs ${lib} successfully`, async function () {
100+
it(`installs ${lib} successfully to the specified install directory`, async function () {
100101
const pack = new Package(lib, installDir);
101102
await pack.install();
103+
104+
expect(await exists(join(installDir, 'node_modules', pack.computedModuleName))).to.be
105+
.true;
102106
});
103107
}
104108
});
@@ -112,10 +116,12 @@ describe('common functionality', function () {
112116
});
113117

114118
context('when given a correctly formatted git package using commit that exists', function () {
115-
it('installs successfully', async function () {
119+
it('installs successfully to specified install directory', async function () {
116120
const bson6Git = new Package('bson#58c002d', installDir);
117121
const maybeError = await bson6Git.install().catch(error => error);
118122
expect(maybeError).to.be.undefined;
123+
expect(await exists(join(installDir, 'node_modules', bson6Git.computedModuleName))).to.be
124+
.true;
119125
});
120126
});
121127

@@ -141,6 +147,8 @@ describe('common functionality', function () {
141147
const bson6Git = new Package('bson#v6.0.0', installDir);
142148
const maybeError = await bson6Git.install().catch(error => error);
143149
expect(maybeError).to.be.undefined;
150+
expect(await exists(join(installDir, 'node_modules', bson6Git.computedModuleName))).to
151+
.be.true;
144152
});
145153
}
146154
);
@@ -166,6 +174,8 @@ describe('common functionality', function () {
166174
const bsonLocal = new Package(`bson:${BSON_PATH}`, installDir);
167175
const maybeError = await bsonLocal.install().catch(error => error);
168176
expect(maybeError).to.not.be.instanceOf(Error, maybeError.message);
177+
expect(await exists(join(installDir, 'node_modules', bsonLocal.computedModuleName))).to.be
178+
.true;
169179
});
170180
});
171181

0 commit comments

Comments
 (0)