@@ -11,7 +11,7 @@ import * as diffResponse from '../test-components/data/diffResponse.json';
1111jest . mock ( '../../src/git' ) ;
1212
1313describe ( '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 ( ) => {
1515 // Given
1616 const props : IDiffProps = {
1717 path : '/path/to/File.ipynb' ,
@@ -34,22 +34,22 @@ describe('NBDiff', () => {
3434 const node = shallow ( < NBDiff { ...props } /> ) ;
3535
3636 // Then
37- jsonResult . then ( ( ) => {
38- node . update ( ) ;
37+ await jsonResult ;
3938
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' }
4946 } ) ;
47+ expect ( node . find ( '.jp-git-diff-error' ) . text ( ) ) . toContain (
48+ 'TEST_ERROR_MESSAGE'
49+ ) ;
5050 } ) ;
5151
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 ( ) => {
5353 // Given
5454 const props : IDiffProps = {
5555 path : '/path/to/File.ipynb' ,
@@ -61,7 +61,7 @@ describe('NBDiff', () => {
6161 } ;
6262
6363 const jsonResult : Promise < any > = Promise . resolve ( {
64- diffResponse
64+ ... diffResponse
6565 } ) ;
6666
6767 ( httpGitRequest as jest . Mock ) . mockReturnValue (
@@ -72,18 +72,17 @@ describe('NBDiff', () => {
7272 const node = shallow ( < NBDiff { ...props } /> ) ;
7373
7474 // Then
75- jsonResult . then ( ( ) => {
76- node . update ( ) ;
75+ await jsonResult ;
76+ node . update ( ) ;
7777
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' }
8783 } ) ;
84+ expect ( node . find ( '.jp-git-diff-error' ) ) . toHaveLength ( 0 ) ;
85+ expect ( node . find ( NBDiffHeader ) ) . toHaveLength ( 1 ) ;
86+ expect ( node . find ( CellDiff ) ) . toHaveLength ( 3 ) ;
8887 } ) ;
8988} ) ;
0 commit comments