@@ -43,24 +43,16 @@ describe('GitTabularDiffView.serialize()', function() {
43
43
GitTabularDiff . activate ( null ) ;
44
44
GitTabularDiff . fileSelector = helper . makeFileSelector ( repositoryPath , exampleFile ) ;
45
45
const id = await helper . openView ( split ) ;
46
-
47
46
expect ( id . length ) . toBe ( 36 ) ;
48
- const workspaceElement = atom . views . getView ( atom . workspace ) ;
49
- expect ( workspaceElement ) . toExist ( ) ;
50
- let gitTabularDiffElement = workspaceElement . querySelector ( `[id='${ id } ']` ) ;
51
- expect ( gitTabularDiffElement ) . toExist ( ) ;
52
- expect ( gitTabularDiffElement ) . toHaveClass ( 'git-tabular-diff' ) ;
53
-
54
47
expect ( GitTabularDiffView . pendingFileDiffs . size ) . toBe ( 0 ) ;
55
48
56
49
let view = atom . workspace . getActivePaneItem ( ) ;
57
50
expect ( view ) . toBeInstanceOf ( GitTabularDiffView ) ;
51
+
58
52
const serializedState = view . serialize ( ) ;
59
53
60
54
view . destroy ( ) ;
61
55
view = null ;
62
- gitTabularDiffElement = workspaceElement . querySelector ( `[id='${ id } ']` ) ;
63
- expect ( gitTabularDiffElement ) . not . toExist ( ) ;
64
56
65
57
view = GitTabularDiff . deserializeGitTabularDiffView ( serializedState ) ;
66
58
expect ( view ) . toBeInstanceOf ( GitTabularDiffView ) ;
@@ -96,29 +88,23 @@ describe('GitTabularDiffView.saveAs()', function() {
96
88
GitTabularDiff . activate ( null ) ;
97
89
GitTabularDiff . fileSelector = helper . makeFileSelector ( repositoryPath , file ) ;
98
90
const id = await helper . openView ( split ) ;
99
-
100
- const workspaceElement = atom . views . getView ( atom . workspace ) ;
101
- expect ( workspaceElement ) . toExist ( ) ;
102
- let gitTabularDiffElement = workspaceElement . querySelector ( `[id='${ id } ']` ) ;
103
- expect ( gitTabularDiffElement ) . toExist ( ) ;
104
- expect ( gitTabularDiffElement ) . toHaveClass ( 'git-tabular-diff' ) ;
105
-
91
+ expect ( id . length ) . toBe ( 36 ) ;
106
92
expect ( GitTabularDiffView . pendingFileDiffs . size ) . toBe ( 0 ) ;
107
93
94
+ const view = atom . workspace . getActivePaneItem ( ) ;
95
+ expect ( view ) . toBeInstanceOf ( GitTabularDiffView ) ;
96
+
108
97
// opening again should activate the existing view, not open another
109
98
const id2 = await helper . openView ( split ) ;
110
99
expect ( id2 ) . toBe ( id ) ;
111
100
expect ( GitTabularDiffView . pendingFileDiffs . size ) . toBe ( 0 ) ;
112
101
113
- let view = atom . workspace . getActivePaneItem ( ) ;
114
- expect ( view ) . toBeInstanceOf ( GitTabularDiffView ) ;
115
- expect ( view . getPath ( ) ) . toBe ( saveAsFile ) ;
116
- await view . saveAs ( saveAsPath ) ;
102
+ const view2 = atom . workspace . getActivePaneItem ( ) ;
103
+ expect ( view2 ) . toBe ( view ) ;
104
+ expect ( GitTabularDiffView . pendingFileDiffs . size ) . toBe ( 0 ) ;
117
105
118
- view . destroy ( ) ;
119
- view = null ;
120
- gitTabularDiffElement = workspaceElement . querySelector ( `[id='${ id } ']` ) ;
121
- expect ( gitTabularDiffElement ) . not . toExist ( ) ;
106
+ expect ( view2 . getPath ( ) ) . toBe ( saveAsFile ) ;
107
+ await view2 . saveAs ( saveAsPath ) ;
122
108
123
109
const savedfileContents = await fs . readFile ( saveAsPath , 'utf8' ) ;
124
110
const goodSaveAsPath = path . join ( repositoryPath , file ) ;
0 commit comments