Skip to content

Commit b30752c

Browse files
committed
chore(mongodb-constants): add test for version specified in constants
1 parent 17563b4 commit b30752c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/mongodb-constants/src/filter.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/* eslint-disable mocha/max-top-level-suites */
12
import { expect } from 'chai';
23
import type { Completion } from './filter';
3-
import { wrapField, getFilteredCompletions } from './filter';
4+
import { wrapField, getFilteredCompletions, ALL_CONSTANTS } from './filter';
5+
import semver from 'semver';
6+
import util from 'util';
47

58
describe('completer', function () {
69
const simpleConstants: Completion[] = [
@@ -190,4 +193,21 @@ describe('completer', function () {
190193
);
191194
});
192195
});
196+
197+
describe('all completions', function () {
198+
it('should have valid semver version or range specified', function () {
199+
ALL_CONSTANTS.forEach(({ name, version }) => {
200+
const errMessage = `Expected completion ${util.inspect({
201+
name,
202+
version,
203+
})} to have valid version`;
204+
205+
try {
206+
expect(semver.valid(version)).to.not.eq(null, errMessage);
207+
} catch {
208+
expect(semver.validRange(version)).to.not.eq(null, errMessage);
209+
}
210+
});
211+
});
212+
});
193213
});

packages/mongodb-constants/src/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { QUERY_OPERATORS } from './query-operators';
99
import { STAGE_OPERATORS } from './stage-operators';
1010
import { SYSTEM_VARIABLES } from './system-variables';
1111

12-
const ALL_CONSTANTS = [
12+
export const ALL_CONSTANTS = [
1313
...ACCUMULATORS,
1414
...BSON_TYPES,
1515
...BSON_TYPE_ALIASES,

0 commit comments

Comments
 (0)