ultimate-helpers 0.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/.gitignore +8 -0
  2. data/.rvmrc +1 -0
  3. data/.rvmrc.example +1 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +126 -0
  6. data/LICENSE +19 -0
  7. data/README.md +25 -0
  8. data/Rakefile +1 -0
  9. data/app/assets/javascripts/ultimate/base.js.coffee +11 -0
  10. data/app/assets/javascripts/ultimate/helpers/asset_tag.js.coffee +82 -0
  11. data/app/assets/javascripts/ultimate/helpers/base.js.coffee +3 -0
  12. data/app/assets/javascripts/ultimate/helpers/decor.js.coffee +19 -0
  13. data/app/assets/javascripts/ultimate/helpers/form_options.js.coffee +106 -0
  14. data/app/assets/javascripts/ultimate/helpers/form_tag.js.coffee +175 -0
  15. data/app/assets/javascripts/ultimate/helpers/javascript.js.coffee +31 -0
  16. data/app/assets/javascripts/ultimate/helpers/number.js.coffee +600 -0
  17. data/app/assets/javascripts/ultimate/helpers/record_tag.js.coffee +81 -0
  18. data/app/assets/javascripts/ultimate/helpers/tag.js.coffee +91 -0
  19. data/app/assets/javascripts/ultimate/helpers/url.js.coffee +152 -0
  20. data/app/assets/javascripts/ultimate/helpers.js.coffee +122 -0
  21. data/app/assets/javascripts/ultimate/jquery.base.js.coffee +85 -0
  22. data/app/assets/javascripts/ultimate/underscore/underscore.inflection.js +176 -0
  23. data/app/assets/javascripts/ultimate/underscore/underscore.js +1204 -0
  24. data/app/assets/javascripts/ultimate/underscore/underscore.outcasts.js.coffee +158 -0
  25. data/app/assets/javascripts/ultimate/underscore/underscore.string.js +600 -0
  26. data/config/routes.rb +2 -0
  27. data/lib/ultimate/helpers/engine.rb +7 -0
  28. data/lib/ultimate/helpers/version.rb +5 -0
  29. data/lib/ultimate/helpers.rb +8 -0
  30. data/scripts/rails +8 -0
  31. data/test/dummy/Rakefile +7 -0
  32. data/test/dummy/_emfile +18 -0
  33. data/test/dummy/app/assets/images/.gitkeep +0 -0
  34. data/test/dummy/app/assets/javascripts/application.js +3 -0
  35. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  36. data/test/dummy/app/assets/stylesheets/global/forms.css.scss +65 -0
  37. data/test/dummy/app/assets/stylesheets/global/layout/footer.scss +18 -0
  38. data/test/dummy/app/assets/stylesheets/global/layout/header.scss +13 -0
  39. data/test/dummy/app/assets/stylesheets/global/layout/main-menu.scss +68 -0
  40. data/test/dummy/app/assets/stylesheets/global/layout.css.scss +46 -0
  41. data/test/dummy/app/assets/stylesheets/global/reserved.css.scss +79 -0
  42. data/test/dummy/app/assets/stylesheets/global/reset.css.scss +85 -0
  43. data/test/dummy/app/assets/stylesheets/global/structures.css.scss +9 -0
  44. data/test/dummy/app/assets/stylesheets/import/base.scss +36 -0
  45. data/test/dummy/app/assets/stylesheets/plugins/qunit.css.scss +3 -0
  46. data/test/dummy/app/controllers/application_controller.rb +4 -0
  47. data/test/dummy/app/controllers/main_controller.rb +8 -0
  48. data/test/dummy/app/helpers/application_helper.rb +2 -0
  49. data/test/dummy/app/mailers/.gitkeep +0 -0
  50. data/test/dummy/app/models/.gitkeep +0 -0
  51. data/test/dummy/app/views/application/_footer.html.haml +3 -0
  52. data/test/dummy/app/views/application/_header.html.haml +4 -0
  53. data/test/dummy/app/views/application/_main_menu.html.haml +11 -0
  54. data/test/dummy/app/views/layouts/application.html.haml +24 -0
  55. data/test/dummy/app/views/main/index.html.haml +13 -0
  56. data/test/dummy/app/views/main/qunit.html.haml +7 -0
  57. data/test/dummy/config/application.rb +58 -0
  58. data/test/dummy/config/boot.rb +10 -0
  59. data/test/dummy/config/database.yml +25 -0
  60. data/test/dummy/config/environment.rb +5 -0
  61. data/test/dummy/config/environments/development.rb +40 -0
  62. data/test/dummy/config/environments/production.rb +67 -0
  63. data/test/dummy/config/environments/test.rb +37 -0
  64. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  65. data/test/dummy/config/initializers/inflections.rb +15 -0
  66. data/test/dummy/config/initializers/mime_types.rb +5 -0
  67. data/test/dummy/config/initializers/qunit-rails.rb +1 -0
  68. data/test/dummy/config/initializers/secret_token.rb +7 -0
  69. data/test/dummy/config/initializers/session_store.rb +8 -0
  70. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  71. data/test/dummy/config/locales/en.yml +5 -0
  72. data/test/dummy/config/routes.rb +63 -0
  73. data/test/dummy/config.ru +4 -0
  74. data/test/dummy/log/.gitkeep +0 -0
  75. data/test/dummy/public/404.html +26 -0
  76. data/test/dummy/public/422.html +26 -0
  77. data/test/dummy/public/500.html +25 -0
  78. data/test/dummy/public/favicon.ico +0 -0
  79. data/test/dummy/script/rails +6 -0
  80. data/test/javascripts/all_tests.js.coffee +12 -0
  81. data/test/javascripts/test_helper.js.coffee +3 -0
  82. data/test/javascripts/tests/helpers/asset_tag_test.js.coffee +51 -0
  83. data/test/javascripts/tests/helpers/form_options_test.js.coffee +170 -0
  84. data/test/javascripts/tests/helpers/form_tag_test.js.coffee +226 -0
  85. data/test/javascripts/tests/helpers/javascript_test.js.coffee +25 -0
  86. data/test/javascripts/tests/helpers/number_test.js.coffee +250 -0
  87. data/test/javascripts/tests/helpers/record_tag_test.js.coffee +60 -0
  88. data/test/javascripts/tests/helpers/tag_test.js.coffee +58 -0
  89. data/test/javascripts/tests/helpers/url_test.js.coffee +76 -0
  90. data/test/javascripts/tests/underscore/underscore.outcasts.test.js.coffee +47 -0
  91. data/test/javascripts/vendors/backbone.js +1533 -0
  92. data/test/javascripts/vendors/i18n-lite.js.coffee +20 -0
  93. data/test/stylesheets/test_helper.css +4 -0
  94. data/test/stylesheets/vendors/ultimate/mixins/_routines.scss +120 -0
  95. data/test/stylesheets/vendors/ultimate/mixins/_vendors.scss +44 -0
  96. data/test/stylesheets/vendors/ultimate/mixins/css3/_text-shadow.scss +40 -0
  97. data/test/stylesheets/vendors/ultimate/mixins/css3.scss +350 -0
  98. data/test/stylesheets/vendors/ultimate/mixins/fonts.scss +100 -0
  99. data/test/stylesheets/vendors/ultimate/mixins/microstructures.scss +239 -0
  100. data/ultimate-helpers.gemspec +25 -0
  101. metadata +193 -0
