15
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
*/
17
17
18
- import { nextTick , ref } from 'vue'
19
- import { once , when , until } from '@/utils/index'
18
+ import { nextTick , ref , computed } from 'vue'
19
+ import { once , when , until } from '@/utils/reactivity'
20
+
21
+ const truthySources = ( ) => [
22
+ ref ( true ) ,
23
+ computed ( ( ) => true ) ,
24
+ ( ) => true ,
25
+ ]
20
26
21
27
describe . each ( [
22
28
{ func : when , description : 'watches source until true and then stops watching' } ,
@@ -44,16 +50,15 @@ describe.each([
44
50
} )
45
51
46
52
describe ( 'when()' , ( ) => {
47
- it ( 'works for a source that is already truthy' , ( ) => {
48
- const source = ref ( true )
53
+ it . for ( truthySources ( ) ) ( 'works for already-truthy source %s' , ( source ) => {
49
54
let counter = 0
50
55
when ( source , ( ) => counter ++ )
51
56
expect ( counter ) . toEqual ( 1 )
52
57
} )
53
58
} )
54
59
55
60
describe ( 'once()' , ( ) => {
56
- it ( 'returns a ref that permanently toggles to true when the source bevomes truthy' , async ( ) => {
61
+ it ( 'returns a ref that permanently toggles to true when the source becomes truthy' , async ( ) => {
57
62
const source = ref ( false )
58
63
const myRef = once ( source )
59
64
expect ( myRef . value ) . toEqual ( false )
@@ -65,8 +70,7 @@ describe('once()', () => {
65
70
expect ( myRef . value ) . toEqual ( true )
66
71
} )
67
72
68
- it ( 'works for a source that is already truthy' , ( ) => {
69
- const source = ref ( true )
73
+ it . for ( truthySources ( ) ) ( 'works for already-truthy source %s' , ( source ) => {
70
74
const myRef = once ( source )
71
75
expect ( myRef . value ) . toEqual ( true )
72
76
} )
0 commit comments