Skip to content

Commit

Permalink
add error preventing setting descriptors that are complex #2
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Aug 15, 2024
1 parent a27b573 commit 75f1ef5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/svelte/src/internal/client/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,33 @@ test('preserves getters', () => {
});

test('defines a property', () => {
const original = {};
const original = { y: 0 };
const state = proxy<any>(original);

let value = 0;

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(
() =>
Expand Down

0 comments on commit 75f1ef5

Please sign in to comment.