Skip to content

Commit 78a6876

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

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { expect } from 'chai';
22
import type { Completion } from './filter';
3-
import { wrapField, getFilteredCompletions } from './filter';
3+
import { wrapField, getFilteredCompletions, ALL_CONSTANTS } from './filter';
4+
import semver from 'semver';
5+
import util from 'util';
46

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

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)