2020-05-28 13:48:25 -03:00
|
|
|
"use strict";
|
|
|
|
|
|
2020-07-05 14:47:40 -03:00
|
|
|
test("basic functionality", () => {
|
2020-07-06 11:37:45 -03:00
|
|
|
[true, false, "foo", 123].forEach(primitive => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
primitive.foo = "bar";
|
2021-04-02 16:00:37 -03:00
|
|
|
}).toThrowWithMessage(
|
|
|
|
|
TypeError,
|
|
|
|
|
`Cannot set property 'foo' of ${typeof primitive} '${primitive}'`
|
|
|
|
|
);
|
|
|
|
|
expect(() => {
|
|
|
|
|
primitive[Symbol.hasInstance] = 123;
|
|
|
|
|
}).toThrowWithMessage(
|
|
|
|
|
TypeError,
|
|
|
|
|
`Cannot set property 'Symbol(Symbol.hasInstance)' of ${typeof primitive} '${primitive}'`
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
[null, undefined].forEach(primitive => {
|
|
|
|
|
expect(() => {
|
|
|
|
|
primitive.foo = "bar";
|
2021-06-25 11:27:59 -03:00
|
|
|
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
|
2020-11-12 07:32:46 -03:00
|
|
|
expect(() => {
|
|
|
|
|
primitive[Symbol.hasInstance] = 123;
|
2021-06-25 11:27:59 -03:00
|
|
|
}).toThrowWithMessage(TypeError, `${primitive} cannot be converted to an object`);
|
2020-07-06 11:37:45 -03:00
|
|
|
});
|
2020-07-05 14:47:40 -03:00
|
|
|
});
|