mirror of
https://github.com/hanzoai/babel.git
synced 2026-09-24 16:56:45 +00:00
40 lines
806 B
JavaScript
40 lines
806 B
JavaScript
// Ref: https://github.com/babel/babel/issues/16219
|
|
|
|
// delete global.Symbol doesn't work with jest in node 6
|
|
Object.defineProperty(global, "Symbol", {
|
|
configurable: true,
|
|
writable: true,
|
|
value: undefined
|
|
});
|
|
|
|
require("core-js/modules/es.symbol.js");
|
|
require("core-js/modules/es.symbol.to-primitive");
|
|
|
|
const symbol = Symbol("test");
|
|
|
|
// Use eval to not let Babel transform this `typeof`
|
|
expect(eval('typeof symbol')).toBe("object");
|
|
expect(typeof symbol).toBe("symbol");
|
|
|
|
function objectWithPrimitive(prim) {
|
|
return { [Symbol.toPrimitive]: () => prim }
|
|
}
|
|
|
|
expect(() => {
|
|
class AxiosHeaders {
|
|
[objectWithPrimitive(symbol)]() {
|
|
return;
|
|
}
|
|
}
|
|
}).not.toThrow()
|
|
|
|
expect(() => {
|
|
class AxiosHeaders {
|
|
[objectWithPrimitive({})]() {
|
|
return;
|
|
}
|
|
}
|
|
}).toThrow()
|
|
|
|
return "ok";
|