@@ -12,14 +12,14 @@ import { MockLogger } from "../test_utils";
12
12
const fixturePath = path . join ( __dirname , ".." , ".." , ".." , "test" , "fixtures" ) ;
13
13
14
14
function assertFoldingRegions ( result , expected ) : void {
15
- assert . equal ( result . length , expected . length ) ;
16
-
17
15
for ( let i = 0 ; i < expected . length ; i ++ ) {
18
16
const failMessage = `expected ${ JSON . stringify ( expected [ i ] ) } , actual ${ JSON . stringify ( result [ i ] ) } ` ;
19
17
assert . equal ( result [ i ] . start , expected [ i ] . start , failMessage ) ;
20
18
assert . equal ( result [ i ] . end , expected [ i ] . end , failMessage ) ;
21
19
assert . equal ( result [ i ] . kind , expected [ i ] . kind , failMessage ) ;
22
20
}
21
+
22
+ assert . equal ( result . length , expected . length ) ;
23
23
}
24
24
25
25
suite ( "Features" , ( ) => {
@@ -36,14 +36,8 @@ suite("Features", () => {
36
36
assert . notEqual ( psGrammar , null ) ;
37
37
} ) ;
38
38
39
- test ( "Can detect all of the foldable regions in a document with CRLF line endings" , async ( ) => {
40
- // Integration test against the test fixture 'folding-crlf.ps1' that contains
41
- // all of the different types of folding available
42
- const uri = vscode . Uri . file ( path . join ( fixturePath , "folding-crlf.ps1" ) ) ;
43
- const document = await vscode . workspace . openTextDocument ( uri ) ;
44
- const result = await provider . provideFoldingRanges ( document , null , null ) ;
45
-
46
- const expected = [
39
+ suite ( "For a single document" , async ( ) => {
40
+ const expectedFoldingRegions = [
47
41
{ start : 1 , end : 6 , kind : 1 } ,
48
42
{ start : 7 , end : 51 , kind : 3 } ,
49
43
{ start : 8 , end : 13 , kind : 1 } ,
@@ -56,30 +50,33 @@ suite("Features", () => {
56
50
{ start : 47 , end : 50 , kind : 3 } ,
57
51
] ;
58
52
59
- assertFoldingRegions ( result , expected ) ;
60
- } ) ;
53
+ test ( "Can detect all of the foldable regions in a document with CRLF line endings" , async ( ) => {
54
+ // Integration test against the test fixture 'folding-crlf.ps1' that contains
55
+ // all of the different types of folding available
56
+ const uri = vscode . Uri . file ( path . join ( fixturePath , "folding-crlf.ps1" ) ) ;
57
+ const document = await vscode . workspace . openTextDocument ( uri ) ;
58
+ const result = await provider . provideFoldingRanges ( document , null , null ) ;
61
59
62
- test ( "Can detect all of the foldable regions in a document with LF line endings" , async ( ) => {
63
- // Integration test against the test fixture 'folding-lf.ps1' that contains
64
- // all of the different types of folding available
65
- const uri = vscode . Uri . file ( path . join ( fixturePath , "folding-lf.ps1" ) ) ;
66
- const document = await vscode . workspace . openTextDocument ( uri ) ;
67
- const result = await provider . provideFoldingRanges ( document , null , null ) ;
60
+ // Ensure we have CRLF line endings as we're depending on git
61
+ // to clone the test fixtures correctly
62
+ assert . notEqual ( document . getText ( ) . indexOf ( "\r\n" ) , - 1 ) ;
68
63
69
- const expected = [
70
- { start : 1 , end : 6 , kind : 1 } ,
71
- { start : 7 , end : 51 , kind : 3 } ,
72
- { start : 8 , end : 13 , kind : 1 } ,
73
- { start : 14 , end : 17 , kind : 3 } ,
74
- { start : 19 , end : 22 , kind : 3 } ,
75
- { start : 26 , end : 28 , kind : 1 } ,
76
- { start : 30 , end : 40 , kind : 3 } ,
77
- { start : 32 , end : 36 , kind : 3 } ,
78
- { start : 42 , end : 44 , kind : 3 } ,
79
- { start : 47 , end : 50 , kind : 3 } ,
80
- ] ;
64
+ assertFoldingRegions ( result , expectedFoldingRegions ) ;
65
+ } ) ;
66
+
67
+ test ( "Can detect all of the foldable regions in a document with LF line endings" , async ( ) => {
68
+ // Integration test against the test fixture 'folding-lf.ps1' that contains
69
+ // all of the different types of folding available
70
+ const uri = vscode . Uri . file ( path . join ( fixturePath , "folding-lf.ps1" ) ) ;
71
+ const document = await vscode . workspace . openTextDocument ( uri ) ;
72
+ const result = await provider . provideFoldingRanges ( document , null , null ) ;
73
+
74
+ // Ensure we do not CRLF line endings as we're depending on git
75
+ // to clone the test fixtures correctly
76
+ assert . equal ( document . getText ( ) . indexOf ( "\r\n" ) , - 1 ) ;
81
77
82
- assertFoldingRegions ( result , expected ) ;
78
+ assertFoldingRegions ( result , expectedFoldingRegions ) ;
79
+ } ) ;
83
80
} ) ;
84
81
} ) ;
85
82
} ) ;
0 commit comments