@@ -9,17 +9,11 @@ import { LibraryItem } from '../src/components/LibraryItem';
9
9
import { ItemData } from "../src/LibraryUtilities" ;
10
10
import { createLibraryItem } from "../src/utils" ;
11
11
import * as Adapter from 'enzyme-adapter-react-16' ;
12
- import { expect , assert } from 'chai' ;
12
+ import { expect } from 'chai' ;
13
13
import { LibraryContainer } from '../src/components/LibraryContainer' ;
14
14
15
15
configure ( { adapter : new Adapter ( ) } ) ;
16
16
17
- describe ( "sample test" , function ( ) {
18
- it ( "should add two numbers" , function ( ) {
19
- expect ( 1 + 2 ) . to . equal ( 3 ) ;
20
- } ) ;
21
- } ) ;
22
-
23
17
describe ( "LibraryContainer UI" , function ( ) {
24
18
let loadedTypesJson : any ;
25
19
let layoutSpecsJson : any ;
@@ -156,27 +150,25 @@ describe("LibraryContainer UI", function () {
156
150
libController . setLoadedTypesJson ( loadedTypesJson , false ) ;
157
151
libController . setLayoutSpecsJson ( layoutSpecsJson , false ) ;
158
152
libController . refreshLibraryView ( ) ;
153
+ libContainer . update ( ) ;
159
154
160
155
} )
161
156
162
- xit ( "scrollToElement should be called when libraryItem is expanded only" , function ( ) {
157
+ it ( "scrollToElement should be called when libraryItem is expanded only" , function ( ) {
163
158
159
+ let scrolled = false ;
164
160
let header = libContainer . find ( 'div.LibraryItemHeader' ) . at ( 0 ) ;
165
161
expect ( header ) . to . have . lengthOf ( 1 ) ;
166
- let count = 0 ;
167
162
168
163
//replace the scroll method with a method which ends the test.
169
- ( libContainer . getNode ( ) as unknown as LibraryContainer ) . scrollToExpandedItem = ( ) => { count = count + 1 ; }
170
- header . simulate ( 'click' ) ;
164
+ ( libContainer . instance ( ) as unknown as LibraryContainer ) . scrollToExpandedItem = ( ) => { scrolled = ! scrolled ; }
171
165
header . simulate ( 'click' ) ;
172
- assert . equal ( count , 1 ) ;
166
+ expect ( scrolled ) . to . be . true ;
173
167
174
168
} ) ;
175
169
176
170
177
- // Test uses timeout function and testframework knows
178
- // when to complete the test bases on calling funciton 'done()'
179
- xit ( "search a string in library and verify change of state and results" , function ( done ) {
171
+ it ( "search a string in library and verify change of state and results" , function ( ) {
180
172
181
173
// find is used to find a rendered component by css selectors,
182
174
// component constructors, display name or property selector.
@@ -187,23 +179,18 @@ describe("LibraryContainer UI", function () {
187
179
188
180
// Search is triggered after a timeout of 300 milli seconds
189
181
// So wait before verifying the results
190
-
191
182
setTimeout ( function ( ) {
192
183
// Verify the state 'inSearchMode' is changed
193
184
expect ( libContainer . state ( 'inSearchMode' ) ) . to . be . true ;
194
- //let result = libContainer.find('div.LibraryItemContainer');
195
185
// Verify the search results are correct
196
186
let value = libContainer . find ( 'SearchResultItem' ) ;
197
187
expect ( value ) . to . have . lengthOf ( 2 ) ;
198
188
expect ( ( value . at ( 0 ) . props ( ) as any ) . data . text ) . to . equal ( "Child1" ) ;
199
189
expect ( ( value . at ( 1 ) . props ( ) as any ) . data . text ) . to . equal ( "Child2" ) ;
200
- done ( ) ; // For testframework to figure out when to complete this test
201
190
} , 500 ) ;
202
191
} ) ;
203
192
204
- // Test uses timeout function and testframework knows
205
- // when to complete the test bases on calling funciton 'done()'
206
- xit ( "search a negative scenario for search" , function ( done ) {
193
+ it ( "search a negative scenario for search" , function ( ) {
207
194
208
195
// find is used to find a rendered component by css selectors,
209
196
// component constructors, display name or property selector.
@@ -221,11 +208,10 @@ describe("LibraryContainer UI", function () {
221
208
// Verify the search does not return any nodes
222
209
let value = libContainer . find ( 'SearchResultItem' ) ;
223
210
expect ( value ) . to . have . lengthOf ( 0 ) ;
224
- done ( ) ; // For testframework to figure out when to complete this test
225
211
} , 500 ) ;
226
212
} ) ;
227
213
228
- xit ( "change state of searchbar to detail view and verify the search results display item description" , function ( done ) {
214
+ it ( "change state of searchbar to detail view and verify the search results display item description" , function ( ) {
229
215
230
216
// Trigger the search so the option for detail view is enabled
231
217
let text = ( ) => libContainer . find ( 'input.SearchInputText' ) ;
@@ -251,11 +237,10 @@ describe("LibraryContainer UI", function () {
251
237
expect ( describe ) . to . have . lengthOf ( 2 ) ;
252
238
expect ( describe . at ( 0 ) . text ( ) ) . to . equal ( 'First item' ) ;
253
239
expect ( describe . at ( 1 ) . text ( ) ) . to . equal ( 'Second item' ) ;
254
- done ( ) ; // For testframework to know when to terminate execution
255
240
} , 500 ) ;
256
241
} ) ;
257
242
258
- xit ( "search bar should not contain structured view button" , function ( ) {
243
+ it ( "search bar should not contain structured view button" , function ( ) {
259
244
260
245
let buttons = libContainer . find ( 'button' ) ;
261
246
//detail view, filter.
@@ -273,7 +258,7 @@ describe("LibraryContainer UI", function () {
273
258
274
259
} ) ;
275
260
276
- xit ( "click item text on search should return to the library item" , function ( done ) {
261
+ it ( "click item text on search should return to the library item" , function ( ) {
277
262
278
263
// Trigger the search so the option for detail view is enabled
279
264
let text = ( ) => libContainer . find ( 'input.SearchInputText' ) ;
@@ -301,31 +286,18 @@ describe("LibraryContainer UI", function () {
301
286
//click the item text
302
287
detials . at ( 0 ) . simulate ( 'click' ) ;
303
288
expect ( ( value . at ( 0 ) . props ( ) as any ) . data . pathToItem [ 0 ] . expanded ) . to . be . true ;
304
- done ( ) ;
305
289
} , 500 ) ;
306
290
} ) ;
307
291
308
- xit ( "coregroup items should auto expand" , function ( ) {
309
-
310
- let header = libContainer . find ( 'div.LibraryItemHeader' ) . at ( 0 ) ;
311
- expect ( header ) . to . have . lengthOf ( 1 ) ;
312
-
313
- header . simulate ( 'click' ) ;
314
-
315
- let libraryItem = libContainer . find ( 'LibraryItem' ) as any ;
316
- expect ( libraryItem . nodes [ 2 ] . props . data . expanded ) . to . be . true ;
317
-
318
- } ) ;
319
-
320
- it ( "add-ons should auto expand" , function ( ) {
292
+ it ( "add-ons should auto expand" , function ( ) {
321
293
322
- let generatedSections = libContainer . instance ( ) . generatedSections ;
323
- expect ( generatedSections ) . to . have . lengthOf ( 2 ) ;
324
- if ( ! generatedSections ) return ;
325
- expect ( generatedSections [ 1 ] . text ) . to . equal ( "Add-ons" ) ;
326
- expect ( generatedSections [ 1 ] . expanded ) . to . be . true ;
327
-
328
- } ) ;
294
+ let generatedSections = libContainer . instance ( ) . generatedSections ;
295
+ expect ( generatedSections ) . to . have . lengthOf ( 2 ) ;
296
+ if ( ! generatedSections ) return ;
297
+ expect ( generatedSections [ 1 ] . text ) . to . equal ( "Add-ons" ) ;
298
+ expect ( generatedSections [ 1 ] . expanded ) . to . be . true ;
299
+
300
+ } ) ;
329
301
} )
330
302
331
303
} ) ;
0 commit comments