Skip to content

Commit 3e22416

Browse files
Test that decorator works on getters
1 parent 44b2749 commit 3e22416

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/index.js

+24
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,27 @@ test('The AsyncComputed decorator allows options on async computed properties',
4848
})
4949
})
5050
})
51+
52+
53+
test('The AsyncComputed decorator can be applied to getter computed properties', t => {
54+
t.plan(4)
55+
56+
@Component()
57+
class TestComponent extends Vue {
58+
@AsyncComputed({default: 0})
59+
get shouldBeComputed () {
60+
return new Promise(resolve => {
61+
resolve(1)
62+
})
63+
}
64+
}
65+
const vm = new TestComponent()
66+
67+
t.equal(vm.shouldBeComputed, 0)
68+
t.equal(vm.$asyncComputed.shouldBeComputed.state, 'updating')
69+
70+
Vue.nextTick(() => {
71+
t.equal(vm.$asyncComputed.shouldBeComputed.state, 'success')
72+
t.equal(vm.shouldBeComputed, 1)
73+
})
74+
})

0 commit comments

Comments
 (0)