Skip to content

Commit e442dcd

Browse files
committed
fixup: add tests
1 parent 8a41879 commit e442dcd

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

packages/query-parser/src/index.spec.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ describe('mongodb-query-parser', function () {
120120
);
121121
});
122122

123-
// TODO: prototype replace test with val for new val.
124-
125123
it('should support LegacyJavaUUID', function () {
126124
assert.deepEqual(
127125
convert('LegacyJavaUUID("00112233-4455-6677-8899-aabbccddeeff")'),
128126
{
129-
$binary: 'OyQRAeK7QlWMr0E2xWapYg==',
127+
$binary: 'd2ZVRDMiEQD/7t3Mu6qZiA==',
130128
$type: `0${bson.Binary.SUBTYPE_UUID_OLD}`,
131129
},
132130
);
@@ -136,7 +134,7 @@ describe('mongodb-query-parser', function () {
136134
assert.deepEqual(
137135
convert('LegacyCSharpUUID("00112233-4455-6677-8899-aabbccddeeff")'),
138136
{
139-
$binary: 'OyQRAeK7QlWMr0E2xWapYg==',
137+
$binary: 'MyIRAFVEd2aImaq7zN3u/w==',
140138
$type: `0${bson.Binary.SUBTYPE_UUID_OLD}`,
141139
},
142140
);
@@ -146,7 +144,7 @@ describe('mongodb-query-parser', function () {
146144
assert.deepEqual(
147145
convert('LegacyPythonUUID("00112233-4455-6677-8899-aabbccddeeff")'),
148146
{
149-
$binary: 'OyQRAeK7QlWMr0E2xWapYg==',
147+
$binary: 'ABEiM0RVZneImaq7zN3u/w==',
150148
$type: `0${bson.Binary.SUBTYPE_UUID_OLD}`,
151149
},
152150
);
@@ -675,7 +673,38 @@ e s`,
675673
);
676674
});
677675

678-
// TODO: New tests for the legacy UUID formats.
676+
it('does not stringify LegacyJavaUUID', function () {
677+
const res = parseFilter(
678+
'{name: LegacyJavaUUID("00112233-4455-6677-8899-aabbccddeeff")}',
679+
);
680+
const stringified = stringify(res);
681+
assert.equal(
682+
stringified,
683+
"{name: BinData(3, 'd2ZVRDMiEQD/7t3Mu6qZiA==')}",
684+
);
685+
});
686+
687+
it('does not stringify LegacyCSharpUUID', function () {
688+
const res = parseFilter(
689+
'{name: LegacyCSharpUUID("00112233-4455-6677-8899-aabbccddeeff")}',
690+
);
691+
const stringified = stringify(res);
692+
assert.equal(
693+
stringified,
694+
"{name: BinData(3, 'MyIRAFVEd2aImaq7zN3u/w==')}",
695+
);
696+
});
697+
698+
it('does not stringify LegacyPythonUUID', function () {
699+
const res = parseFilter(
700+
'{name: LegacyPythonUUID("00112233-4455-6677-8899-aabbccddeeff")}',
701+
);
702+
const stringified = stringify(res);
703+
assert.equal(
704+
stringified,
705+
"{name: BinData(3, 'ABEiM0RVZneImaq7zN3u/w==')}",
706+
);
707+
});
679708

680709
// https://www.mongodb.com/docs/manual/reference/method/Binary.createFromHexString/
681710
it('should support Binary.createFromHexString', function () {

0 commit comments

Comments
 (0)