@@ -24,48 +24,48 @@ describe('ResultsView', () => {
2424
2525 function getResultsPane ( ) {
2626 let pane = atom . workspace . paneForURI ( ResultsPaneView . URI ) ;
27-
28- // Allow element-resize-detector to perform batched measurements
29- advanceClock ( 1 ) ;
30-
3127 if ( pane ) return pane . itemForURI ( ResultsPaneView . URI ) ;
3228 }
3329
3430 function getResultsView ( ) {
3531 return getResultsPane ( ) . refs . resultsView ;
3632 }
3733
38- function buildResultsView ( ) {
34+ function buildResultsView ( options = { } ) {
3935 const FindOptions = require ( "../lib/find-options" )
4036 const ResultsModel = require ( "../lib/project/results-model" )
4137 const { Result } = ResultsModel
4238 const ResultsView = require ( "../lib/project/results-view" )
4339 const model = new ResultsModel ( new FindOptions ( { } ) , null )
4440 const resultsView = new ResultsView ( { model } )
45- model . addResult ( "/a/b.txt" , Result . create ( {
46- filePath : "/a/b.txt" ,
47- matches : [
48- {
49- lineText : "hello world" ,
50- matchText : "world" ,
51- range : { start : { row : 0 , column : 6 } , end : { row : 0 , column : 11 } } ,
52- leadingContextLines : [ ] ,
53- trailingContextLines : [ ]
54- }
55- ]
56- } ) )
57- model . addResult ( "/c/d.txt" , Result . create ( {
58- filePath : "/c/d.txt" ,
59- matches : [
60- {
61- lineText : "goodnight moon" ,
62- matchText : "night" ,
63- range : { start : { row : 0 , column : 4 } , end : { row : 0 , column : 8 } } ,
64- leadingContextLines : [ ] ,
65- trailingContextLines : [ ]
66- }
67- ]
68- } ) )
41+
42+ if ( ! options . empty ) {
43+ model . addResult ( "/a/b.txt" , Result . create ( {
44+ filePath : "/a/b.txt" ,
45+ matches : [
46+ {
47+ lineText : "hello world" ,
48+ matchText : "world" ,
49+ range : { start : { row : 0 , column : 6 } , end : { row : 0 , column : 11 } } ,
50+ leadingContextLines : [ ] ,
51+ trailingContextLines : [ ]
52+ }
53+ ]
54+ } ) )
55+ model . addResult ( "/c/d.txt" , Result . create ( {
56+ filePath : "/c/d.txt" ,
57+ matches : [
58+ {
59+ lineText : "goodnight moon" ,
60+ matchText : "night" ,
61+ range : { start : { row : 0 , column : 4 } , end : { row : 0 , column : 8 } } ,
62+ leadingContextLines : [ ] ,
63+ trailingContextLines : [ ]
64+ }
65+ ]
66+ } ) )
67+ }
68+
6969 return resultsView
7070 }
7171
@@ -97,7 +97,6 @@ describe('ResultsView', () => {
9797 await searchPromise ;
9898
9999 resultsView = getResultsView ( ) ;
100- await resultsView . heightInvalidationPromise ;
101100 expect ( resultsView . refs . listView . element . querySelector ( '.path-name' ) . textContent ) . toBe ( "one-long-line.coffee" ) ;
102101 expect ( resultsView . refs . listView . element . querySelectorAll ( '.preview' ) . length ) . toBe ( 1 ) ;
103102 expect ( resultsView . refs . listView . element . querySelector ( '.preview' ) . textContent ) . toBe ( 'test test test test test test test test test test test a b c d e f g h i j k l abcdefghijklmnopqrstuvwxyz' ) ;
@@ -116,7 +115,6 @@ describe('ResultsView', () => {
116115 await searchPromise ;
117116
118117 resultsView = getResultsView ( ) ;
119- await resultsView . heightInvalidationPromise ;
120118 expect ( resultsView . refs . listView . element . querySelector ( '.path-name' ) . textContent ) . toBe ( path . join ( "project" , "one-long-line.coffee" ) ) ;
121119 } ) ;
122120 } ) ;
@@ -135,7 +133,6 @@ describe('ResultsView', () => {
135133 await searchPromise ;
136134
137135 resultsView = getResultsView ( ) ;
138- await resultsView . heightInvalidationPromise ;
139136 expect ( resultsView . refs . listView . element . querySelector ( '.path-name' ) . textContent ) . toBe ( "one-long-line.coffee" ) ;
140137 expect ( resultsView . refs . listView . element . querySelectorAll ( '.preview' ) . length ) . toBe ( 1 ) ;
141138 expect ( resultsView . refs . listView . element . querySelector ( '.match' ) . textContent ) . toBe ( 'ghijkl' ) ;
@@ -147,7 +144,6 @@ describe('ResultsView', () => {
147144 await searchPromise ;
148145
149146 resultsView = getResultsView ( ) ;
150- await resultsView . heightInvalidationPromise ;
151147 expect ( resultsView . refs . listView . element . querySelector ( '.match' ) . textContent ) . toBe ( 'ghijkl' ) ;
152148 expect ( resultsView . refs . listView . element . querySelector ( '.match' ) ) . toHaveClass ( 'highlight-info' ) ;
153149 expect ( resultsView . refs . listView . element . querySelector ( '.replacement' ) . textContent ) . toBe ( '' ) ;
@@ -179,7 +175,6 @@ describe('ResultsView', () => {
179175 await searchPromise ;
180176
181177 resultsView = getResultsView ( ) ;
182- await resultsView . heightInvalidationPromise ;
183178 const listElement = resultsView . refs . listView . element ;
184179 expect ( listElement . querySelectorAll ( '.match' ) [ 0 ] . textContent ) . toBe ( 'function ()' ) ;
185180 expect ( listElement . querySelectorAll ( '.replacement' ) [ 0 ] . textContent ) . toBe ( '() =>' ) ;
@@ -198,7 +193,6 @@ describe('ResultsView', () => {
198193 await searchPromise ;
199194
200195 resultsView = getResultsView ( ) ;
201- await resultsView . heightInvalidationPromise ;
202196 const { listView} = resultsView . refs ;
203197 expect ( listView . element . scrollTop ) . toBe ( 0 ) ;
204198 expect ( listView . element . scrollHeight ) . toBeGreaterThan ( listView . element . offsetHeight ) ;
@@ -303,7 +297,6 @@ describe('ResultsView', () => {
303297 projectFindView . confirm ( ) ;
304298 await searchPromise ;
305299 resultsView = getResultsView ( ) ;
306- await resultsView . heightInvalidationPromise ;
307300 } ) ;
308301
309302 it ( "selects the first/last item when core:move-to-top/move-to-bottom is triggered" , async ( ) => {
@@ -343,7 +336,6 @@ describe('ResultsView', () => {
343336 await searchPromise ;
344337
345338 resultsView = getResultsView ( ) ;
346- await resultsView . heightInvalidationPromise ;
347339
348340 resultsView . moveDown ( ) ;
349341 resultsView . moveDown ( ) ;
@@ -382,7 +374,6 @@ describe('ResultsView', () => {
382374 await searchPromise ;
383375
384376 resultsView = getResultsView ( ) ;
385- await resultsView . heightInvalidationPromise ;
386377
387378 await resultsView . collapseResult ( ) ;
388379 expect ( resultsView . element . querySelector ( '.collapsed' ) ) . not . toBe ( null ) ;
@@ -450,7 +441,6 @@ describe('ResultsView', () => {
450441 await searchPromise ;
451442
452443 resultsView = getResultsView ( ) ;
453- await resultsView . heightInvalidationPromise ;
454444 resultsView . selectFirstResult ( ) ;
455445 } ) ;
456446
@@ -546,7 +536,6 @@ describe('ResultsView', () => {
546536 await searchPromise ;
547537
548538 resultsView = getResultsView ( ) ;
549- await resultsView . heightInvalidationPromise ;
550539
551540 let { length : resultCount } = resultsView . refs . listView . element . querySelectorAll ( ".match-row" ) ;
552541 expect ( resultCount ) . toBe ( 11 ) ;
@@ -594,7 +583,6 @@ describe('ResultsView', () => {
594583 atom . commands . dispatch ( projectFindView . element , 'core:confirm' ) ;
595584 await searchPromise ;
596585 resultsView = getResultsView ( ) ;
597- await resultsView . heightInvalidationPromise ;
598586 } ) ;
599587
600588 it ( "shows the preview-controls" , ( ) => {
@@ -660,11 +648,7 @@ describe('ResultsView', () => {
660648
661649 describe ( "when the results view is empty" , ( ) => {
662650 it ( "ignores core:confirm and other commands for selecting results" , async ( ) => {
663- projectFindView . findEditor . setText ( 'thiswillnotmatchanythingintheproject' ) ;
664- atom . commands . dispatch ( projectFindView . element , 'core:confirm' ) ;
665- await searchPromise ;
666- resultsView = getResultsView ( ) ;
667- await resultsView . heightInvalidationPromise ;
651+ const resultsView = buildResultsView ( { empty : true } ) ;
668652 atom . commands . dispatch ( resultsView . element , 'core:confirm' ) ;
669653 atom . commands . dispatch ( resultsView . element , 'core:move-down' ) ;
670654 atom . commands . dispatch ( resultsView . element , 'core:move-up' ) ;
@@ -675,10 +659,8 @@ describe('ResultsView', () => {
675659 } ) ;
676660
677661 it ( "won't show the preview-controls" , async ( ) => {
678- projectFindView . findEditor . setText ( 'thiswillnotmatchanythingintheproject' ) ;
679- atom . commands . dispatch ( projectFindView . element , 'core:confirm' ) ;
680- await searchPromise ;
681- expect ( getResultsPane ( ) . refs . previewControls . style . display ) . toBe ( 'none' ) ;
662+ const resultsPane = new ResultsPaneView ( ) ;
663+ expect ( resultsPane . refs . previewControls . style . display ) . toBe ( 'none' ) ;
682664 } ) ;
683665 } ) ;
684666
@@ -759,7 +741,6 @@ describe('ResultsView', () => {
759741 await searchPromise ;
760742
761743 resultsView = getResultsView ( ) ;
762- await resultsView . heightInvalidationPromise ;
763744 let fileIconClasses = Array . from ( resultsView . refs . listView . element . querySelectorAll ( '.path-row .icon' ) ) . map ( el => el . className ) ;
764745 expect ( fileIconClasses ) . toContain ( 'first-icon-class second-icon-class icon' ) ;
765746 expect ( fileIconClasses ) . toContain ( 'third-icon-class fourth-icon-class icon' ) ;
@@ -939,7 +920,6 @@ describe('ResultsView', () => {
939920 await searchPromise ;
940921
941922 resultsView = getResultsView ( ) ;
942- await resultsView . heightInvalidationPromise ;
943923 } ) ;
944924
945925 it ( 'maintains selected result when adding and removing results' , async ( ) => {
0 commit comments