Skip to content

Commit 75f1ef5

Browse files
committed
add error preventing setting descriptors that are complex #2
1 parent a27b573 commit 75f1ef5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

packages/svelte/src/internal/client/proxy.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,33 @@ test('preserves getters', () => {
3535
});
3636

3737
test('defines a property', () => {
38-
const original = {};
38+
const original = { y: 0 };
3939
const state = proxy<any>(original);
4040

4141
let value = 0;
4242

4343
Object.defineProperty(state, 'x', {
4444
value: 1
4545
});
46+
Object.defineProperty(state, 'y', {
47+
value: 1
48+
});
4649

4750
assert.equal(state.x, 1);
51+
assert.deepEqual(Object.getOwnPropertyDescriptor(state, 'x'), {
52+
configurable: true,
53+
writable: true,
54+
value: 1,
55+
enumerable: true
56+
});
57+
4858
assert.ok(!('x' in original));
59+
assert.deepEqual(Object.getOwnPropertyDescriptor(original, 'y'), {
60+
configurable: true,
61+
writable: true,
62+
value: 0,
63+
enumerable: true
64+
});
4965

5066
assert.throws(
5167
() =>

0 commit comments

Comments
 (0)