Skip to content

Commit 0f65eb4

Browse files
committed
modify expected jsx regex on generator test cases
1 parent ee048ce commit 0f65eb4

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

test/generators/coffee_component_generator_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ def class_name
4040
end
4141

4242
test 'that it generates working jsx' do
43-
expected_name_div = /\.createElement\(\s*"div",\s*null,\s*"Name:\s*",\s*this\.props\.name\s*\)/x
44-
expected_shape_div = /\.createElement\(\s*"div",\s*null,\s*"Address:\s*",\s*this\.props\.address\s*\)/x
45-
4643
run_generator %w(GeneratedComponent name:string address:shape --coffee)
4744
jsx = React::JSX.transform(CoffeeScript.compile(File.read(File.join(destination_root, filename))))
4845

49-
assert_match(Regexp.new(expected_name_div), jsx)
50-
assert_match(Regexp.new(expected_shape_div), jsx)
46+
assert_match(Regexp.new(expected_working_jsx), jsx)
5147
end
5248
end

test/generators/component_generator_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ def filename
5858
end
5959

6060
test 'generates working jsx' do
61-
expected_name_div = /\.createElement\(\s*"div",\s*null,\s*\"Name:\s*\",\s*this\.props\.name\s*\)/x
62-
expected_shape_div = /\.createElement\(\s*"div",\s*null,\s*\"Address:\s*\",\s*this\.props\.address\s*\)/x
63-
6461
run_generator %w(GeneratedComponent name:string address:shape)
6562
jsx = React::JSX.transform(File.read(File.join(destination_root, filename)))
6663

67-
assert_match(Regexp.new(expected_name_div), jsx)
68-
assert_match(Regexp.new(expected_shape_div), jsx)
64+
assert_match(Regexp.new(expected_working_jsx), jsx)
6965
end
7066
end

test/generators/es6_component_generator_test.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@ def class_name
3434
end
3535

3636
test 'generates working jsx' do
37-
expected_name_div = /\.createElement\(\s*"div",\s*null,\s*\"Name:\s*\",\s*this\.props\.name\s*\)/x
38-
expected_shape_div = /\.createElement\(\s*"div",\s*null,\s*\"Address:\s*\",\s*this\.props\.address\s*\)/x
39-
4037
run_generator %w(GeneratedComponent name:string address:shape --es6)
4138
jsx = React::JSX.transform(File.read(File.join(destination_root, filename)))
4239

43-
assert_match(Regexp.new(expected_name_div), jsx)
44-
assert_match(Regexp.new(expected_shape_div), jsx)
40+
assert_match(Regexp.new(expected_working_jsx), jsx)
4541
end
4642
end

test/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ def when_stateful_js_context_available
120120
end
121121
end
122122

123+
def expected_working_jsx
124+
/\.createElement\(\s*\S*\.Fragment,\s*null,\s*\"Name:\s*\",\s*this\.props\.name,\s*\"Address:\s*\",\s*this\.props\.address\s*\)/x
125+
end
126+
123127
module ParamsHelper
124128
# Normalize params for Rails 5.1+
125129
def query_params(params)

0 commit comments

Comments
 (0)