mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
test(context): assert scope isolation without probing prototypes
Replace Object.getPrototypeOf checks for bottom() and getAll() with 'in' checks on typical Object.prototype names plus a merge assertion. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -217,11 +217,16 @@ describe('Context', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('scope storage', function () {
|
describe('scope storage', function () {
|
||||||
it('should use null prototype for bottom scope', function () {
|
it('should not treat Object.prototype properties as implicit keys on bottom scope', function () {
|
||||||
expect(Object.getPrototypeOf(new Context().bottom())).toBeNull()
|
const bottom = new Context().bottom() as Record<string, unknown>
|
||||||
|
expect('toString' in bottom).toBe(false)
|
||||||
|
expect('hasOwnProperty' in bottom).toBe(false)
|
||||||
})
|
})
|
||||||
it('should use null prototype for getAll() merge result', function () {
|
it('should merge into a scope result without implicit Object.prototype keys', function () {
|
||||||
expect(Object.getPrototypeOf(new Context({ a: 1 }).getAll())).toBeNull()
|
const all = new Context({ a: 1 }).getAll() as Record<string, unknown>
|
||||||
|
expect(all.a).toBe(1)
|
||||||
|
expect('toString' in all).toBe(false)
|
||||||
|
expect('hasOwnProperty' in all).toBe(false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user