Skip to content

Commit b20a6e9

Browse files
committed
Update tests
1 parent 482bc3a commit b20a6e9

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

javascript/usearch.test.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,28 @@ test('Invalid operations', async (t) => {
166166
() => index.add(42n, new Float32Array([0.2, 0.6, 0.4])),
167167
{
168168
name: 'Error',
169-
message: 'Duplicate keys not allowed in high-level wrappers'
169+
message: '<key:42 message:Duplicate keys not allowed in high-level wrappers>'
170+
}
171+
);
172+
});
173+
174+
await t.test('Batch add containing the same key', () => {
175+
const index = new usearch.Index({
176+
metric: "l2sq",
177+
connectivity: 16,
178+
dimensions: 3,
179+
});
180+
index.add(42n, new Float32Array([0.2, 0.6, 0.4]));
181+
assert.throws(
182+
() => {
183+
index.add(
184+
[41n, 42n, 43n],
185+
[[0.1, 0.6, 0.4], [0.2, 0.6, 0.4], [0.3, 0.6, 0.4]]
186+
);
187+
},
188+
{
189+
name: 'Error',
190+
message: '<key:42 message:Duplicate keys not allowed in high-level wrappers>'
170191
}
171192
);
172193
});
@@ -232,7 +253,7 @@ test('Serialization', async (t) => {
232253
() => index.add(43n, new Float32Array([0.2, 0.6, 0.4])),
233254
{
234255
name: 'Error',
235-
message: "Can't add to an immutable index"
256+
message: "<key:43 message:Can't add to an immutable index>"
236257
}
237258
);
238259
});

0 commit comments

Comments
 (0)