@@ -13,29 +13,36 @@ var indexOfPageInResults = function(pageName, results) {
1313 }
1414} ;
1515
16- /* Clear local storage */
17- window . localStorage . clear ( ) ;
18-
19- /* Render the search templates into the page */
20- var qunitFixture = document . getElementById ( 'qunit-fixture' ) ;
21- qunitFixture . appendChild ( searchBarTemplate ( ) ) ;
22- qunitFixture . appendChild ( searchResultsTemplate ( ) ) ;
23-
24- /* Create a new instance of the search control */
25- var search = new SearchControl ( '.search-bar' , {
26- pathPrefix : '../doc'
27- } ) ;
16+ var search ;
17+ var setUpSearchControl ;
2818
2919/* Tests */
30- QUnit . module ( 'search control' ) ;
20+ QUnit . module ( 'search control' , {
21+ before : function ( ) {
22+
23+ /* Clear local storage */
24+ window . localStorage . clear ( ) ;
25+
26+ /* Render the search templates into the page */
27+ var qunitFixture = document . getElementById ( 'qunit-fixture' ) ;
28+ qunitFixture . appendChild ( searchBarTemplate ( ) ) ;
29+ qunitFixture . appendChild ( searchResultsTemplate ( ) ) ;
30+
31+ /* Create a new instance of the search control */
32+ search = new SearchControl ( '.search-bar' , {
33+ pathPrefix : '../doc'
34+ } ) ;
35+
36+ setUpSearchControl = search . searchEnginePromise . then ( function ( searchMap ) {
37+ return new Promise ( function ( resolve ) {
38+ // Wait for the search worker to be set up
39+ setTimeout ( function ( ) {
40+ resolve ( searchLogic . indexData ( search . convertSearchMapToIndexableItems ( searchMap ) ) ) ;
41+ } , 2000 ) ;
42+ } ) ;
43+ } ) ;
3144
32- var setUpSearchControl = search . searchEnginePromise . then ( function ( searchMap ) {
33- return new Promise ( function ( resolve ) {
34- // Wait for the search worker to be set up
35- setTimeout ( function ( ) {
36- resolve ( searchLogic . indexData ( search . convertSearchMapToIndexableItems ( searchMap ) ) ) ;
37- } , 2000 ) ;
38- } ) ;
45+ }
3946} ) ;
4047
4148QUnit . test ( 'Search results render' , function ( assert ) {
0 commit comments