Skip to content

Commit 2a069e4

Browse files
authored
Test for Stage 3 decorators with ECMA private fields (mobxjs#4668)
1 parent 96ddd31 commit 2a069e4

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

packages/mobx/__tests__/decorators_20223/stage3-decorators.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,32 @@ test("annotations", () => {
134134
expect(order1.aFunction()).toBe(1)
135135
})
136136

137+
test("observable private accessors", () => {
138+
class Store {
139+
@observable accessor #value = 1
140+
141+
@computed
142+
get double() {
143+
return this.#value * 2
144+
}
145+
146+
increment() {
147+
this.#value++
148+
}
149+
}
150+
151+
const store = new Store()
152+
const values: number[] = []
153+
const dispose = autorun(() => values.push(store.double))
154+
155+
store.increment()
156+
dispose()
157+
store.increment()
158+
159+
expect(values).toEqual([2, 4])
160+
expect(store.double).toBe(6)
161+
})
162+
137163
test("box", () => {
138164
class Box {
139165
@observable accessor uninitialized: any

0 commit comments

Comments
 (0)