2020-05-28 17:48:25 +01:00
|
|
|
"use strict";
|
|
|
|
|
2023-11-05 15:21:01 +01:00
|
|
|
test("basic functionality", () => {
|
|
|
|
[true, false, "foo", 123, 123n, null, undefined].forEach(primitive => {
|
|
|
|
let description = `${typeof primitive} '${primitive}${
|
|
|
|
typeof primitive == "bigint" ? "n" : ""
|
|
|
|
}'`;
|
|
|
|
if (primitive == null) description = String(primitive);
|
2020-07-06 07:37:45 -07:00
|
|
|
expect(() => {
|
|
|
|
primitive.foo = "bar";
|
2023-11-05 15:21:01 +01:00
|
|
|
}).toThrowWithMessage(TypeError, `Cannot set property 'foo' of ${description}`);
|
2021-04-02 21:00:37 +02:00
|
|
|
expect(() => {
|
|
|
|
primitive[Symbol.hasInstance] = 123;
|
|
|
|
}).toThrowWithMessage(
|
|
|
|
TypeError,
|
2023-11-05 15:21:01 +01:00
|
|
|
`Cannot set property 'Symbol(Symbol.hasInstance)' of ${description}`
|
2021-04-02 21:00:37 +02:00
|
|
|
);
|
|
|
|
});
|
2020-07-05 10:47:40 -07:00
|
|
|
});
|