mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #14597 from Snuffleupagus/Dict-set-validate-key
Ensure that `Dict.set` only accepts string `key`s
This commit is contained in:
commit
409cbfc817
4 changed files with 20 additions and 7 deletions
|
@ -149,6 +149,17 @@ describe("primitives", function () {
|
|||
checkInvalidKeyValues(dictWithSizeKey);
|
||||
});
|
||||
|
||||
it("should not accept to set a non-string key", function () {
|
||||
const dict = new Dict();
|
||||
expect(function () {
|
||||
dict.set(123, "val");
|
||||
}).toThrow(new Error('Dict.set: The "key" must be a string.'));
|
||||
|
||||
expect(dict.has(123)).toBeFalsy();
|
||||
|
||||
checkInvalidKeyValues(dict);
|
||||
});
|
||||
|
||||
it("should not accept to set a key with an undefined value", function () {
|
||||
const dict = new Dict();
|
||||
expect(function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue