1+ // The module 'assert' provides assertion methods from node
2+ import * as assert from 'assert' ;
3+
4+ // You can import and use all API from the 'vscode' module
5+ // as well as import your extension to test it
6+ import * as vscode from 'vscode' ;
7+ import * as myExtension from '../src/extension' ;
8+
9+ import Parser from '../src/test_file_parser'
10+
11+ suite ( "File Parsing" , ( ) => {
12+
13+ test ( "For the simplest global case" , async ( ) => {
14+ let parser = new Parser ( )
15+ await parser . run ( __dirname + "/../../test/fixtures/global_its.js" )
16+ assert . equal ( parser . itBlocks . length , 2 )
17+
18+ let firstIt = parser . itBlocks [ 0 ]
19+ assert . equal ( firstIt . name , "works with old functions" )
20+ assert . notStrictEqual ( firstIt . start , { line : 1 , column : 0 } )
21+ assert . notStrictEqual ( firstIt . end , { line : 3 , column : 0 } )
22+
23+ let secondIt = parser . itBlocks [ 1 ]
24+ assert . equal ( secondIt . name , "works with new functions" )
25+ assert . notStrictEqual ( secondIt . start , { line : 5 , column : 0 } )
26+ assert . notStrictEqual ( secondIt . end , { line : 7 , column : 0 } )
27+ } ) ;
28+
29+ test ( "For its inside describes" , async ( ) => {
30+ let parser = new Parser ( )
31+ await parser . run ( __dirname + "/../../test/fixtures/nested_its.js" )
32+ assert . equal ( parser . itBlocks . length , 3 )
33+
34+ let firstIt = parser . itBlocks [ 0 ]
35+ assert . equal ( firstIt . name , "1" )
36+ assert . deepEqual ( firstIt . start , { line : 2 , column : 4 } )
37+ assert . deepEqual ( firstIt . end , { line : 3 , column : 6 } )
38+
39+ let secondIt = parser . itBlocks [ 1 ]
40+ assert . equal ( secondIt . name , "2" )
41+ assert . deepEqual ( secondIt . start , { line : 4 , column : 4 } )
42+ assert . deepEqual ( secondIt . end , { line : 5 , column : 6 } )
43+
44+ let thirdIt = parser . itBlocks [ 2 ]
45+ assert . equal ( thirdIt . name , "3" )
46+ assert . deepEqual ( thirdIt . start , { line : 9 , column : 4 } )
47+ assert . deepEqual ( thirdIt . end , { line : 10 , column : 6 } )
48+ } ) ;
49+
50+ test ( "For a danger test file (which has flow annotations)" , async ( ) => {
51+ let parser = new Parser ( )
52+ await parser . run ( __dirname + "/../../test/fixtures/dangerjs/travis-ci.jstest.js" )
53+ assert . equal ( parser . itBlocks . length , 7 )
54+ } )
55+ } ) ;
0 commit comments