@@ -0,0 +1,226 @@
1
+ #= require ultimate/underscore/underscore
2
+ #= require ultimate/underscore/underscore.string
3
+ #= require ultimate/underscore/underscore.outcasts
4
+ #= require ultimate/helpers/form_tag
5
+
6
+ module "Ultimate.Helpers.FormTag"
7
+
8
+ _.extend @, Ultimate.Helpers.FormTag
9
+
10
+ hidden_fields = (options = {}) ->
11
+ method = options['method']
12
+ txt = '<div style="margin:0;padding:0;display:inline">'
13
+ txt += '<input name="utf8" type="hidden" value="&#x2713;" />'
14
+ if method and not (method in ['get', 'post'])
15
+ txt += '<input name="_method" type="hidden" value="' + method + '" />'
16
+ txt + '</div>'
17
+
18
+ form_text = (action = 'http://www.example.com', options = {}) ->
19
+ [remote, enctype, html_class, id, method] = _.map(_.string.words('remote enctype html_class id method'), (key) -> options[key])
20
+ method = 'post' if method isnt 'get'
21
+ txt = "<form accept-charset=\"UTF-8\" action=\"#{action}\""
22
+ txt += " enctype=\"multipart/form-data\"" if enctype
23
+ txt += " data-remote=\"true\"" if remote
24
+ txt += " class=\"#{html_class}\"" if html_class
25
+ txt += " id=\"#{id}\"" if id
26
+ txt += " method=\"#{method}\">"
27
+ txt
28
+
29
+ whole_form = (action = 'javascript:;', options = {}) ->
30
+ out = form_text(action, options) + hidden_fields(options)
31
+ if block = _.outcasts.blockGiven(arguments)
32
+ out += block() + "</form>"
33
+ out
34
+
35
+ test "form_tag", ->
36
+ equal form_tag(), whole_form()
37
+ equal form_tag({}, multipart: true), whole_form(null, enctype: true)
38
+ equal form_tag({}, method: 'patch'), whole_form(null, method: 'patch')
39
+ equal form_tag({}, method: 'put'), whole_form(null, method: 'put')
40
+ equal form_tag({}, method: 'delete'), whole_form(null, method: 'delete')
41
+ equal form_tag({}, remote: true), whole_form(null, remote: true)
42
+ equal form_tag(-> 'Hello world!'), whole_form(null, -> 'Hello world!')
43
+ equal form_tag(null, method: 'put', -> 'Hello world!'), whole_form(null, method: 'put', -> 'Hello world!')
44
+
45
+ test "select_tag", ->
46
+ equal select_tag("people", "<option>david</option>"),
47
+ '<select id="people" name="people"><option>david</option></select>'
48
+ equal select_tag("colors", "<option>Red</option><option>Blue</option><option>Green</option>", multiple: true),
49
+ '<select id="colors" multiple="multiple" name="colors[]"><option>Red</option><option>Blue</option><option>Green</option></select>'
50
+ equal select_tag("places", "<option>Home</option><option>Work</option><option>Pub</option>", disabled: true),
51
+ '<select disabled="disabled" id="places" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>'
52
+ equal select_tag("places", "<option>Home</option><option>Work</option><option>Pub</option>", include_blank: true),
53
+ '<select id="places" name="places"><option value=""></option><option>Home</option><option>Work</option><option>Pub</option></select>'
54
+ equal select_tag("places", "<option>Home</option><option>Work</option><option>Pub</option>", prompt: "string"),
55
+ '<select id="places" name="places"><option value="">string</option><option>Home</option><option>Work</option><option>Pub</option></select>'
56
+ equal select_tag("places", "<option>Home</option><option>Work</option><option>Pub</option>", prompt: "<script>alert(1337)</script>"),
57
+ '<select id="places" name="places"><option value="">&lt;script&gt;alert(1337)&lt;/script&gt;</option><option>Home</option><option>Work</option><option>Pub</option></select>'
58
+ equal select_tag("places", "<option>Home</option><option>Work</option><option>Pub</option>", prompt: "string", include_blank: true),
59
+ '<select id="places" name="places"><option value="">string</option><option value=""></option><option>Home</option><option>Work</option><option>Pub</option></select>'
60
+ equal select_tag("places", null, include_blank: true),
61
+ '<select id="places" name="places"><option value=""></option></select>'
62
+ equal select_tag("places", null, prompt: "string"),
63
+ '<select id="places" name="places"><option value="">string</option></select>'
64
+
65
+ test "text_field_tag", ->
66
+ equal text_field_tag("title"),
67
+ '<input id="title" name="title" type="text" />'
68
+ equal text_field_tag("title", "Hello!", class: "admin"),
69
+ '<input class="admin" id="title" name="title" type="text" value="Hello!" />'
70
+ equal text_field_tag("title", "Hello!", size: 75),
71
+ '<input id="title" name="title" size="75" type="text" value="Hello!" />'
72
+ equal text_field_tag("title", "Hello!", disabled: true),
73
+ '<input disabled="disabled" id="title" name="title" type="text" value="Hello!" />'
74
+ equal text_field_tag("title", "Hello!", size: 70, maxlength: 80),
75
+ '<input id="title" maxlength="80" name="title" size="70" type="text" value="Hello!" />'
76
+
77
+ test "label_tag", ->
78
+ equal label_tag("title"), '<label for="title">Title</label>'
79
+ equal label_tag("title", "My Title"), '<label for="title">My Title</label>'
80
+ equal label_tag("title", "My Title", class: "small-label"), '<label class="small-label" for="title">My Title</label>'
81
+ equal label_tag( -> "Blocked" ), '<label>Blocked</label>'
82
+ equal label_tag( -> content_tag('span', "Blocked SPAN", class: 'inner') ), '<label><span class="inner">Blocked SPAN</span></label>'
83
+ equal label_tag("clock", -> "Grandfather"), '<label for="clock">Grandfather</label>'
84
+ equal label_tag("clock", id: "label_clock", -> "Grandfather"), '<label for="clock" id="label_clock">Grandfather</label>'
85
+
86
+ test "hidden_field_tag", ->
87
+ equal hidden_field_tag('id', 3), '<input id="id" name="id" type="hidden" value="3" />'
88
+
89
+ test "file_field_tag", ->
90
+ equal file_field_tag('picsplz'), '<input id="picsplz" name="picsplz" type="file" />'
91
+ equal file_field_tag('picsplz', class: 'pix'), '<input class="pix" id="picsplz" name="picsplz" type="file" />'
92
+
93
+ test "password_field_tag", ->
94
+ equal password_field_tag(), '<input id="password" name="password" type="password" />'
95
+
96
+ test "text_area_tag", ->
97
+ equal text_area_tag("body", "hello world", size: "20x40"),
98
+ '<textarea cols="20" id="body" name="body" rows="40">\nhello world</textarea>'
99
+ equal text_area_tag("body", "hello world", size: 20),
100
+ '<textarea id="body" name="body">\nhello world</textarea>'
101
+ equal text_area_tag("body", "<b>hello world</b>", size: "20x40"),
102
+ '<textarea cols="20" id="body" name="body" rows="40">\n&lt;b&gt;hello world&lt;/b&gt;</textarea>'
103
+ equal text_area_tag("body", "<b>hello world</b>", size: "20x40", escape: false),
104
+ '<textarea cols="20" id="body" name="body" rows="40">\n<b>hello world</b></textarea>'
105
+ equal text_area_tag("body", null, escape: false),
106
+ '<textarea id="body" name="body">\n</textarea>'
107
+
108
+ test "check_box_tag", ->
109
+ equal check_box_tag('admin'), '<input id="admin" name="admin" type="checkbox" value="1" />'
110
+
111
+ test "radio_button_tag", ->
112
+ equal radio_button_tag("people", "david"),
113
+ '<input id="people_david" name="people" type="radio" value="david" />'
114
+ equal radio_button_tag("num_people", 5),
115
+ '<input id="num_people_5" name="num_people" type="radio" value="5" />'
116
+ equal radio_button_tag("gender", "m") + radio_button_tag("gender", "f"),
117
+ '<input id="gender_m" name="gender" type="radio" value="m" /><input id="gender_f" name="gender" type="radio" value="f" />'
118
+ equal radio_button_tag("opinion", "-1") + radio_button_tag("opinion", "1"),
119
+ '<input id="opinion_-1" name="opinion" type="radio" value="-1" /><input id="opinion_1" name="opinion" type="radio" value="1" />'
120
+ equal radio_button_tag("person[gender]", "m"),
121
+ '<input id="person_gender_m" name="person[gender]" type="radio" value="m" />'
122
+ equal radio_button_tag('ctrlname', 'apache2.2'),
123
+ '<input id="ctrlname_apache2.2" name="ctrlname" type="radio" value="apache2.2" />'
124
+
125
+ test "submit_tag", ->
126
+ equal submit_tag("Save", onclick: "alert('hello!')", data: { disable_with: "Saving..." }),
127
+ '<input data-disable-with="Saving..." name="commit" onclick="alert(&apos;hello!&apos;)" type="submit" value="Save" />'
128
+ equal submit_tag("Save", data: { disable_with: "Saving..." }),
129
+ '<input data-disable-with="Saving..." name="commit" type="submit" value="Save" />'
130
+ equal submit_tag("Save", data: { confirm: "Are you sure?" }),
131
+ '<input data-confirm="Are you sure?" name="commit" type="submit" value="Save" />'
132
+
133
+ test "button_tag", ->
134
+ equal button_tag(),
135
+ '<button name="button" type="submit">Button</button>'
136
+ equal button_tag("Save", type: "submit"),
137
+ '<button name="button" type="submit">Save</button>'
138
+ equal button_tag("Button", type: "button"),
139
+ '<button name="button" type="button">Button</button>'
140
+ equal button_tag("Reset", type: "reset"),
141
+ '<button name="button" type="reset">Reset</button>'
142
+ equal button_tag("Reset", type: "reset", disabled: true),
143
+ '<button disabled="disabled" name="button" type="reset">Reset</button>'
144
+ equal button_tag("<b>Reset</b>", type: "reset", disabled: true),
145
+ '<button disabled="disabled" name="button" type="reset">&lt;b&gt;Reset&lt;/b&gt;</button>'
146
+ equal button_tag( -> 'Content' ),
147
+ '<button name="button" type="submit">Content</button>'
148
+ equal button_tag(name: 'temptation', type: 'button', -> content_tag('strong', 'Do not press me')),
149
+ '<button name="temptation" type="button"><strong>Do not press me</strong></button>'
150
+ equal button_tag("Save", type: "submit", data: { confirm: "Are you sure?" }),
151
+ '<button data-confirm="Are you sure?" name="button" type="submit">Save</button>'
152
+
153
+ test "image_submit_tag", ->
154
+ equal image_submit_tag("save.gif", data: { confirm: "Are you sure?" }),
155
+ '<input data-confirm="Are you sure?" src="/images/save.gif" type="image" />'
156
+
157
+ test "field_set_tag", ->
158
+ equal field_set_tag('Your details', -> 'Hello world!'),
159
+ '<fieldset><legend>Your details</legend>Hello world!</fieldset>'
160
+ equal field_set_tag(-> 'Hello world!'),
161
+ '<fieldset>Hello world!</fieldset>'
162
+ equal field_set_tag('', -> 'Hello world!'),
163
+ '<fieldset>Hello world!</fieldset>'
164
+ equal field_set_tag('', class: 'format', -> 'Hello world!'),
165
+ '<fieldset class="format">Hello world!</fieldset>'
166
+ equal field_set_tag(),
167
+ '<fieldset></fieldset>'
168
+ equal field_set_tag('You legend!'),
169
+ '<fieldset><legend>You legend!</legend></fieldset>'
170
+
171
+ test "different fields tags helpers", ->
172
+ equal color_field_tag("car"),
173
+ '<input id="car" name="car" type="color" />'
174
+ equal search_field_tag("query"),
175
+ '<input id="query" name="query" type="search" />'
176
+ equal telephone_field_tag("cell"),
177
+ '<input id="cell" name="cell" type="tel" />'
178
+ equal telephone_field_tag("cell"),
179
+ phone_field_tag("cell")
180
+ equal date_field_tag("cell"),
181
+ '<input id="cell" name="cell" type="date" />'
182
+ equal time_field_tag("cell"),
183
+ '<input id="cell" name="cell" type="time" />'
184
+ equal datetime_field_tag("appointment"),
185
+ '<input id="appointment" name="appointment" type="datetime" />'
186
+ equal datetime_local_field_tag("appointment"),
187
+ '<input id="appointment" name="appointment" type="datetime-local" />'
188
+ equal month_field_tag("birthday"),
189
+ '<input id="birthday" name="birthday" type="month" />'
190
+ equal week_field_tag("birthday"),
191
+ '<input id="birthday" name="birthday" type="week" />'
192
+ equal url_field_tag("homepage"),
193
+ '<input id="homepage" name="homepage" type="url" />'
194
+ equal email_field_tag("address"),
195
+ '<input id="address" name="address" type="email" />'
196
+ equal number_field_tag("quantity", null, in: {min: "1", max: "9"}),
197
+ '<input id="quantity" max="9" min="1" name="quantity" type="number" />'
198
+ equal range_field_tag("volume", null, in: {min: 0, max: 11}, step: 0.1),
199
+ '<input id="volume" max="11" min="0" name="volume" step="0.1" type="range" />'
200
+
201
+ test "boolean options", ->
202
+ equal check_box_tag("admin", 1, true, disabled: true, readonly: "yes"),
203
+ '<input checked="checked" disabled="disabled" id="admin" name="admin" readonly="readonly" type="checkbox" value="1" />'
204
+ equal check_box_tag("admin", 1, true, disabled: false, readonly: null),
205
+ '<input checked="checked" id="admin" name="admin" type="checkbox" value="1" />'
206
+ equal tag('input', type: "checkbox", checked: false),
207
+ '<input type="checkbox" />'
208
+ equal select_tag("people", "<option>david</option>", multiple: true),
209
+ '<select id="people" multiple="multiple" name="people[]"><option>david</option></select>'
210
+ equal select_tag("people[]", "<option>david</option>", multiple: true),
211
+ '<select id="people_" multiple="multiple" name="people[]"><option>david</option></select>'
212
+ equal select_tag("people", "<option>david</option>", multiple: null),
213
+ '<select id="people" name="people"><option>david</option></select>'
214
+
215
+ test "options side effects", ->
216
+ options = { option: "random_option" }
217
+ text_area_tag "body", "hello world", options
218
+ deepEqual options, { option: "random_option" }
219
+ submit_tag "submit value", options
220
+ deepEqual options, { option: "random_option" }
221
+ button_tag "button value", options
222
+ deepEqual options, { option: "random_option" }
223
+ image_submit_tag "submit source", options
224
+ deepEqual options, { option: "random_option" }
225
+ label_tag "submit source", "title", options
226
+ deepEqual options, { option: "random_option" }
@@ -0,0 +1,25 @@
1
+ #= require ultimate/underscore/underscore
2
+ #= require ultimate/underscore/underscore.string
3
+ #= require ultimate/underscore/underscore.outcasts
4
+ #= require ultimate/helpers/javascript
5
+
6
+ module "Ultimate.Helpers.Javascript"
7
+
8
+ _.extend @, Ultimate.Helpers.Javascript
9
+
10
+ test "escape_javascript", ->
11
+ strictEqual escape_javascript(null), ''
12
+ equal escape_javascript('This "thing" is really\n netos\''), 'This \\"thing\\" is really\\n netos\\\''
13
+ equal escape_javascript('backslash\\test'), 'backslash\\\\test'
14
+ equal escape_javascript('dont </close> tags'), 'dont <\\/close> tags'
15
+ # equal escape_javascript('unicode \\342\\200\\250 newline'), 'unicode &#x2028; newline'
16
+ # equal escape_javascript('unicode \\342\\200\\251 newline'), 'unicode &#x2029; newline'
17
+ equal j('dont </close> tags'), 'dont <\\/close> tags'
18
+ equal escape_javascript('\'quoted\' "double-quoted" new-line:\n </closed>'), '\\\'quoted\\\' \\"double-quoted\\" new-line:\\n <\\/closed>'
19
+
20
+ test "javascript_tag", ->
21
+ equal javascript_tag("alert('hello')"), "<script>\n//<![CDATA[\nalert('hello')\n//]]>\n</script>"
22
+ equal javascript_tag("alert('hello')", id: "the_js_tag"), "<script id=\"the_js_tag\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>"
23
+
24
+ test "javascript_cdata_section", ->
25
+ equal javascript_cdata_section("alert('hello')"), "\n//<![CDATA[\nalert('hello')\n//]]>\n"
@@ -0,0 +1,250 @@
1
+ #= require ultimate/underscore/underscore
2
+ #= require ultimate/underscore/underscore.string
3
+ #= require vendors/i18n-lite
4
+ #= require ultimate/helpers/number
5
+
6
+ module "Ultimate.Helpers.Number"
7
+
8
+ _.extend @, Ultimate.Helpers.Number
9
+
10
+ kilobytes = (number) -> number * 1024
11
+ megabytes = (number) -> kilobytes(number) * 1024
12
+ gigabytes = (number) -> megabytes(number) * 1024
13
+ terabytes = (number) -> gigabytes(number) * 1024
14
+
15
+ test "number_to_phone", ->
16
+ equal number_to_phone(5551234), "555-1234"
17
+ equal number_to_phone(8005551212), "800-555-1212"
18
+ equal number_to_phone(8005551212, area_code: true), "(800) 555-1212"
19
+ strictEqual number_to_phone("", area_code: true), ""
20
+ equal number_to_phone(8005551212, delimiter: " "), "800 555 1212"
21
+ equal number_to_phone(8005551212, area_code: true, extension: 123), "(800) 555-1212 x 123"
22
+ equal number_to_phone(8005551212, extension: " "), "800-555-1212"
23
+ strictEqual number_to_phone(5551212, delimiter: '.'), "555.1212"
24
+ equal number_to_phone("8005551212"), "800-555-1212"
25
+ equal number_to_phone(8005551212, country_code: 1), "+1-800-555-1212"
26
+ strictEqual number_to_phone(8005551212, country_code: 1, delimiter: ''), "+18005551212"
27
+ equal number_to_phone(225551212), "22-555-1212"
28
+ equal number_to_phone(225551212, country_code: 45), "+45-22-555-1212"
29
+ equal number_to_phone(911), "911"
30
+ equal number_to_phone(0), "0"
31
+ equal number_to_phone(-1), "1"
32
+
33
+ test "number_to_currency", ->
34
+ equal number_to_currency(1234567890.50), "$1,234,567,890.50"
35
+ equal number_to_currency(1234567890.506), "$1,234,567,890.51"
36
+ equal number_to_currency(-1234567890.50), "-$1,234,567,890.50"
37
+ equal number_to_currency(-1234567890.50, format: "%u %n"), "-$ 1,234,567,890.50"
38
+ equal number_to_currency(-1234567890.50, negative_format: "(%u%n)"), "($1,234,567,890.50)"
39
+ equal number_to_currency(1234567891.50, precision: 0), "$1,234,567,892"
40
+ equal number_to_currency(1234567890.50, precision: 1), "$1,234,567,890.5"
41
+ equal number_to_currency(1234567890.50, unit: "&pound;", separator: ",", delimiter: ""), "&pound;1234567890,50"
42
+ equal number_to_currency("1234567890.50"), "$1,234,567,890.50"
43
+ equal number_to_currency("1234567890.50", unit: "K&#269;", format: "%n %u"), "1,234,567,890.50 K&#269;"
44
+ equal number_to_currency("-1234567890.50", unit: "K&#269;", format: "%n %u", negative_format: "%n - %u"), "1,234,567,890.50 - K&#269;"
45
+ strictEqual number_to_currency(0.0, unit: "", negative_format: "(%n)"), "0.00"
46
+
47
+ test "number_to_percentage", ->
48
+ equal number_to_percentage(100), "100.000%"
49
+ equal number_to_percentage(100, precision: 0), "100%"
50
+ equal number_to_percentage(302.0574, precision: 2), "302.06%"
51
+ equal number_to_percentage("100"), "100.000%"
52
+ equal number_to_percentage("1000"), "1000.000%"
53
+ equal number_to_percentage(123.400, precision: 3, strip_insignificant_zeros: true), "123.4%"
54
+ equal number_to_percentage(1000, delimiter: '.', separator: ','), "1.000,000%"
55
+ equal number_to_percentage(1000, format: "%n %"), "1000.000 %"
56
+ equal number_to_percentage(0), "0.000%"
57
+ equal number_to_percentage(-1), "-1.000%"
58
+
59
+ test "number_to_delimited", ->
60
+ strictEqual number_to_delimited(12345678), "12,345,678"
61
+ strictEqual number_to_delimited(0), "0"
62
+ strictEqual number_to_delimited(123), "123"
63
+ strictEqual number_to_delimited(123456), "123,456"
64
+ strictEqual number_to_delimited(123456.78), "123,456.78"
65
+ strictEqual number_to_delimited(123456.789), "123,456.789"
66
+ strictEqual number_to_delimited(123456.78901), "123,456.78901"
67
+ strictEqual number_to_delimited(123456789.78901), "123,456,789.78901"
68
+ strictEqual number_to_delimited(0.78901), "0.78901"
69
+ strictEqual number_to_delimited("123456.78"), "123,456.78"
70
+ strictEqual number_to_delimited(12345678, delimiter: ' '), "12 345 678"
71
+ strictEqual number_to_delimited(12345678.05, separator: '-'), "12,345,678-05"
72
+ strictEqual number_to_delimited(12345678.05, separator: ',', delimiter: '.'), "12.345.678,05"
73
+ strictEqual number_to_delimited(12345678.05, delimiter: '.', separator: ','), "12.345.678,05"
74
+
75
+ test "round_with_precision", ->
76
+ strictEqual round_with_precision(10/3), 3.33
77
+ strictEqual round_with_precision(10/3, 0), 3
78
+ strictEqual round_with_precision(100/3, 5), 33.33333
79
+ strictEqual round_with_precision(100/3, -1), 30
80
+ strictEqual round_with_precision("19.3", -1), 20
81
+ # strictEqual round_with_precision(9.995, 2), 10
82
+ strictEqual round_with_precision(null), 0
83
+
84
+ test "number_to_rounded", ->
85
+ strictEqual number_to_rounded(-111.2346), "-111.235"
86
+ strictEqual number_to_rounded(111.2346), "111.235"
87
+ strictEqual number_to_rounded(31.825, precision: 2), "31.83"
88
+ strictEqual number_to_rounded(111.2346, precision: 2), "111.23"
89
+ strictEqual number_to_rounded(111, precision: 2), "111.00"
90
+ strictEqual number_to_rounded("111.2346"), "111.235"
91
+ strictEqual number_to_rounded("31.825", precision: 2), "31.83"
92
+ strictEqual number_to_rounded((32.6751 * 100.00), precision: 0), "3268"
93
+ strictEqual number_to_rounded(111.50, precision: 0), "112"
94
+ strictEqual number_to_rounded(1234567891.50, precision: 0), "1234567892"
95
+ strictEqual number_to_rounded(0, precision: 0), "0"
96
+ strictEqual number_to_rounded(0.001, precision: 5), "0.00100"
97
+ strictEqual number_to_rounded(0.00111, precision: 3), "0.001"
98
+ # strictEqual number_to_rounded(9.995, precision: 2), "10.00"
99
+ strictEqual number_to_rounded(10.995, precision: 2), "11.00"
100
+ strictEqual number_to_rounded(-0.001, precision: 2), "0.00"
101
+ strictEqual number_to_rounded(31.825, precision: 2, separator: ','), "31,83"
102
+ strictEqual number_to_rounded(1231.825, precision: 2, separator: ',', delimiter: '.'), "1.231,83"
103
+ strictEqual number_to_rounded(123987, precision: 3, significant: true), "124000"
104
+ strictEqual number_to_rounded(123987876, precision: 2, significant: true ), "120000000"
105
+ strictEqual number_to_rounded("43523", precision: 1, significant: true ), "40000"
106
+ strictEqual number_to_rounded(9775, precision: 4, significant: true ), "9775"
107
+ strictEqual number_to_rounded(5.3923, precision: 2, significant: true ), "5.4"
108
+ strictEqual number_to_rounded(5.3923, precision: 1, significant: true ), "5"
109
+ strictEqual number_to_rounded(1.232, precision: 1, significant: true ), "1"
110
+ strictEqual number_to_rounded(7, precision: 1, significant: true ), "7"
111
+ strictEqual number_to_rounded(1, precision: 1, significant: true ), "1"
112
+ strictEqual number_to_rounded(52.7923, precision: 2, significant: true ), "53"
113
+ strictEqual number_to_rounded(9775, precision: 6, significant: true ), "9775.00"
114
+ strictEqual number_to_rounded(5.3929, precision: 7, significant: true ), "5.392900"
115
+ strictEqual number_to_rounded(0, precision: 2, significant: true ), "0.0"
116
+ strictEqual number_to_rounded(0, precision: 1, significant: true ), "0"
117
+ strictEqual number_to_rounded(0.0001, precision: 1, significant: true ), "0.0001"
118
+ strictEqual number_to_rounded(0.0001, precision: 3, significant: true ), "0.000100"
119
+ strictEqual number_to_rounded(0.0001111, precision: 1, significant: true ), "0.0001"
120
+ # strictEqual number_to_rounded(9.995, precision: 3, significant: true), "10.0"
121
+ strictEqual number_to_rounded(9.994, precision: 3, significant: true), "9.99"
122
+ strictEqual number_to_rounded(10.995, precision: 3, significant: true), "11.0"
123
+ strictEqual number_to_rounded(9775.43, precision: 4, strip_insignificant_zeros: true ), "9775.43"
124
+ strictEqual number_to_rounded(9775.2, precision: 6, significant: true, strip_insignificant_zeros: true ), "9775.2"
125
+ strictEqual number_to_rounded(0, precision: 6, significant: true, strip_insignificant_zeros: true ), "0"
126
+ strictEqual number_to_rounded(123.987, precision: 0, significant: true), "124"
127
+ strictEqual number_to_rounded(12, precision: 0, significant: true ), "12"
128
+ strictEqual number_to_rounded("12.3", precision: 0, significant: true ), "12"
129
+
130
+ test "number_to_human_size", ->
131
+ equal number_to_human_size(0), "0 Bytes"
132
+ # equal number_to_human_size(1), "1 Byte"
133
+ equal number_to_human_size(3.14159265), "3 Bytes"
134
+ equal number_to_human_size(123.0), "123 Bytes"
135
+ equal number_to_human_size(123), "123 Bytes"
136
+ equal number_to_human_size(1234), "1.21 KB"
137
+ equal number_to_human_size(12345), "12.1 KB"
138
+ equal number_to_human_size(1234567), "1.18 MB"
139
+ equal number_to_human_size(1234567890), "1.15 GB"
140
+ equal number_to_human_size(1234567890123), "1.12 TB"
141
+ equal number_to_human_size(terabytes(1026)), "1030 TB"
142
+ equal number_to_human_size(kilobytes(444)), "444 KB"
143
+ equal number_to_human_size(megabytes(1023)), "1020 MB"
144
+ equal number_to_human_size(terabytes(3)), "3 TB"
145
+ equal number_to_human_size(1234567, precision: 2), "1.2 MB"
146
+ equal number_to_human_size(3.14159265, precision: 4), "3 Bytes"
147
+ equal number_to_human_size('123'), "123 Bytes"
148
+ equal number_to_human_size(kilobytes(1.0123), precision: 2), "1 KB"
149
+ equal number_to_human_size(kilobytes(1.0100), precision: 4), "1.01 KB"
150
+ equal number_to_human_size(kilobytes(10.000), precision: 4), "10 KB"
151
+ # equal number_to_human_size(1.1), "1 Byte"
152
+ equal number_to_human_size(10), "10 Bytes"
153
+ equal number_to_human_size(3.14159265, prefix: 'si'), "3 Bytes"
154
+ equal number_to_human_size(123.0, prefix: 'si'), "123 Bytes"
155
+ equal number_to_human_size(123, prefix: 'si'), "123 Bytes"
156
+ equal number_to_human_size(1234, prefix: 'si'), "1.23 KB"
157
+ equal number_to_human_size(12345, prefix: 'si'), "12.3 KB"
158
+ equal number_to_human_size(1234567, prefix: 'si'), "1.23 MB"
159
+ equal number_to_human_size(1234567890, prefix: 'si'), "1.23 GB"
160
+ equal number_to_human_size(1234567890123, prefix: 'si'), "1.23 TB"
161
+ equal number_to_human_size(1234567, precision: 2), "1.2 MB"
162
+ equal number_to_human_size(3.14159265, precision: 4), "3 Bytes"
163
+ equal number_to_human_size(kilobytes(1.0123), precision: 2), "1 KB"
164
+ equal number_to_human_size(kilobytes(1.0100), precision: 4), "1.01 KB"
165
+ equal number_to_human_size(kilobytes(10.000), precision: 4), "10 KB"
166
+ equal number_to_human_size(1234567890123, precision: 1), "1 TB"
167
+ equal number_to_human_size(524288000, precision: 3), "500 MB"
168
+ equal number_to_human_size(9961472, precision: 0), "10 MB"
169
+ equal number_to_human_size(41010, precision: 1), "40 KB"
170
+ equal number_to_human_size(41100, precision: 2), "40 KB"
171
+ equal number_to_human_size(kilobytes(1.0123), precision: 2, strip_insignificant_zeros: false), "1.0 KB"
172
+ equal number_to_human_size(kilobytes(1.0123), precision: 3, significant: false), "1.012 KB"
173
+ equal number_to_human_size(kilobytes(1.0123), precision: 0, significant: true), "1 KB" #ignores significant it precision is 0
174
+ equal number_to_human_size(kilobytes(1.0123), precision: 3, separator: ','), "1,01 KB"
175
+ equal number_to_human_size(kilobytes(1.0100), precision: 4, separator: ','), "1,01 KB"
176
+ equal number_to_human_size(terabytes(1000.1), precision: 5, delimiter: '.', separator: ','), "1.000,1 TB"
177
+
178
+ test "number_to_human", ->
179
+ strictEqual number_to_human(-123), "-123"
180
+ strictEqual number_to_human(-0.5), "-0.5"
181
+ strictEqual number_to_human(0), "0"
182
+ strictEqual number_to_human(0.5), "0.5"
183
+ strictEqual number_to_human(123), "123"
184
+ equal number_to_human(1234), "1.23 Thousand"
185
+ equal number_to_human(12345), "12.3 Thousand"
186
+ equal number_to_human(1234567), "1.23 Million"
187
+ equal number_to_human(1234567890), "1.23 Billion"
188
+ equal number_to_human(1234567890123), "1.23 Trillion"
189
+ equal number_to_human(1234567890123456), "1.23 Quadrillion"
190
+ equal number_to_human(1234567890123456789), "1230 Quadrillion"
191
+ equal number_to_human(489939, precision: 2), "490 Thousand"
192
+ equal number_to_human(489939, precision: 4), "489.9 Thousand"
193
+ equal number_to_human(489000, precision: 4), "489 Thousand"
194
+ equal number_to_human(489000, precision: 4, strip_insignificant_zeros: false), "489.0 Thousand"
195
+ equal number_to_human(1234567, precision: 4, significant: false), "1.2346 Million"
196
+ equal number_to_human(1234567, precision: 1, significant: false, separator: ','), "1,2 Million"
197
+ equal number_to_human(1234567, precision: 0, significant: true, separator: ','), "1 Million" #significant forced to false
198
+ #Only integers
199
+ volume = unit: "ml", thousand: "lt", million: "m3"
200
+ equal number_to_human(123456, units: volume), "123 lt"
201
+ equal number_to_human(12, units: volume), "12 ml"
202
+ equal number_to_human(1234567, units: volume), "1.23 m3"
203
+ #Including fractionals
204
+ distance = mili: "mm", centi: "cm", deci: "dm", unit: "m", ten: "dam", hundred: "hm", thousand: "km"
205
+ equal number_to_human(0.00123, units: distance), "1.23 mm"
206
+ equal number_to_human(0.0123, units: distance), "1.23 cm"
207
+ equal number_to_human(0.123, units: distance), "1.23 dm"
208
+ equal number_to_human(1.23, units: distance), "1.23 m"
209
+ equal number_to_human(12.3, units: distance), "1.23 dam"
210
+ equal number_to_human(123, units: distance), "1.23 hm"
211
+ equal number_to_human(1230, units: distance), "1.23 km"
212
+ equal number_to_human(1230, units: distance), "1.23 km"
213
+ equal number_to_human(1230, units: distance), "1.23 km"
214
+ equal number_to_human(12300, units: distance), "12.3 km"
215
+ #The quantifiers don't need to be a continuous sequence
216
+ gangster = hundred: "hundred bucks", million: "thousand quids"
217
+ equal number_to_human(100, units: gangster), "1 hundred bucks"
218
+ equal number_to_human(2500, units: gangster), "25 hundred bucks"
219
+ equal number_to_human(25000000, units: gangster), "25 thousand quids"
220
+ equal number_to_human(12345000000, units: gangster), "12300 thousand quids"
221
+ #Spaces are stripped from the resulting string
222
+ strictEqual number_to_human(4, units: unit: "", ten: 'tens '), "4"
223
+ equal number_to_human(45, units: unit: "", ten: ' tens '), "4.5 tens"
224
+ equal number_to_human(123456, format: "%n times %u"), "123 times Thousand"
225
+ volume = unit: "ml", thousand: "lt", million: "m3"
226
+ equal number_to_human(123456, units: volume, format: "%n.%u"), "123.lt"
227
+
228
+ number_to_helpers = _.string.words("phone currency percentage delimited rounded human_size human")
229
+
230
+ test "number helpers should return empty string when given null", number_to_helpers.length, =>
231
+ for h in number_to_helpers
232
+ strictEqual @["number_to_#{h}"](null), "", "number_to_#{h}"
233
+
234
+ test "number helpers don't mutate options hash", number_to_helpers.length, =>
235
+ options = raise: true
236
+ for h in number_to_helpers
237
+ @["number_to_#{h}"](1, options)
238
+ deepEqual options, {raise: true}, "number_to_#{h}"
239
+
240
+ test "number helpers should return non numeric param unchanged", ->
241
+ equal number_to_phone("x", country_code: 1, extension: 123), "+1-x x 123"
242
+ equal number_to_phone("x"), "x"
243
+ equal number_to_currency("x."), "$x."
244
+ equal number_to_currency("x"), "$x"
245
+ equal number_to_percentage("x"), "x%"
246
+ equal number_to_delimited("x"), "x"
247
+ equal number_to_rounded("x."), "x."
248
+ equal number_to_rounded("x"), "x"
249
+ equal number_to_human_size('x'), "x"
250
+ equal number_to_human('x'), "x"
@@ -0,0 +1,60 @@
1
+ #= require ultimate/underscore/underscore
2
+ #= require ultimate/underscore/underscore.string
3
+ #= require ultimate/underscore/underscore.inflection
4
+ #= require ultimate/helpers/record_tag
5
+
6
+ module "Ultimate.Helpers.RecordTag"
7
+
8
+ _.extend @, Ultimate.Helpers.RecordTag
9
+
10
+ class RecordTagPost
11
+ body: "What a wonderful world!"
12
+ constructor: (options = {}) ->
13
+ _.extend @, options
14
+
15
+ record = new RecordTagPost()
16
+ singular = 'record_tag_post'
17
+
18
+ test "dom_class", ->
19
+ equal dom_class(record), singular
20
+ equal dom_class(record.constructor.name), singular
21
+ equal dom_class(record, "custom_prefix"), "custom_prefix_#{singular}"
22
+
23
+ test "dom_id", ->
24
+ record.id = null
25
+ equal dom_id(record), "new_#{singular}"
26
+ equal dom_id(record, "custom_prefix"), "custom_prefix_#{singular}"
27
+ record.id = 1
28
+ equal dom_id(record), "#{singular}_1"
29
+ equal dom_id(record, "edit"), "edit_#{singular}_1"
30
+
31
+ test "content_tag_for", ->
32
+ record.id = 45
33
+ equal content_tag_for('li', record),
34
+ "<li class=\"#{singular}\" id=\"#{singular}_45\"></li>"
35
+ equal content_tag_for('ul', record, 'archived'),
36
+ "<ul class=\"archived_#{singular}\" id=\"archived_#{singular}_45\"></ul>"
37
+ equal content_tag_for('tr', record, class: "special", style: "background-color: #f0f0f0"),
38
+ "<tr class=\"#{singular} special\" id=\"#{singular}_45\" style=\"background-color: #f0f0f0\"></tr>"
39
+ equal content_tag_for('tr', record, 'archived', class: "special", style: "background-color: #f0f0f0"),
40
+ "<tr class=\"archived_#{singular} special\" id=\"archived_#{singular}_45\" style=\"background-color: #f0f0f0\"></tr>"
41
+ equal content_tag_for('tr', record, -> "<b>#{record.body}</b>"),
42
+ "<tr class=\"#{singular}\" id=\"#{singular}_45\"><b>What a wonderful world!</b></tr>"
43
+ post_1 = new RecordTagPost(id: 101, body: "Hello!")
44
+ post_2 = new RecordTagPost(id: 102, body: "World!")
45
+ equal content_tag_for('li', [post_1, post_2], (post) -> post.body),
46
+ "<li class=\"#{singular}\" id=\"#{singular}_101\">Hello!</li>\n<li class=\"#{singular}\" id=\"#{singular}_102\">World!</li>"
47
+ options = class: 'important'
48
+ content_tag_for('li', record, options)
49
+ deepEqual options, class: 'important'
50
+ strictEqual content_tag_for('tr', null), ""
51
+ strictEqual content_tag_for('tr', [null, null]), "\n"
52
+
53
+ test "div_for", ->
54
+ record.id = 36
55
+ equal div_for(record, class: 'special', -> record.body),
56
+ "<div class=\"#{singular} special\" id=\"#{singular}_36\">What a wonderful world!</div>"
57
+ post_1 = new RecordTagPost(id: 101, body: "Hello!")
58
+ post_2 = new RecordTagPost(id: 102, body: "World!")
59
+ equal div_for([post_1, post_2], (post) -> post.body),
60
+ "<div class=\"#{singular}\" id=\"#{singular}_101\">Hello!</div>\n<div class=\"#{singular}\" id=\"#{singular}_102\">World!</div>"
@@ -0,0 +1,58 @@
1
+ #= require ultimate/underscore/underscore
2
+ #= require ultimate/underscore/underscore.string
3
+ #= require ultimate/helpers/tag
4
+
5
+ module "Ultimate.Helpers.Tag"
6
+
7
+ _.extend @, Ultimate.Helpers.Tag
8
+
9
+ test "tag_options", ->
10
+ strictEqual tag_options(), ""
11
+ strictEqual tag_options({}), ""
12
+ ok /title="Some title"/.test tag_options(class: "some-class", title: "Some title")
13
+ equal tag_options(class: ["song", "play>"]), ' class="song play&gt;"'
14
+ equal tag_options(disabled: true, itemscope: false, multiple: true, readonly: true), ' disabled="disabled" multiple="multiple" readonly="readonly"'
15
+ equal tag_options(data: {remote: true}, role: "ajax"), ' data-remote="true" role="ajax"'
16
+ equal tag_options(data: {inner: {section: true}}), ' data-inner="{&quot;section&quot;:true}"'
17
+ equal tag_options(data: {inner: {section: true}}, false), ' data-inner="{"section":true}"'
18
+ equal tag_options(included: ''), ' included=""'
19
+
20
+ test "tag", ->
21
+ equal tag('br'), '<br />'
22
+ equal tag('br', null, true), '<br>'
23
+ equal tag('input', type: 'text', disabled: true), '<input disabled="disabled" type="text" />'
24
+ equal tag('img', src: 'open & shut.png'), '<img src="open &amp; shut.png" />'
25
+ equal tag("img", {src: "open &amp; shut.png"}, false, false), '<img src="open &amp; shut.png" />'
26
+ equal tag("div", data: {name: 'Stephen', city_state: ['Chicago', 'IL']}), '<div data-city-state="[&quot;Chicago&quot;,&quot;IL&quot;]" data-name="Stephen" />'
27
+
28
+ test "content_tag", ->
29
+ equal content_tag('div', '', class: ['some', 'class']), '<div class="some class"></div>'
30
+ equal content_tag('div', '<Inner content>', class: 'some class'), '<div class="some class">&lt;Inner content&gt;</div>'
31
+ equal content_tag('div', '<Inner content>', class: 'some class', false), '<div class="some class"><Inner content></div>'
32
+ equal content_tag('div', class: 'some class', -> '<Inner content>'), '<div class="some class">&lt;Inner content&gt;</div>'
33
+ equal content_tag('div', class: 'some class', false, -> '<Inner content>'), '<div class="some class">&lt;Inner content&gt;</div>'
34
+
35
+ test "cdata_section", ->
36
+ equal cdata_section("<hello world>"), "<![CDATA[<hello world>]]>"
37
+ equal cdata_section("hello]]>world"), "<![CDATA[hello]]]]><![CDATA[>world]]>"
38
+ equal cdata_section("hello]]>world]]>again"), "<![CDATA[hello]]]]><![CDATA[>world]]]]><![CDATA[>again]]>"
39
+
40
+ test "concat_class", ->
41
+ strictEqual concat_class(), ''
42
+ strictEqual concat_class(null), ''
43
+ strictEqual concat_class([]), ''
44
+ equal concat_class('lol', 0), 'lol'
45
+ equal concat_class(' lol ', false, ' wow '), 'lol wow'
46
+ equal concat_class('lol', null, 'rofl lol wow ', ' wow '), 'lol rofl wow'
47
+ equal concat_class([['lol', [null]], 'rofl lol wow '], ' wow '), 'lol rofl wow'
48
+
49
+ test "selectorToHtml", ->
50
+ equal selectorToHtml(''), ''
51
+ equal selectorToHtml('.lol'), '<div class="lol"></div>'
52
+ equal selectorToHtml('.mega-lol'), '<div class="mega-lol"></div>'
53
+ equal selectorToHtml('tr.lol'), '<tr class="lol"></tr>'
54
+ equal selectorToHtml('tr.lol#rofl'), '<tr class="lol" id="rofl"></tr>'
55
+ equal selectorToHtml('#rofl.lol'), '<div class="lol" id="rofl"></div>'
56
+ equal selectorToHtml('.lol.wow'), '<div class="lol wow"></div>'
57
+ equal selectorToHtml('.wow#rofl.lol'), '<div class="wow lol" id="rofl"></div>'
58
+ # equal selectorToHtml('h1.one+p.two'), '<h1 class="one"></h1><p class="two"></p>'