1
1
import React from 'react'
2
- import { App } from '../App'
2
+ import App from '../../App'
3
+ import { getThoughtsRanked } from '../../util.js'
3
4
4
5
// eslint-disable-next-line fp/no-let
5
6
let wrapper = null
@@ -24,10 +25,31 @@ it('create and edit subthought', async () => {
24
25
expect ( thought . text ( ) ) . toBe ( '' )
25
26
const keyboardResponder = wrapper . find ( 'div#keyboard' )
26
27
await thought . simulate ( 'change' , { target : { value : 'c' } } )
27
- await keyboardResponder . simulate ( 'keydown' , { key : 'Enter' } )
28
+ await keyboardResponder . simulate ( 'keydown' , { key : 'Enter' , ctrlKey : true } )
28
29
// eslint-disable-next-line no-undef
29
30
jest . runAllTimers ( )
30
31
await thought . update ( )
31
32
// eslint-disable-next-line no-undef
32
33
expect ( thought . text ( ) ) . toBe ( 'c' )
34
+ // eslint-disable-next-line fp/no-let
35
+ let subthoughtsData = getThoughtsRanked ( [ 'c' ] )
36
+ // eslint-disable-next-line fp/no-let
37
+ let subthoughtData = subthoughtsData [ 0 ]
38
+ // eslint-disable-next-line no-undef
39
+ expect ( subthoughtData . value ) . toBe ( '' )
40
+ await wrapper . update ( )
41
+ const subthought = wrapper . find (
42
+ 'ul.distance-from-cursor-0 li.leaf div.thought-container div.thought div.editable' ,
43
+ )
44
+ await subthought . simulate ( 'change' , { target : { value : 's' } } )
45
+ await keyboardResponder . simulate ( 'keydown' , { key : 'Enter' } )
46
+ // eslint-disable-next-line no-undef
47
+ jest . runAllTimers ( )
48
+ await subthought . update ( )
49
+ // eslint-disable-next-line no-undef
50
+ expect ( subthought . text ( ) ) . toBe ( 's' )
51
+ subthoughtsData = getThoughtsRanked ( [ 'c' ] )
52
+ subthoughtData = subthoughtsData [ 0 ]
53
+ // eslint-disable-next-line no-undef
54
+ expect ( subthoughtData . value ) . toBe ( 's' )
33
55
} )
0 commit comments