@@ -11,23 +11,27 @@ import { expect } from 'chai';
11
11
import { describe , it } from 'mocha' ;
12
12
import { dedentBlockStringValue } from '../blockString' ;
13
13
14
+ function joinLines ( ...args ) {
15
+ return args . join ( '\n' ) ;
16
+ }
17
+
14
18
describe ( 'dedentBlockStringValue' , ( ) => {
15
19
it ( 'removes uniform indentation from a string' , ( ) => {
16
- const rawValue = [
20
+ const rawValue = joinLines (
17
21
'' ,
18
22
' Hello,' ,
19
23
' World!' ,
20
24
'' ,
21
25
' Yours,' ,
22
26
' GraphQL.' ,
23
- ] . join ( '\n' ) ;
27
+ ) ;
24
28
expect ( dedentBlockStringValue ( rawValue ) ) . to . equal (
25
- [ 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ] . join ( '\n ') ,
29
+ joinLines ( 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ) ,
26
30
) ;
27
31
} ) ;
28
32
29
33
it ( 'removes empty leading and trailing lines' , ( ) => {
30
- const rawValue = [
34
+ const rawValue = joinLines (
31
35
'' ,
32
36
'' ,
33
37
' Hello,' ,
@@ -37,14 +41,14 @@ describe('dedentBlockStringValue', () => {
37
41
' GraphQL.' ,
38
42
'' ,
39
43
'' ,
40
- ] . join ( '\n' ) ;
44
+ ) ;
41
45
expect ( dedentBlockStringValue ( rawValue ) ) . to . equal (
42
- [ 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ] . join ( '\n ') ,
46
+ joinLines ( 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ) ,
43
47
) ;
44
48
} ) ;
45
49
46
50
it ( 'removes blank leading and trailing lines' , ( ) => {
47
- const rawValue = [
51
+ const rawValue = joinLines (
48
52
' ' ,
49
53
' ' ,
50
54
' Hello,' ,
@@ -54,43 +58,43 @@ describe('dedentBlockStringValue', () => {
54
58
' GraphQL.' ,
55
59
' ' ,
56
60
' ' ,
57
- ] . join ( '\n' ) ;
61
+ ) ;
58
62
expect ( dedentBlockStringValue ( rawValue ) ) . to . equal (
59
- [ 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ] . join ( '\n ') ,
63
+ joinLines ( 'Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ) ,
60
64
) ;
61
65
} ) ;
62
66
63
67
it ( 'retains indentation from first line' , ( ) => {
64
- const rawValue = [
68
+ const rawValue = joinLines (
65
69
' Hello,' ,
66
70
' World!' ,
67
71
'' ,
68
72
' Yours,' ,
69
73
' GraphQL.' ,
70
- ] . join ( '\n' ) ;
74
+ ) ;
71
75
expect ( dedentBlockStringValue ( rawValue ) ) . to . equal (
72
- [ ' Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ] . join ( '\n ') ,
76
+ joinLines ( ' Hello,' , ' World!' , '' , 'Yours,' , ' GraphQL.' ) ,
73
77
) ;
74
78
} ) ;
75
79
76
80
it ( 'does not alter trailing spaces' , ( ) => {
77
- const rawValue = [
81
+ const rawValue = joinLines (
78
82
' ' ,
79
83
' Hello, ' ,
80
84
' World! ' ,
81
85
' ' ,
82
86
' Yours, ' ,
83
87
' GraphQL. ' ,
84
88
' ' ,
85
- ] . join ( '\n' ) ;
89
+ ) ;
86
90
expect ( dedentBlockStringValue ( rawValue ) ) . to . equal (
87
- [
91
+ joinLines (
88
92
'Hello, ' ,
89
93
' World! ' ,
90
94
' ' ,
91
95
'Yours, ' ,
92
96
' GraphQL. ' ,
93
- ] . join ( '\n' ) ,
97
+ ) ,
94
98
) ;
95
99
} ) ;
96
100
} ) ;
0 commit comments