Skip to content

Commit 5dc7d99

Browse files
Add tests for boxed strings and Objects pretending to be a string
1 parent ba3c7ae commit 5dc7d99

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

test/util.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,23 @@ describe('assertString', () => {
5454
assert.throws(() => { assertString([]); }, TypeError);
5555
});
5656

57+
it('Should throw an error if argument provided is an Object pretending to be a \'string\'', () => {
58+
assert.throws(() => { assertString({constructor: {name: "string"}}); }, TypeError);
59+
});
60+
61+
it('Should throw an error if argument provided is an Object pretending to be a \'String\'', () => {
62+
assert.throws(() => { assertString({constructor: {name: "String"}}); }, TypeError);
63+
});
64+
5765
it('Should not throw an error if the argument is an empty string', () => {
5866
assert.doesNotThrow(() => { assertString(''); });
5967
});
60-
68+
6169
it('Should not throw an error if the argument is a String', () => {
6270
assert.doesNotThrow(() => { assertString('antidisestablishmentarianism'); });
6371
});
72+
73+
it('Should not throw an error if the argument is a boxed string', () => {
74+
assert.doesNotThrow(() => { assertString(new String('antidisestablishmentarianism')); });
75+
});
6476
});

0 commit comments

Comments
 (0)