From 02dcd4e970b35e779487e819ed891b41aefc630a Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Tue, 12 May 2026 01:11:31 +0800 Subject: [PATCH] test: dedupe registry checks; merge filter prototype loop Co-authored-by: Cursor --- test/e2e/issues.spec.ts | 5 +---- test/integration/liquid/register-filters.spec.ts | 13 ++----------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/test/e2e/issues.spec.ts b/test/e2e/issues.spec.ts index 35d3f17c3..700bbaa8e 100644 --- a/test/e2e/issues.spec.ts +++ b/test/e2e/issues.spec.ts @@ -77,16 +77,13 @@ describe('Issues', function () { ) expect(html).toBe('BAR') }) - it('filter/tag maps are null-prototype; built-ins work (node + UMD)', async () => { - const tpl = `{{ 'a' | append: 'b' }}` + it('filter/tag maps are null-prototype (node + UMD)', async () => { const nodeEngine = new Liquid() const umdEngine = new LiquidUMD() expect(Object.getPrototypeOf(nodeEngine.filters)).toBeNull() expect(Object.getPrototypeOf(nodeEngine.tags)).toBeNull() expect(Object.getPrototypeOf(umdEngine.filters)).toBeNull() expect(Object.getPrototypeOf(umdEngine.tags)).toBeNull() - expect(await nodeEngine.parseAndRender(tpl)).toBe('ab') - expect(await umdEngine.parseAndRender(tpl)).toBe('ab') }) it('lenientIf not working as expected in umd #313', async () => { const engine = new LiquidUMD({ diff --git a/test/integration/liquid/register-filters.spec.ts b/test/integration/liquid/register-filters.spec.ts index 33a46d295..e60b781ae 100644 --- a/test/integration/liquid/register-filters.spec.ts +++ b/test/integration/liquid/register-filters.spec.ts @@ -65,22 +65,13 @@ describe('liquid#registerFilter()', function () { it('should use a null-prototype map for filters', () => { expect(Object.getPrototypeOf(liquid.filters)).toBeNull() }) - it('should still resolve built-in filters', async () => { - expect(await liquid.parseAndRender(`{{ 'a' | append: 'b' }}`)).toBe('ab') - }) - it('should not resolve names that exist only on Object.prototype', async () => { + it('should treat Object.prototype keys as unregistered unless explicitly registered', async () => { const registered = new Set(Object.keys(liquid.filters)) + const strict = new Liquid({ strictFilters: true }) for (const name of Object.getOwnPropertyNames(Object.prototype)) { if (registered.has(name)) continue const out = await liquid.parseAndRender(`{{ x | ${name} }}`, { x: 42 }) expect(out).toBe('42') - } - }) - it('should reject unknown filter names under strictFilters, including Object.prototype keys', async () => { - const strict = new Liquid({ strictFilters: true }) - const registered = new Set(Object.keys(strict.filters)) - for (const name of Object.getOwnPropertyNames(Object.prototype)) { - if (registered.has(name)) continue await expect(strict.parseAndRender(`{{ 1 | ${name} }}`)).rejects.toThrow('undefined filter') } })