From 75f1ef5369f35e3d84d16652c1181c2edea64292 Mon Sep 17 00:00:00 2001 From: Dominic Gannaway Date: Thu, 15 Aug 2024 09:33:26 +0100 Subject: [PATCH] add error preventing setting descriptors that are complex #2 --- .../svelte/src/internal/client/proxy.test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/svelte/src/internal/client/proxy.test.ts b/packages/svelte/src/internal/client/proxy.test.ts index 9786ad0acbbb..c549f87935cc 100644 --- a/packages/svelte/src/internal/client/proxy.test.ts +++ b/packages/svelte/src/internal/client/proxy.test.ts @@ -35,7 +35,7 @@ test('preserves getters', () => { }); test('defines a property', () => { - const original = {}; + const original = { y: 0 }; const state = proxy(original); let value = 0; @@ -43,9 +43,25 @@ test('defines a property', () => { Object.defineProperty(state, 'x', { value: 1 }); + Object.defineProperty(state, 'y', { + value: 1 + }); assert.equal(state.x, 1); + assert.deepEqual(Object.getOwnPropertyDescriptor(state, 'x'), { + configurable: true, + writable: true, + value: 1, + enumerable: true + }); + assert.ok(!('x' in original)); + assert.deepEqual(Object.getOwnPropertyDescriptor(original, 'y'), { + configurable: true, + writable: true, + value: 0, + enumerable: true + }); assert.throws( () =>