@@ -52,96 +52,158 @@ test "import an entire module for side effects only, without importing any bindi
52
52
eq toJS (input), output
53
53
54
54
test " import default member from module, adding the member to the current scope" , ->
55
- input = " import foo from 'lib'\n foo.fooMethod()"
56
- output = " import foo from 'lib';\n\n foo.fooMethod();"
55
+ input = """
56
+ import foo from 'lib'
57
+ foo.fooMethod()"""
58
+ output = """
59
+ import foo from 'lib';
60
+
61
+ foo.fooMethod();"""
57
62
eq toJS (input), output
58
63
59
64
test " import an entire module's contents as an alias, adding the alias to the current scope" , ->
60
- input = " import * as foo from 'lib'\n foo.fooMethod()"
61
- output = " import * as foo from 'lib';\n\n foo.fooMethod();"
65
+ input = """
66
+ import * as foo from 'lib'
67
+ foo.fooMethod()"""
68
+ output = """
69
+ import * as foo from 'lib';
70
+
71
+ foo.fooMethod();"""
62
72
eq toJS (input), output
63
73
64
74
test " import a single member of a module, adding the member to the current scope" , ->
65
- input = " import { foo } from 'lib'\n foo.fooMethod()"
66
- output = " import { foo } from 'lib';\n\n foo.fooMethod();"
75
+ input = """
76
+ import { foo } from 'lib'
77
+ foo.fooMethod()"""
78
+ output = """
79
+ import {
80
+ foo
81
+ } from 'lib';
82
+
83
+ foo.fooMethod();"""
67
84
eq toJS (input), output
68
85
69
86
test " import a single member of a module as an alias, adding the alias to the current scope" , ->
70
- input = " import { foo as bar } from 'lib'\n bar.barMethod()"
71
- output = " import { foo as bar } from 'lib';\n\n bar.barMethod();"
87
+ input = """
88
+ import { foo as bar } from 'lib'
89
+ bar.barMethod()"""
90
+ output = """
91
+ import {
92
+ foo as bar
93
+ } from 'lib';
94
+
95
+ bar.barMethod();"""
72
96
eq toJS (input), output
73
97
74
98
test " import a multiple members of a module, adding the members to the current scope" , ->
75
- input = " import { foo, bar } from 'lib'\n foo.fooMethod()\n bar.barMethod()"
76
- output = " import { foo, bar } from 'lib';\n\n foo.fooMethod();\n\n bar.barMethod();"
99
+ input = """
100
+ import { foo, bar } from 'lib'
101
+ foo.fooMethod()
102
+ bar.barMethod()"""
103
+ output = """
104
+ import {
105
+ foo,
106
+ bar
107
+ } from 'lib';
108
+
109
+ foo.fooMethod();
110
+
111
+ bar.barMethod();"""
77
112
eq toJS (input), output
78
113
79
114
test " import a multiple members of a module where some are aliased, adding the members or aliases to the current scope" , ->
80
- input = " import { foo, bar as baz } from 'lib'\n foo.fooMethod()\n baz.bazMethod()"
81
- output = " import { foo, bar as baz } from 'lib';\n\n foo.fooMethod();\n\n baz.bazMethod();"
115
+ input = """
116
+ import { foo, bar as baz } from 'lib'
117
+ foo.fooMethod()
118
+ baz.bazMethod()"""
119
+ output = """
120
+ import {
121
+ foo,
122
+ bar as baz
123
+ } from 'lib';
124
+
125
+ foo.fooMethod();
126
+
127
+ baz.bazMethod();"""
82
128
eq toJS (input), output
83
129
84
130
test " import default member and other members of a module, adding the members to the current scope" , ->
85
- input = " import foo, { bar, baz as qux } from 'lib'\n foo.fooMethod()\n bar.barMethod()\n qux.quxMethod()"
86
- output = " import foo, { bar, baz as qux } from 'lib';\n\n foo.fooMethod();\n\n bar.barMethod();\n\n qux.quxMethod();"
131
+ input = """
132
+ import foo, { bar, baz as qux } from 'lib'
133
+ foo.fooMethod()
134
+ bar.barMethod()
135
+ qux.quxMethod()"""
136
+ output = """
137
+ import foo, {
138
+ bar,
139
+ baz as qux
140
+ } from 'lib';
141
+
142
+ foo.fooMethod();
143
+
144
+ bar.barMethod();
145
+
146
+ qux.quxMethod();"""
87
147
eq toJS (input), output
88
148
89
149
test " import default member from a module as well as the entire module's contents as an alias, adding the member and alias to the current scope" , ->
90
- input = " import foo, * as bar from 'lib'\n foo.fooMethod()\n bar.barMethod()"
91
- output = " import foo, * as bar from 'lib';\n\n foo.fooMethod();\n\n bar.barMethod();"
150
+ input = """
151
+ import foo, * as bar from 'lib'
152
+ foo.fooMethod()
153
+ bar.barMethod()"""
154
+ output = """
155
+ import foo, * as bar from 'lib';
156
+
157
+ foo.fooMethod();
158
+
159
+ bar.barMethod();"""
92
160
eq toJS (input), output
93
161
94
162
test " multiline simple import" , ->
95
- input = """ import {
96
- foo,
97
- bar as baz
98
- } from 'lib'"""
99
- output = " import { foo, bar as baz } from 'lib';"
100
-
163
+ input = """
164
+ import {
165
+ foo,
166
+ bar as baz
167
+ } from 'lib'"""
168
+ output = """
169
+ import {
170
+ foo,
171
+ bar as baz
172
+ } from 'lib';"""
101
173
eq toJS (input), output
102
174
103
175
test " multiline complex import" , ->
104
- input = """ import foo, {
176
+ input = """
177
+ import foo, {
105
178
bar,
106
179
baz as qux
107
180
} from 'lib'"""
108
- output = " import foo, { bar, baz as qux } from 'lib';"
109
-
181
+ output = """
182
+ import foo, {
183
+ bar,
184
+ baz as qux
185
+ } from 'lib';"""
110
186
eq toJS (input), output
111
187
112
- # test "multiline simple import", ->
113
- # input = """import {
114
- # foo,
115
- # bar as baz
116
- # } from 'lib'"""
117
- # output = """import {
118
- # foo,
119
- # bar as baz
120
- # } from 'lib';"""
121
- # eq toJS(input), output
122
-
123
- # test "multiline complex import", ->
124
- # input = """import foo, {
125
- # bar,
126
- # baz as qux
127
- # } from 'lib'"""
128
- # output = """import foo, {
129
- # bar,
130
- # baz as qux
131
- # } from 'lib';"""
132
- # eq toJS(input), output
133
-
134
188
135
189
# Export statements
136
190
137
191
test " export named members within an object" , ->
138
192
input = " export { foo, bar }"
139
- output = " export { foo, bar };"
193
+ output = """
194
+ export {
195
+ foo,
196
+ bar
197
+ };"""
140
198
eq toJS (input), output
141
199
142
200
test " export named members as aliases, within an object" , ->
143
201
input = " export { foo as bar, baz as qux }"
144
- output = " export { foo as bar, baz as qux };"
202
+ output = """
203
+ export {
204
+ foo as bar,
205
+ baz as qux
206
+ };"""
145
207
eq toJS (input), output
146
208
147
209
test " export default expression" , ->
@@ -166,7 +228,11 @@ test "export default multiline function", ->
166
228
167
229
test " export default named member, within an object" , ->
168
230
input = " export { foo as default, bar }"
169
- output = " export { foo as default, bar };"
231
+ output = """
232
+ export {
233
+ foo as default,
234
+ bar
235
+ };"""
170
236
eq toJS (input), output
171
237
172
238
@@ -179,10 +245,18 @@ test "export an entire module's contents", ->
179
245
180
246
test " export members imported from another module" , ->
181
247
input = " export { foo, bar } from 'lib'"
182
- output = " export { foo, bar } from 'lib';"
248
+ output = """
249
+ export {
250
+ foo,
251
+ bar
252
+ } from 'lib';"""
183
253
eq toJS (input), output
184
254
185
255
test " export as aliases members imported from another module" , ->
186
256
input = " export { foo as bar, baz as qux } from 'lib'"
187
- output = " export { foo as bar, baz as qux } from 'lib';"
257
+ output = """
258
+ export {
259
+ foo as bar,
260
+ baz as qux
261
+ } from 'lib';"""
188
262
eq toJS (input), output
0 commit comments