|
5 | 5 | describe Ruby2JS::Filter::CJS do
|
6 | 6 |
|
7 | 7 | def to_js( string)
|
8 |
| - Ruby2JS.convert(string, filters: [Ruby2JS::Filter::CJS], |
9 |
| - file: __FILE__, eslevel: 2017) |
| 8 | + _(Ruby2JS.convert(string, filters: [Ruby2JS::Filter::CJS], |
| 9 | + file: __FILE__, eslevel: 2017).to_s) |
10 | 10 | end
|
11 | 11 |
|
12 | 12 | def to_js_fn( string)
|
13 |
| - Ruby2JS.convert(string, |
| 13 | + _(Ruby2JS.convert(string, |
14 | 14 | filters: [Ruby2JS::Filter::CJS, Ruby2JS::Filter::Functions],
|
15 |
| - file: __FILE__, eslevel: 2017) |
| 15 | + file: __FILE__, eslevel: 2017).to_s) |
16 | 16 | end
|
17 | 17 |
|
18 | 18 | describe :exports do
|
19 | 19 | it "should export a simple function" do
|
20 |
| - to_js( 'export def f(a); return a; end' ).to_s. |
| 20 | + to_js( 'export def f(a); return a; end' ). |
21 | 21 | must_equal 'exports.f = a => a'
|
22 | 22 | end
|
23 | 23 |
|
24 | 24 | it "should export an async function" do
|
25 |
| - to_js( 'export async def f(a, b); return a; end' ).to_s. |
| 25 | + to_js( 'export async def f(a, b); return a; end' ). |
26 | 26 | must_equal 'exports.f = async (a, b) => a'
|
27 | 27 | end
|
28 | 28 |
|
29 | 29 | it "should export a value" do
|
30 |
| - to_js( 'export foo = 1' ).to_s. |
| 30 | + to_js( 'export foo = 1' ). |
31 | 31 | must_equal 'exports.foo = 1'
|
32 | 32 | end
|
33 | 33 |
|
34 | 34 | it "should convert .inspect into JSON.stringify()" do
|
35 |
| - to_js_fn( 'export async def f(a, b); return {input: a}.inspect; end' ).to_s. |
| 35 | + to_js_fn( 'export async def f(a, b); return {input: a}.inspect; end' ). |
36 | 36 | must_equal 'exports.f = async (a, b) => JSON.stringify({input: a})'
|
37 | 37 | end
|
38 | 38 | end
|
39 | 39 |
|
40 | 40 | describe :default do
|
41 | 41 | it "should export a simple function" do
|
42 |
| - to_js( 'export default proc do |a|; return a; end' ).to_s. |
| 42 | + to_js( 'export default proc do |a|; return a; end' ). |
43 | 43 | must_equal 'module.exports = a => a'
|
44 | 44 | end
|
45 | 45 |
|
46 | 46 | it "should export an async function" do
|
47 |
| - to_js( 'export default async proc do |a, b| return a; end' ).to_s. |
| 47 | + to_js( 'export default async proc do |a, b| return a; end' ). |
48 | 48 | must_equal 'module.exports = async (a, b) => a'
|
49 | 49 | end
|
50 | 50 |
|
51 | 51 | it "should export a value" do
|
52 |
| - to_js( 'export default 1' ).to_s. |
| 52 | + to_js( 'export default 1' ). |
53 | 53 | must_equal 'module.exports = 1'
|
54 | 54 | end
|
55 | 55 | end
|
56 | 56 |
|
57 | 57 | describe Ruby2JS::Filter::DEFAULTS do
|
58 | 58 | it "should include CJS" do
|
59 |
| - Ruby2JS::Filter::DEFAULTS.must_include Ruby2JS::Filter::CJS |
| 59 | + _(Ruby2JS::Filter::DEFAULTS).must_include Ruby2JS::Filter::CJS |
60 | 60 | end
|
61 | 61 | end
|
62 | 62 | end
|
0 commit comments