Skip to content

Commit

Permalink
test: using gasket.symbol as weakmap key (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
agerard-godaddy authored Nov 23, 2024
1 parent 74df1bc commit f3637f9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/gasket-core/test/gasket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,34 @@ describe('makeGasket', () => {
expect(gasket.symbol).toBe(gasket.traceBranch().traceBranch().symbol);
});

it('symbol can be used as a WeakMap key from root', () => {
const data = { example: true };
const map = new WeakMap();

const gasket = makeGasket({ plugins: [mockPlugin] });
const t1 = gasket.traceBranch();
const t2 = t1.traceBranch();
map.set(gasket.symbol, data);

expect(map.has(gasket.symbol)).toBe(true);
expect(map.has(t1.symbol)).toBe(true);
expect(map.has(t2.symbol)).toBe(true);
});

it('symbol can be used as a WeakMap key from deep trace', () => {
const data = { example: true };
const map = new WeakMap();

const gasket = makeGasket({ plugins: [mockPlugin] });
const t1 = gasket.traceBranch();
const t2 = t1.traceBranch();
map.set(t2.symbol, data);

expect(map.has(t2.symbol)).toBe(true);
expect(map.has(t1.symbol)).toBe(true);
expect(map.has(gasket.symbol)).toBe(true);
});

it('defaults env to local', () => {
const gasket = makeGasket({ plugins: [mockPlugin] });
expect(gasket.config.env).toEqual('local');
Expand Down

0 comments on commit f3637f9

Please sign in to comment.