|
1 | 1 | component extends="wheels.tests.Test" { |
2 | 2 |
|
3 | 3 | function setup() { |
4 | | - _controller = application.wirebox.getInstance( "wheels.Controller" ); |
| 4 | + _controller = controller(name = "ControllerWithModel"); |
5 | 5 | set(functionName = "checkBoxTag", encode = false); |
6 | 6 | set(functionName = "textField", encode = false); |
7 | 7 | set(functionName = "textFieldTag", encode = false); |
@@ -53,56 +53,49 @@ component extends="wheels.tests.Test" { |
53 | 53 | /* object based helpers */ |
54 | 54 |
|
55 | 55 | function test_custom_label_on_object_helper() { |
56 | | - tag = model("tag").findOne(order = "id"); |
57 | | - actual = _controller.textField(objectName = "tag", property = "name", label = "The Label:"); |
58 | | - expected = '<label for="tag-name">The Label:<input id="tag-name" maxlength="50" name="tag[name]" type="text" value="releases"></label>'; |
| 56 | + actual = _controller.textField(objectName = "user", property = "username", label = "The Label:"); |
| 57 | + expected = '<label for="user-username">The Label:<input id="user-username" maxlength="50" name="user[username]" type="text" value="tonyp"></label>'; |
59 | 58 | assert('actual eq expected'); |
60 | 59 | } |
61 | 60 |
|
62 | 61 | function test_custom_label_on_object_helper_and_overriding_id() { |
63 | | - tag = model("tag").findOne(order = "id"); |
64 | 62 | actual = _controller.textField( |
65 | | - objectName = "tag", |
66 | | - property = "name", |
| 63 | + objectName = "user", |
| 64 | + property = "username", |
67 | 65 | label = "The Label:", |
68 | 66 | id = "the-id" |
69 | 67 | ); |
70 | | - expected = '<label for="the-id">The Label:<input id="the-id" maxlength="50" name="tag[name]" type="text" value="releases"></label>'; |
| 68 | + expected = '<label for="the-id">The Label:<input id="the-id" maxlength="50" name="user[username]" type="text" value="tonyp"></label>'; |
71 | 69 | assert('actual eq expected'); |
72 | 70 | } |
73 | 71 |
|
74 | 72 | function test_blank_label_on_object_helper() { |
75 | | - tag = model("tag").findOne(order = "id"); |
76 | | - actual = _controller.textField(objectName = "tag", property = "name", label = ""); |
77 | | - expected = '<input id="tag-name" maxlength="50" name="tag[name]" type="text" value="releases">'; |
| 73 | + actual = _controller.textField(objectName = "user", property = "username", label = ""); |
| 74 | + expected = '<input id="user-username" maxlength="50" name="user[username]" type="text" value="tonyp">'; |
78 | 75 | assert('actual eq expected'); |
79 | 76 | } |
80 | 77 |
|
81 | 78 | function test_automatic_label_on_object_helper_with_around_placement() { |
82 | | - tag = model("tag").findOne(order = "id"); |
83 | | - actual = _controller.textField(objectName = "tag", property = "name", labelPlacement = "around"); |
84 | | - expected = '<label for="tag-name">Tag name<input id="tag-name" maxlength="50" name="tag[name]" type="text" value="releases"></label>'; |
| 79 | + actual = _controller.textField(objectName = "user", property = "username", labelPlacement = "around"); |
| 80 | + expected = '<label for="user-username">Username<input id="user-username" maxlength="50" name="user[username]" type="text" value="tonyp"></label>'; |
85 | 81 | assert('actual eq expected'); |
86 | 82 | } |
87 | 83 |
|
88 | 84 | function test_automatic_label_on_object_helper_with_before_placement() { |
89 | | - tag = model("tag").findOne(order = "id"); |
90 | | - actual = _controller.textField(objectName = "tag", property = "name", labelPlacement = "before"); |
91 | | - expected = '<label for="tag-name">Tag name</label><input id="tag-name" maxlength="50" name="tag[name]" type="text" value="releases">'; |
| 85 | + actual = _controller.textField(objectName = "user", property = "username", labelPlacement = "before"); |
| 86 | + expected = '<label for="user-username">Username</label><input id="user-username" maxlength="50" name="user[username]" type="text" value="tonyp">'; |
92 | 87 | assert('actual eq expected'); |
93 | 88 | } |
94 | 89 |
|
95 | 90 | function test_automatic_label_on_object_helper_with_after_placement() { |
96 | | - tag = model("tag").findOne(order = "id"); |
97 | | - actual = _controller.textField(objectName = "tag", property = "name", labelPlacement = "after"); |
98 | | - expected = '<input id="tag-name" maxlength="50" name="tag[name]" type="text" value="releases"><label for="tag-name">Tag name</label>'; |
| 91 | + actual = _controller.textField(objectName = "user", property = "username", labelPlacement = "after") |
| 92 | + expected = '<input id="user-username" maxlength="50" name="user[username]" type="text" value="tonyp"><label for="user-username">Username</label>' |
99 | 93 | assert('actual eq expected'); |
100 | 94 | } |
101 | 95 |
|
102 | 96 | function test_automatic_label_on_object_helper_with_non_persisted_property() { |
103 | | - tag = model("tag").findOne(order = "id"); |
104 | | - actual = _controller.textField(objectName = "tag", property = "virtual"); |
105 | | - expected = '<label for="tag-virtual">Virtual property<input id="tag-virtual" name="tag[virtual]" type="text" value=""></label>'; |
| 97 | + actual = _controller.textField(objectName = "user", property = "virtual"); |
| 98 | + expected = '<label for="user-virtual">Virtual<input id="user-virtual" name="user[virtual]" type="text" value=""></label>'; |
106 | 99 | assert('actual eq expected'); |
107 | 100 | } |
108 | 101 |
|
|
0 commit comments