@@ -11,7 +11,7 @@ import * as diffResponse from '../test-components/data/diffResponse.json';
11
11
jest . mock ( '../../src/git' ) ;
12
12
13
13
describe ( 'NBDiff' , ( ) => {
14
- it ( 'should render error in if API response is failed' , async function ( ) {
14
+ it ( 'should render error in if API response is failed' , async ( ) => {
15
15
// Given
16
16
const props : IDiffProps = {
17
17
path : '/path/to/File.ipynb' ,
@@ -34,22 +34,22 @@ describe('NBDiff', () => {
34
34
const node = shallow ( < NBDiff { ...props } /> ) ;
35
35
36
36
// Then
37
- jsonResult . then ( ( ) => {
38
- node . update ( ) ;
37
+ await jsonResult ;
39
38
40
- expect ( httpGitRequest ) . toHaveBeenCalled ( ) ;
41
- expect ( httpGitRequest ) . toBeCalledWith ( '/nbdime/api/gitdiff' , 'POST' , {
42
- file_path : '/path/to/File.ipynb' ,
43
- ref_curr : { special : 'WORKING' } ,
44
- ref_prev : { git : '83baee' }
45
- } ) ;
46
- expect ( node . find ( '.jp-git-diff-error' ) . text ( ) ) . toContain (
47
- 'TEST_ERROR_MESSAGE'
48
- ) ;
39
+ node . update ( ) ;
40
+
41
+ expect ( httpGitRequest ) . toHaveBeenCalled ( ) ;
42
+ expect ( httpGitRequest ) . toBeCalledWith ( '/nbdime/api/gitdiff' , 'POST' , {
43
+ file_path : 'top/repo/path/path/to/File.ipynb' ,
44
+ ref_remote : { special : 'WORKING' } ,
45
+ ref_local : { git : '83baee' }
49
46
} ) ;
47
+ expect ( node . find ( '.jp-git-diff-error' ) . text ( ) ) . toContain (
48
+ 'TEST_ERROR_MESSAGE'
49
+ ) ;
50
50
} ) ;
51
51
52
- it ( 'should render header and cell diff components in success case' , async function ( ) {
52
+ it ( 'should render header and cell diff components in success case' , async ( ) => {
53
53
// Given
54
54
const props : IDiffProps = {
55
55
path : '/path/to/File.ipynb' ,
@@ -61,7 +61,7 @@ describe('NBDiff', () => {
61
61
} ;
62
62
63
63
const jsonResult : Promise < any > = Promise . resolve ( {
64
- diffResponse
64
+ ... diffResponse
65
65
} ) ;
66
66
67
67
( httpGitRequest as jest . Mock ) . mockReturnValue (
@@ -72,18 +72,17 @@ describe('NBDiff', () => {
72
72
const node = shallow ( < NBDiff { ...props } /> ) ;
73
73
74
74
// Then
75
- jsonResult . then ( ( ) => {
76
- node . update ( ) ;
75
+ await jsonResult ;
76
+ node . update ( ) ;
77
77
78
- expect ( httpGitRequest ) . toHaveBeenCalled ( ) ;
79
- expect ( httpGitRequest ) . toBeCalledWith ( '/nbdime/api/gitdiff' , 'POST' , {
80
- file_path : '/path/to/File.ipynb' ,
81
- ref_curr : { special : 'WORKING' } ,
82
- ref_prev : { git : '83baee' }
83
- } ) ;
84
- expect ( node . find ( '.jp-git-diff-error' ) . html ( ) ) . toBeNull ( ) ;
85
- expect ( node . find ( NBDiffHeader ) ) . toHaveLength ( 1 ) ;
86
- expect ( node . find ( CellDiff ) ) . toHaveLength ( 2 ) ;
78
+ expect ( httpGitRequest ) . toHaveBeenCalled ( ) ;
79
+ expect ( httpGitRequest ) . toBeCalledWith ( '/nbdime/api/gitdiff' , 'POST' , {
80
+ file_path : 'top/repo/path/path/to/File.ipynb' ,
81
+ ref_remote : { special : 'WORKING' } ,
82
+ ref_local : { git : '83baee' }
87
83
} ) ;
84
+ expect ( node . find ( '.jp-git-diff-error' ) ) . toHaveLength ( 0 ) ;
85
+ expect ( node . find ( NBDiffHeader ) ) . toHaveLength ( 1 ) ;
86
+ expect ( node . find ( CellDiff ) ) . toHaveLength ( 3 ) ;
88
87
} ) ;
89
88
} ) ;
0 commit comments