hippo-fw 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (535) hide show
  1. checksums.yaml +7 -0
  2. data/.dir-locals.el +8 -0
  3. data/.eslintrc.js +7 -0
  4. data/.flowconfig +2 -0
  5. data/.gitignore +22 -0
  6. data/.jshintrc +3 -0
  7. data/.rubocop.yml +9 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +24 -0
  10. data/Gemfile +17 -0
  11. data/Guardfile +19 -0
  12. data/LICENSE-MIT.txt +21 -0
  13. data/README.md +36 -0
  14. data/Rakefile +39 -0
  15. data/bin/hippo +5 -0
  16. data/client/extension.js +0 -0
  17. data/client/hippo/__mocks__/config.js +17 -0
  18. data/client/hippo/access/index.js +4 -0
  19. data/client/hippo/access/login-dialog.jsx +38 -0
  20. data/client/hippo/access/styles.scss +0 -0
  21. data/client/hippo/boot.jsx +41 -0
  22. data/client/hippo/components/asset.jsx +81 -0
  23. data/client/hippo/components/asset.scss +15 -0
  24. data/client/hippo/components/calendar/Calendar.jsx +25 -0
  25. data/client/hippo/components/calendar/index.js +3 -0
  26. data/client/hippo/components/calendar/styles.scss +3 -0
  27. data/client/hippo/components/data-list.jsx +105 -0
  28. data/client/hippo/components/data-table.jsx +243 -0
  29. data/client/hippo/components/data-table/header-cell.jsx +94 -0
  30. data/client/hippo/components/data-table/table-styles.scss +34 -0
  31. data/client/hippo/components/enabled.js.erb +5 -0
  32. data/client/hippo/components/field-validation.js +7 -0
  33. data/client/hippo/components/form.jsx +65 -0
  34. data/client/hippo/components/form/field-prop-type.js +16 -0
  35. data/client/hippo/components/form/fields.jsx +76 -0
  36. data/client/hippo/components/form/fields/checkbox-wrapper.jsx +21 -0
  37. data/client/hippo/components/form/fields/date-wrapper.jsx +49 -0
  38. data/client/hippo/components/form/fields/form-field.scss +4 -0
  39. data/client/hippo/components/form/fields/select-wrapper.jsx +31 -0
  40. data/client/hippo/components/form/fields/text-wrapper.jsx +20 -0
  41. data/client/hippo/components/form/model.js +95 -0
  42. data/client/hippo/components/form/validations.js +0 -0
  43. data/client/hippo/components/form/wrapper.jsx +40 -0
  44. data/client/hippo/components/grid/config.json +3 -0
  45. data/client/hippo/components/grid/editors.scss +78 -0
  46. data/client/hippo/components/grid/index.js +2 -0
  47. data/client/hippo/components/grid/row-editor.scss +74 -0
  48. data/client/hippo/components/grid/styles.scss +118 -0
  49. data/client/hippo/components/icon.jsx +70 -0
  50. data/client/hippo/components/index.js +3 -0
  51. data/client/hippo/components/modal/index.js +1 -0
  52. data/client/hippo/components/modal/styles.scss +12 -0
  53. data/client/hippo/components/network-activity-overlay.jsx +127 -0
  54. data/client/hippo/components/network-activity-overlay.scss +52 -0
  55. data/client/hippo/components/query-builder.jsx +157 -0
  56. data/client/hippo/components/record-finder.jsx +95 -0
  57. data/client/hippo/components/record-finder/config.json +3 -0
  58. data/client/hippo/components/record-finder/query-layer.jsx +74 -0
  59. data/client/hippo/components/record-finder/record-finder.scss +12 -0
  60. data/client/hippo/components/request-spinner/index.js +1 -0
  61. data/client/hippo/components/screen.jsx +34 -0
  62. data/client/hippo/components/select-field/index.js +2 -0
  63. data/client/hippo/components/select-field/styles.scss +27 -0
  64. data/client/hippo/components/shared/AssetsListing.jsx +23 -0
  65. data/client/hippo/components/shared/Checkbox.jsx +49 -0
  66. data/client/hippo/components/shared/CountBadge.jsx +13 -0
  67. data/client/hippo/components/shared/DateTime.jsx +58 -0
  68. data/client/hippo/components/shared/DisplayValue.jsx +15 -0
  69. data/client/hippo/components/shared/ErrorDisplay.jsx +37 -0
  70. data/client/hippo/components/shared/FieldMixin.jsx +254 -0
  71. data/client/hippo/components/shared/FieldSet.jsx +52 -0
  72. data/client/hippo/components/shared/FieldWrapper.jsx +94 -0
  73. data/client/hippo/components/shared/FormGroup.jsx +41 -0
  74. data/client/hippo/components/shared/GenericField.jsx +7 -0
  75. data/client/hippo/components/shared/IconButton.jsx +13 -0
  76. data/client/hippo/components/shared/ImageAsset.jsx +78 -0
  77. data/client/hippo/components/shared/IndeterminateCheckbox.jsx +31 -0
  78. data/client/hippo/components/shared/Input.jsx +16 -0
  79. data/client/hippo/components/shared/InputFieldMixin.jsx +78 -0
  80. data/client/hippo/components/shared/JobProgress.jsx +46 -0
  81. data/client/hippo/components/shared/NumberInput.jsx +37 -0
  82. data/client/hippo/components/shared/PanelHeader.jsx +15 -0
  83. data/client/hippo/components/shared/RadioField.jsx +33 -0
  84. data/client/hippo/components/shared/ResizeSensor.jsx +18 -0
  85. data/client/hippo/components/shared/ScreenWrapper.jsx +17 -0
  86. data/client/hippo/components/shared/TextArea.jsx +19 -0
  87. data/client/hippo/components/shared/Throbber.jsx +8 -0
  88. data/client/hippo/components/shared/ToggleField.jsx +2 -0
  89. data/client/hippo/components/shared/Tooltip.jsx +23 -0
  90. data/client/hippo/components/shared/fields.scss +58 -0
  91. data/client/hippo/components/shared/fieldset.scss +27 -0
  92. data/client/hippo/components/shared/image-asset.scss +53 -0
  93. data/client/hippo/components/shared/index.js +5 -0
  94. data/client/hippo/components/shared/overlay.scss +83 -0
  95. data/client/hippo/components/shared/resize-sensor.scss +30 -0
  96. data/client/hippo/components/shared/styles.scss +64 -0
  97. data/client/hippo/components/shared/throbber.scss +53 -0
  98. data/client/hippo/components/toolbar/changes-notification.scss +63 -0
  99. data/client/hippo/components/toolbar/index.js +3 -0
  100. data/client/hippo/components/toolbar/styles.scss +74 -0
  101. data/client/hippo/components/warning-notification.jsx +14 -0
  102. data/client/hippo/config.js +72 -0
  103. data/client/hippo/extensions/EarlyExtensions.js.erb +3 -0
  104. data/client/hippo/extensions/LateLoaded.js.erb +4 -0
  105. data/client/hippo/extensions/base.js +23 -0
  106. data/client/hippo/extensions/hippo.js +11 -0
  107. data/client/hippo/extensions/index.js +47 -0
  108. data/client/hippo/extensions/namespace-available.js.erb +3 -0
  109. data/client/hippo/fonts/fontawesome-webfont.woff +0 -0
  110. data/client/hippo/fonts/fontawesome-webfont.woff2 +0 -0
  111. data/client/hippo/index.js +1 -0
  112. data/client/hippo/index.scss.erb +31 -0
  113. data/client/hippo/lib/__mocks__/loader.js +11 -0
  114. data/client/hippo/lib/__mocks__/request-assets.js +6 -0
  115. data/client/hippo/lib/all.js +14 -0
  116. data/client/hippo/lib/bootstrap.js +45 -0
  117. data/client/hippo/lib/index.js.erb +6 -0
  118. data/client/hippo/lib/loader.js +67 -0
  119. data/client/hippo/lib/request-assets.js +38 -0
  120. data/client/hippo/lib/smooth-scroll.js +68 -0
  121. data/client/hippo/lib/util.js +101 -0
  122. data/client/hippo/models/PubSub.js +208 -0
  123. data/client/hippo/models/__mocks__/sync.js +17 -0
  124. data/client/hippo/models/asset.js +104 -0
  125. data/client/hippo/models/base.js +142 -0
  126. data/client/hippo/models/collection.js +58 -0
  127. data/client/hippo/models/decorators.js +72 -0
  128. data/client/hippo/models/index.js +10 -0
  129. data/client/hippo/models/query.js +116 -0
  130. data/client/hippo/models/query/array-result.js +188 -0
  131. data/client/hippo/models/query/clause.js +52 -0
  132. data/client/hippo/models/query/field.js +63 -0
  133. data/client/hippo/models/query/info.js +43 -0
  134. data/client/hippo/models/query/operator.js +21 -0
  135. data/client/hippo/models/query/result.js +21 -0
  136. data/client/hippo/models/query/types.js +5 -0
  137. data/client/hippo/models/sync.js +135 -0
  138. data/client/hippo/models/system-setting.js +26 -0
  139. data/client/hippo/react/DefaultComponentNotFound.jsx +23 -0
  140. data/client/hippo/react/Root.jsx +24 -0
  141. data/client/hippo/react/index.js +7 -0
  142. data/client/hippo/react/viewport-root.jsx +44 -0
  143. data/client/hippo/screens/all.js.erb +3 -0
  144. data/client/hippo/screens/definition.js +67 -0
  145. data/client/hippo/screens/group.js +35 -0
  146. data/client/hippo/screens/index.js +34 -0
  147. data/client/hippo/screens/instance.js +99 -0
  148. data/client/hippo/screens/mixins/index.js +0 -0
  149. data/client/hippo/screens/register.js.erb +14 -0
  150. data/client/hippo/screens/styles.scss +8 -0
  151. data/client/hippo/screens/system-settings.jsx +92 -0
  152. data/client/hippo/screens/system-settings/mailer-config.jsx +53 -0
  153. data/client/hippo/screens/system-settings/system-settings.scss +8 -0
  154. data/client/hippo/screens/user-management.jsx +67 -0
  155. data/client/hippo/screens/user-management/edit-form.jsx +94 -0
  156. data/client/hippo/screens/user-management/index.scss +7 -0
  157. data/client/hippo/styles/fonts.scss +23 -0
  158. data/client/hippo/styles/fonts/_animated.scss +34 -0
  159. data/client/hippo/styles/fonts/_bordered-pulled.scss +25 -0
  160. data/client/hippo/styles/fonts/_core.scss +12 -0
  161. data/client/hippo/styles/fonts/_fixed-width.scss +6 -0
  162. data/client/hippo/styles/fonts/_icons.scss +789 -0
  163. data/client/hippo/styles/fonts/_larger.scss +13 -0
  164. data/client/hippo/styles/fonts/_list.scss +19 -0
  165. data/client/hippo/styles/fonts/_mixins.scss +60 -0
  166. data/client/hippo/styles/fonts/_path.scss +10 -0
  167. data/client/hippo/styles/fonts/_rotated-flipped.scss +20 -0
  168. data/client/hippo/styles/fonts/_screen-reader.scss +5 -0
  169. data/client/hippo/styles/fonts/_stacked.scss +20 -0
  170. data/client/hippo/styles/fonts/_variables.scss +800 -0
  171. data/client/hippo/styles/fonts/font-awesome.scss +18 -0
  172. data/client/hippo/styles/fonts/index.scss +2 -0
  173. data/client/hippo/styles/global.scss +3 -0
  174. data/client/hippo/styles/global/fancy-header.scss +14 -0
  175. data/client/hippo/styles/global/mixins.scss +5 -0
  176. data/client/hippo/styles/global/styles.scss +6 -0
  177. data/client/hippo/styles/variables.scss +28 -0
  178. data/client/hippo/testing/index.js +6 -0
  179. data/client/hippo/testing/matchers.js +14 -0
  180. data/client/hippo/testing/mocks/fetch.js +54 -0
  181. data/client/hippo/testing/screens.js +64 -0
  182. data/client/hippo/testing/utils.js +1 -0
  183. data/client/hippo/user.js +93 -0
  184. data/client/hippo/workspace/content.jsx +22 -0
  185. data/client/hippo/workspace/foo.js +0 -0
  186. data/client/hippo/workspace/index.jsx +85 -0
  187. data/client/hippo/workspace/menu-group.jsx +39 -0
  188. data/client/hippo/workspace/menu-option.jsx +41 -0
  189. data/client/hippo/workspace/menu.jsx +71 -0
  190. data/client/hippo/workspace/navbar.jsx +46 -0
  191. data/client/hippo/workspace/screen.jsx +50 -0
  192. data/client/hippo/workspace/styles.scss +61 -0
  193. data/client/hippo/workspace/styles/forms.scss +4 -0
  194. data/client/hippo/workspace/styles/header.scss +69 -0
  195. data/client/hippo/workspace/styles/keybindings.scss +6 -0
  196. data/client/hippo/workspace/styles/layout.scss +230 -0
  197. data/client/hippo/workspace/styles/screens.scss +15 -0
  198. data/client/hippo/workspace/styles/tabs.scss +141 -0
  199. data/client/hippo/workspace/tabs.jsx +60 -0
  200. data/client/hippo/workspace/viewport.jsx +82 -0
  201. data/client/images/hippo/ajax-loader.gif +0 -0
  202. data/client/images/hippo/logo-sm.png +0 -0
  203. data/coffeelint.json +49 -0
  204. data/command-reference-files/initial/.babelrc +20 -0
  205. data/command-reference-files/initial/.eslintrc.js +7 -0
  206. data/command-reference-files/initial/.gitignore +4 -0
  207. data/command-reference-files/initial/.rubocop.yml +9 -0
  208. data/command-reference-files/initial/Gemfile +9 -0
  209. data/command-reference-files/initial/Guardfile +13 -0
  210. data/command-reference-files/initial/Rakefile +2 -0
  211. data/command-reference-files/initial/client/appy-app/components/.gitkeep +0 -0
  212. data/command-reference-files/initial/client/appy-app/extension.js +32 -0
  213. data/command-reference-files/initial/client/appy-app/index.js +6 -0
  214. data/command-reference-files/initial/client/appy-app/models/.gitkeep +0 -0
  215. data/command-reference-files/initial/client/appy-app/models/base.js +11 -0
  216. data/command-reference-files/initial/client/appy-app/screens/.gitkeep +0 -0
  217. data/command-reference-files/initial/client/appy-app/styles.scss +1 -0
  218. data/command-reference-files/initial/config.ru +7 -0
  219. data/command-reference-files/initial/config/database.yml +11 -0
  220. data/command-reference-files/initial/config/initialize.rb +10 -0
  221. data/command-reference-files/initial/config/jest.config.json +19 -0
  222. data/command-reference-files/initial/config/jest/babel-transform.js +47 -0
  223. data/command-reference-files/initial/config/routes.rb +4 -0
  224. data/command-reference-files/initial/config/screens.rb +10 -0
  225. data/command-reference-files/initial/config/webpack.config.js +106 -0
  226. data/command-reference-files/initial/db/.gitkeep +0 -0
  227. data/command-reference-files/initial/lib/appy-app.rb +15 -0
  228. data/command-reference-files/initial/lib/appy-app/extension.rb +22 -0
  229. data/command-reference-files/initial/lib/appy-app/model.rb +11 -0
  230. data/command-reference-files/initial/lib/appy-app/version.rb +3 -0
  231. data/command-reference-files/initial/package.json +6 -0
  232. data/command-reference-files/initial/spec/client/.eslintrc.js +20 -0
  233. data/command-reference-files/initial/spec/client/setup.js +17 -0
  234. data/command-reference-files/initial/spec/server/spec_helper.rb +8 -0
  235. data/command-reference-files/initial/views/index.html +69 -0
  236. data/command-reference-files/model/client/appy-app/models/test_test.js +12 -0
  237. data/command-reference-files/model/config/routes.rb +4 -0
  238. data/command-reference-files/model/db/migrate/20150218032025_create_test_tests.rb +10 -0
  239. data/command-reference-files/model/lib/appy-app/model.rb +12 -0
  240. data/command-reference-files/model/lib/appy-app/models/test_test.rb +7 -0
  241. data/command-reference-files/model/spec/client/models/test_test.spec.js +8 -0
  242. data/command-reference-files/model/spec/fixtures/appy-app/test_test.yml +11 -0
  243. data/command-reference-files/model/spec/server/test_test_spec.rb +10 -0
  244. data/command-reference-files/screen/client/appy-app/extension.js +32 -0
  245. data/command-reference-files/screen/client/appy-app/screens/ready-set-go.jsx +22 -0
  246. data/command-reference-files/screen/config/screens.rb +19 -0
  247. data/command-reference-files/screen/spec/client/screens/ready-set-go.spec.jsx +12 -0
  248. data/config.ru +5 -0
  249. data/config/database.yml +9 -0
  250. data/config/jest.config.json +27 -0
  251. data/config/jest/babel-transform.js +47 -0
  252. data/config/jest/style-mock.js +2 -0
  253. data/config/jest/yaml-transform.js +19 -0
  254. data/config/routes.rb +28 -0
  255. data/config/screens.rb +42 -0
  256. data/config/webpack.config.js +105 -0
  257. data/db/migrate/01_create_system_settings.rb +10 -0
  258. data/db/migrate/02_create_assets.rb +13 -0
  259. data/db/migrate/20140615031600_create_users.rb +12 -0
  260. data/db/seed.rb +1 -0
  261. data/docs/command.md +114 -0
  262. data/docs/model.md +217 -0
  263. data/docs/react.md +137 -0
  264. data/docs/todo-example-part-1.md +69 -0
  265. data/docs/welcome.md +0 -0
  266. data/hippo-fw.gemspec +79 -0
  267. data/lib/generators/hippo/migrations/install_generator.rb +42 -0
  268. data/lib/hippo-fw.rb +1 -0
  269. data/lib/hippo.rb +34 -0
  270. data/lib/hippo/access.rb +49 -0
  271. data/lib/hippo/access/authentication_provider.rb +79 -0
  272. data/lib/hippo/access/config/database.yml +9 -0
  273. data/lib/hippo/access/config/routes.rb +20 -0
  274. data/lib/hippo/access/locked_fields.rb +43 -0
  275. data/lib/hippo/access/public/files/1nty/7ebo/n7k0/8b2ac0bbd97f401951fe40546f977200.png +0 -0
  276. data/lib/hippo/access/public/files/6hgp/eiw1/8dua/ba944287e36e101713a9c1ad793353b8.png +0 -0
  277. data/lib/hippo/access/public/files/94bd/9agc/2ua3/33800e285d7145760650ac88d1c558fb.png +0 -0
  278. data/lib/hippo/access/public/files/cr1e/vfwc/fvrh/0e7fe6ef12d622bfb93e024883c2f81c.png +0 -0
  279. data/lib/hippo/access/public/files/kezo/fm8j/u6xl/dfc47658aedd8e546abff63366a7285d.png +0 -0
  280. data/lib/hippo/access/public/files/n5c4/uovf/jec6/7ee9a3519e2b60430e095160a23f1d77.png +0 -0
  281. data/lib/hippo/access/role.rb +86 -0
  282. data/lib/hippo/access/role_collection.rb +88 -0
  283. data/lib/hippo/access/roles/administrator.rb +32 -0
  284. data/lib/hippo/access/roles/basic_user.rb +13 -0
  285. data/lib/hippo/access/roles/support.rb +15 -0
  286. data/lib/hippo/access/test_fixture_extensions.rb +16 -0
  287. data/lib/hippo/access/track_modifications.rb +79 -0
  288. data/lib/hippo/access/version.rb +5 -0
  289. data/lib/hippo/api.rb +23 -0
  290. data/lib/hippo/api/cable.rb +57 -0
  291. data/lib/hippo/api/controller_base.rb +299 -0
  292. data/lib/hippo/api/default_routes.rb +38 -0
  293. data/lib/hippo/api/error_formatter.rb +37 -0
  294. data/lib/hippo/api/formatted_reply.rb +62 -0
  295. data/lib/hippo/api/generic_controller.rb +35 -0
  296. data/lib/hippo/api/handlers/asset.rb +38 -0
  297. data/lib/hippo/api/handlers/print.rb +15 -0
  298. data/lib/hippo/api/handlers/user_session.rb +42 -0
  299. data/lib/hippo/api/helper_methods.rb +58 -0
  300. data/lib/hippo/api/pub_sub.rb +36 -0
  301. data/lib/hippo/api/request_wrapper.rb +105 -0
  302. data/lib/hippo/api/root.rb +70 -0
  303. data/lib/hippo/api/routing.rb +111 -0
  304. data/lib/hippo/api/sprockets_extension.rb +105 -0
  305. data/lib/hippo/api/to_json.rb +7 -0
  306. data/lib/hippo/api/updates.rb +37 -0
  307. data/lib/hippo/asset.rb +18 -0
  308. data/lib/hippo/capistrano.rb +30 -0
  309. data/lib/hippo/cli.rb +50 -0
  310. data/lib/hippo/command.rb +43 -0
  311. data/lib/hippo/command/app.rb +90 -0
  312. data/lib/hippo/command/client_config.rb +69 -0
  313. data/lib/hippo/command/client_model_update.rb +65 -0
  314. data/lib/hippo/command/console.rb +23 -0
  315. data/lib/hippo/command/db.rb +36 -0
  316. data/lib/hippo/command/db.usage +1 -0
  317. data/lib/hippo/command/generate.rb +24 -0
  318. data/lib/hippo/command/generate_component.rb +28 -0
  319. data/lib/hippo/command/generate_component.usage +11 -0
  320. data/lib/hippo/command/generate_migration.rb +33 -0
  321. data/lib/hippo/command/generate_model.rb +91 -0
  322. data/lib/hippo/command/generate_model.usage +45 -0
  323. data/lib/hippo/command/generate_screen.rb +40 -0
  324. data/lib/hippo/command/generate_screen.usage +8 -0
  325. data/lib/hippo/command/guard.rb +18 -0
  326. data/lib/hippo/command/jest.rb +40 -0
  327. data/lib/hippo/command/migration_support.rb +29 -0
  328. data/lib/hippo/command/model_attribute.rb +193 -0
  329. data/lib/hippo/command/named_command.rb +33 -0
  330. data/lib/hippo/command/puma.rb +56 -0
  331. data/lib/hippo/command/server.rb +19 -0
  332. data/lib/hippo/command/server.usage +3 -0
  333. data/lib/hippo/command/update.rb +13 -0
  334. data/lib/hippo/command/update_model.rb +127 -0
  335. data/lib/hippo/command/update_model.usage +2 -0
  336. data/lib/hippo/command/webpack.rb +57 -0
  337. data/lib/hippo/command/webpack_view.rb +32 -0
  338. data/lib/hippo/concerns/all.rb +15 -0
  339. data/lib/hippo/concerns/api_path.rb +21 -0
  340. data/lib/hippo/concerns/asset_uploader.rb +38 -0
  341. data/lib/hippo/concerns/association_extensions.rb +94 -0
  342. data/lib/hippo/concerns/attr_accessor_with_default.rb +68 -0
  343. data/lib/hippo/concerns/code_identifier.rb +43 -0
  344. data/lib/hippo/concerns/export_associations.rb +52 -0
  345. data/lib/hippo/concerns/export_join_tables.rb +39 -0
  346. data/lib/hippo/concerns/export_methods.rb +104 -0
  347. data/lib/hippo/concerns/export_scope.rb +64 -0
  348. data/lib/hippo/concerns/exported_limit_evaluator.rb +17 -0
  349. data/lib/hippo/concerns/pub_sub.rb +127 -0
  350. data/lib/hippo/concerns/queries.rb +24 -0
  351. data/lib/hippo/concerns/random_identifier.rb +37 -0
  352. data/lib/hippo/concerns/sanitize_fields.rb +32 -0
  353. data/lib/hippo/concerns/set_attribute_data.rb +125 -0
  354. data/lib/hippo/concerns/sorting_expressions.rb +34 -0
  355. data/lib/hippo/configuration.rb +143 -0
  356. data/lib/hippo/db.rb +57 -0
  357. data/lib/hippo/db/migrations.rb +32 -0
  358. data/lib/hippo/environment.rb +22 -0
  359. data/lib/hippo/extension.rb +112 -0
  360. data/lib/hippo/extension/definition.rb +90 -0
  361. data/lib/hippo/guard_tasks.rb +62 -0
  362. data/lib/hippo/hippo_guard_plugin.rb +80 -0
  363. data/lib/hippo/job.rb +82 -0
  364. data/lib/hippo/job/failure_logger.rb +33 -0
  365. data/lib/hippo/logger.rb +64 -0
  366. data/lib/hippo/mailer.rb +28 -0
  367. data/lib/hippo/model.rb +24 -0
  368. data/lib/hippo/multi_server_boot.rb +26 -0
  369. data/lib/hippo/numbers.rb +72 -0
  370. data/lib/hippo/rails_engine.rb +5 -0
  371. data/lib/hippo/rake_tasks.rb +69 -0
  372. data/lib/hippo/redis.rb +13 -0
  373. data/lib/hippo/reloadable_sinatra.rb +24 -0
  374. data/lib/hippo/reloadable_view.rb +13 -0
  375. data/lib/hippo/screen.rb +152 -0
  376. data/lib/hippo/spec_helper.rb +141 -0
  377. data/lib/hippo/strings.rb +56 -0
  378. data/lib/hippo/system_settings.rb +72 -0
  379. data/lib/hippo/templates/base.rb +44 -0
  380. data/lib/hippo/templates/latex.rb +101 -0
  381. data/lib/hippo/templates/liquid.rb +28 -0
  382. data/lib/hippo/user.rb +152 -0
  383. data/lib/hippo/validators/all.rb +2 -0
  384. data/lib/hippo/validators/email.rb +17 -0
  385. data/lib/hippo/validators/set.rb +18 -0
  386. data/lib/hippo/version.rb +5 -0
  387. data/lib/hippo/workspace.rb +4 -0
  388. data/lib/hippo/workspace/config/screens.rb +6 -0
  389. data/package.json +82 -0
  390. data/spec/client/.eslintrc.js +20 -0
  391. data/spec/client/access/login-dialog.spec.jsx +28 -0
  392. data/spec/client/components/__snapshots__/asset.spec.jsx.snap +48 -0
  393. data/spec/client/components/__snapshots__/network-activity-overlay.spec.jsx.snap +35 -0
  394. data/spec/client/components/__snapshots__/query-builder.spec.jsx.snap +82 -0
  395. data/spec/client/components/asset.spec.jsx +16 -0
  396. data/spec/client/components/data-list.spec.jsx +36 -0
  397. data/spec/client/components/data-table.spec.jsx +55 -0
  398. data/spec/client/components/form.spec.jsx +63 -0
  399. data/spec/client/components/network-activity-overlay.spec.jsx +30 -0
  400. data/spec/client/components/query-builder.spec.jsx +45 -0
  401. data/spec/client/components/record-finder.spec.jsx +45 -0
  402. data/spec/client/extension/base.spec.js +15 -0
  403. data/spec/client/lib/util.spec.js +48 -0
  404. data/spec/client/models/asset.spec.js +50 -0
  405. data/spec/client/models/base.spec.js +95 -0
  406. data/spec/client/models/collection.spec.js +51 -0
  407. data/spec/client/models/query.spec.js +243 -0
  408. data/spec/client/models/sync.spec.js +42 -0
  409. data/spec/client/models/system-setting.spec.js +19 -0
  410. data/spec/client/screens/__snapshots__/system-settings.spec.jsx.snap +364 -0
  411. data/spec/client/screens/__snapshots__/tabs.spec.jsx.snap +127 -0
  412. data/spec/client/screens/definition.spec.js +24 -0
  413. data/spec/client/screens/group.spec.js +33 -0
  414. data/spec/client/screens/instance.spec.js +61 -0
  415. data/spec/client/screens/system-settings.spec.jsx +22 -0
  416. data/spec/client/screens/tabs.spec.jsx +36 -0
  417. data/spec/client/screens/user-management.spec.jsx +48 -0
  418. data/spec/client/setup.js +12 -0
  419. data/spec/client/test-logo.json +41 -0
  420. data/spec/client/test-models.js +94 -0
  421. data/spec/client/user.spec.js +19 -0
  422. data/spec/client/workspace/__snapshots__/menu.spec.jsx.snap +380 -0
  423. data/spec/client/workspace/menu.spec.jsx +52 -0
  424. data/spec/factories/user.rb +11 -0
  425. data/spec/fixtures/logo.png +0 -0
  426. data/spec/fixtures/system_settings.yml +8 -0
  427. data/spec/fixtures/test_printer.tex +22 -0
  428. data/spec/fixtures/user.yml +2 -0
  429. data/spec/hippo/components/grid/GridSpec.coffee +56 -0
  430. data/spec/hippo/components/grid/PopoverEditorSpec.coffee +47 -0
  431. data/spec/hippo/components/grid/RowEditorSpec.coffee +98 -0
  432. data/spec/hippo/components/select-field/SelectFieldSpec.coffee +106 -0
  433. data/spec/hippo/components/shared/NetworkActivityOverlaySpec.coffee +34 -0
  434. data/spec/hippo/helpers/.gitkeep +0 -0
  435. data/spec/hippo/helpers/hippo-helpers.coffee +5 -0
  436. data/spec/hippo/helpers/jasmine-matchers.js +1580 -0
  437. data/spec/hippo/helpers/mock-ajax.js +573 -0
  438. data/spec/hippo/models/AssociationMapSpec.coffee +85 -0
  439. data/spec/hippo/models/AssociationProxySpec.coffee +76 -0
  440. data/spec/hippo/models/BaseSpec.coffee +155 -0
  441. data/spec/hippo/models/CollectionSpec.coffee +32 -0
  442. data/spec/hippo/models/EnumMapSpec.coffee +26 -0
  443. data/spec/hippo/models/PubSubSpec.coffee +71 -0
  444. data/spec/hippo/models/QuerySpec.coffee +19 -0
  445. data/spec/hippo/models/SyncSpec.coffee +28 -0
  446. data/spec/hippo/models/UserSpec.coffee +17 -0
  447. data/spec/hippo/react/mixins/DataSpec.coffee +74 -0
  448. data/spec/hippo/screens/DefinitionsSpec.coffee +33 -0
  449. data/spec/hippo/views/BaseSpec.coffee +147 -0
  450. data/spec/hippo/views/FormBindingsSpec.coffee +32 -0
  451. data/spec/server/api/controller_base_spec.rb +101 -0
  452. data/spec/server/assertions.rb +11 -0
  453. data/spec/server/asset_spec.rb +42 -0
  454. data/spec/server/command_spec.rb +73 -0
  455. data/spec/server/concerns/api_path_spec.rb +20 -0
  456. data/spec/server/concerns/association_extensions_spec.rb +24 -0
  457. data/spec/server/concerns/attr_accessor_with_default_spec.rb +63 -0
  458. data/spec/server/concerns/export_methods_spec.rb +34 -0
  459. data/spec/server/concerns/export_scope_spec.rb +14 -0
  460. data/spec/server/concerns/exported_limits_spec.rb +51 -0
  461. data/spec/server/concerns/pub_sub_spec.rb +132 -0
  462. data/spec/server/concerns/set_attribute_data_spec.rb +76 -0
  463. data/spec/server/concerns/sorting_expressions_spec.rb +34 -0
  464. data/spec/server/concerns/track_modifications_spec.rb +18 -0
  465. data/spec/server/configuration_spec.rb +26 -0
  466. data/spec/server/job_spec.rb +54 -0
  467. data/spec/server/mailer_spec.rb +33 -0
  468. data/spec/server/numbers_spec.rb +25 -0
  469. data/spec/server/print/form_spec.rb +29 -0
  470. data/spec/server/spec_helper.rb +74 -0
  471. data/spec/server/strings_spec.rb +41 -0
  472. data/spec/server/system_settings_spec.rb +39 -0
  473. data/tasks/migrations.rake +22 -0
  474. data/tasks/publish.rake +8 -0
  475. data/templates/.babelrc +20 -0
  476. data/templates/.gitignore +4 -0
  477. data/templates/Gemfile +9 -0
  478. data/templates/Guardfile +13 -0
  479. data/templates/Rakefile +2 -0
  480. data/templates/client/components/.gitkeep +0 -0
  481. data/templates/client/components/BaseComponent.coffee +9 -0
  482. data/templates/client/components/Component.cjsx +4 -0
  483. data/templates/client/components/template.html +3 -0
  484. data/templates/client/extension.js +32 -0
  485. data/templates/client/index.js +6 -0
  486. data/templates/client/models/base.js +11 -0
  487. data/templates/client/models/model.js +17 -0
  488. data/templates/client/screens/screen.jsx +22 -0
  489. data/templates/client/styles.scss +1 -0
  490. data/templates/config.ru +7 -0
  491. data/templates/config/database.yml +11 -0
  492. data/templates/config/initialize.rb +10 -0
  493. data/templates/config/jest.config.json +19 -0
  494. data/templates/config/jest/babel-transform.js +47 -0
  495. data/templates/config/routes.rb +4 -0
  496. data/templates/config/screen.rb +9 -0
  497. data/templates/config/screens.rb +10 -0
  498. data/templates/config/webpack.config.js +106 -0
  499. data/templates/db/create_table_migration.rb +19 -0
  500. data/templates/gitignore +4 -0
  501. data/templates/js/config-data.js +10 -0
  502. data/templates/js/jest.config.json +11 -0
  503. data/templates/js/root-view.html +71 -0
  504. data/templates/js/screen-definitions.js +22 -0
  505. data/templates/lib/namespace.rb +15 -0
  506. data/templates/lib/namespace/base_model.rb +11 -0
  507. data/templates/lib/namespace/extension.rb +22 -0
  508. data/templates/lib/namespace/model.rb +7 -0
  509. data/templates/lib/namespace/version.rb +3 -0
  510. data/templates/public/.gitkeep +0 -0
  511. data/templates/spec/client/components/ComponentSpec.coffee +5 -0
  512. data/templates/spec/client/models/model.spec.js +8 -0
  513. data/templates/spec/client/screen.spec.jsx +12 -0
  514. data/templates/spec/client/setup.js +17 -0
  515. data/templates/spec/fixtures/namespace/model.yml +16 -0
  516. data/templates/spec/server/model_spec.rb +10 -0
  517. data/templates/spec/server/spec_helper.rb +8 -0
  518. data/test.js +7 -0
  519. data/views/hippo_root_view.erb +68 -0
  520. data/views/index.html +71 -0
  521. data/yard_ext/all.rb +9 -0
  522. data/yard_ext/code_identifier_handler.rb +33 -0
  523. data/yard_ext/concern_meta_methods.rb +60 -0
  524. data/yard_ext/config_options.rb +27 -0
  525. data/yard_ext/exported_scope.rb +4 -0
  526. data/yard_ext/immutable_handler.rb +17 -0
  527. data/yard_ext/json_attr_accessor.rb +22 -0
  528. data/yard_ext/locked_fields_handler.rb +21 -0
  529. data/yard_ext/templates/default/layout/html/layout.erb +20 -0
  530. data/yard_ext/templates/default/method_details/html/github_link.erb +1 -0
  531. data/yard_ext/templates/default/method_details/setup.rb +3 -0
  532. data/yard_ext/validators.rb +1 -0
  533. data/yard_ext/visible_id_handler.rb +38 -0
  534. data/yarn.lock +6562 -0
  535. metadata +1182 -0
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+ factory :user, class: Hippo::User do
3
+ name { Faker::Name.name }
4
+ email { Faker::Internet.email }
5
+ login { Faker::Internet.user_name }
6
+
7
+ password 'password'
8
+ password_confirmation 'password'
9
+ role_names ['administrator']
10
+ end
11
+ end
Binary file
@@ -0,0 +1,8 @@
1
+ default:
2
+ id: 1
3
+ settings:
4
+ hippo:
5
+ smtp:
6
+ server: test.test.test
7
+ login: 'test'
8
+ password: 'test'
@@ -0,0 +1,22 @@
1
+ \documentclass[12pt]{article}
2
+ \begin{document}
3
+ Some work from stories others from requirements,
4
+ If we are lucky the analysts have thought of resources and environments!!
5
+ Does this field accept a digit, a letter or a hash?
6
+ What happens if I inject something here a comma or slash?
7
+
8
+ How about testing stress, load or capacity?
9
+ I've found a bug developer please don't be mad at me.
10
+ It works on your system? Well it doesn't on mine,
11
+ If you take a look and fix it I'm sure production be fine.
12
+
13
+ Is it secure or can someone break in?
14
+ Mess with the system send it in a spin.
15
+ Will it failover gracefully and alert you of issues,
16
+ Make supporting the system simple and report any misuse.
17
+
18
+ Can this talk to that and do it in time?
19
+ Oh God will the users like it and think its sublime.
20
+ Does it do what they want or is it worse than they've got?
21
+ After all of this testing I bloody hope not.
22
+ \end{document}
@@ -0,0 +1,2 @@
1
+ test:
2
+ login: test
@@ -0,0 +1,56 @@
1
+ #= require hippo/components/grid
2
+
3
+
4
+ DATA = {total:2, success:true, message:"Retrieve succeeded", data:[
5
+ [1, "TEST1", "Nathan Stitt", "swell guy"]
6
+ [2, "TEST2", "Nathan Stitt", "Dupe of id #1"]
7
+ ]}
8
+
9
+ Model = Hippo.Test.defineModel(
10
+ props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
11
+ )
12
+
13
+ renderGrid = (q, done) ->
14
+ loaded = spyOn(q.results, 'ensureLoaded').and.callThrough()
15
+ grid = LT.renderComponent(LC.Grid, props: query: q)
16
+ expect(loaded).toHaveBeenCalled()
17
+ _.defer ->
18
+ expect(_.dom(grid).qs('.r').el).not.toBeNull()
19
+ done()
20
+
21
+
22
+ describe "Hippo.Components.Grid", ->
23
+
24
+ beforeEach (done) ->
25
+ LT.syncRespondWith(DATA)
26
+ @query = new Hippo.Models.Query(
27
+ src: Model, fields: [ 'id', 'code', 'name', 'notes' ]
28
+ )
29
+ @collection = new Model.Collection
30
+ @query.ensureLoaded().then => @collection.ensureLoaded().then -> done()
31
+
32
+ describe "loading", ->
33
+
34
+ it "from a result set", (d) ->
35
+ renderGrid(@query, d)
36
+
37
+ it "from a collection", (d) ->
38
+ @query.src = @collection
39
+ renderGrid(@query, d)
40
+
41
+ it 'renders toolbar', ->
42
+ grid = LT.renderComponent(LC.Grid, props: {
43
+ query: @query, editor: true, allowCreate: true
44
+ })
45
+ tb = _.dom(grid).qs('.toolbar')
46
+ expect(tb).not.toBeUndefined()
47
+
48
+ it 'notifies when selection changes', (done) ->
49
+ spy = jasmine.createSpy('selection')
50
+ grid = LT.renderComponent(LC.Grid, props: {
51
+ query: @query, editor: true, onSelectionChange: spy
52
+ })
53
+ _.defer ->
54
+ _.dom(grid).qs('.grid-body .c').click()
55
+ expect(spy).toHaveBeenCalled()
56
+ done()
@@ -0,0 +1,47 @@
1
+ #= require hippo/components/grid
2
+
3
+
4
+ DATA = {total:2, success:true, message:"Retrieve succeeded", data:[
5
+ [1, "TEST1", "Nathan Stitt", "swell guy"]
6
+ [2, "TEST2", "Nathan Stitt", "Dupe of id #1"]
7
+ ]}
8
+
9
+ Model = Hippo.Test.defineModel(
10
+ props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
11
+ )
12
+
13
+ LAST_ROW_SELECTOR = '.grid-body .r:last-child'
14
+ ADD_ROW_SELECTOR = 'button.add-row'
15
+
16
+ describe "Hippo.Components.Grid.PopoverEditor", ->
17
+
18
+ beforeEach (done) ->
19
+ LT.syncRespondWith(DATA)
20
+ @query = new Hippo.Models.Query(
21
+ src: Model, fields: [ 'id', 'code', 'name', 'notes' ]
22
+ )
23
+ @query.ensureLoaded().then =>
24
+ @grid = LT.renderComponent(LC.Grid, props: {
25
+ allowCreate: true, editor: Hippo.Components.Grid.PopoverEditor, query: @query
26
+ })
27
+ done()
28
+
29
+ it "edits", (done) ->
30
+ _.dom(@grid).qs(LAST_ROW_SELECTOR).click(clientX: 5)
31
+ editor = Hippo.Test.Utils.findRenderedComponentWithType(
32
+ @grid, Hippo.Components.Grid.PopoverEditor
33
+ )
34
+ _.dom(editor).qs('.field:nth-of-type(3) input').setValue('BOB')
35
+ _.dom(editor).qs('.btn.save').click()
36
+ expect( @query.results.rowAt(1)[2] ).toEqual('BOB')
37
+ done()
38
+
39
+ it 'adds row', (done) ->
40
+ _.dom(@grid).qs(ADD_ROW_SELECTOR).click()
41
+ editor = Hippo.Test.Utils.findRenderedComponentWithType(
42
+ @grid, Hippo.Components.Grid.PopoverEditor
43
+ )
44
+ _.dom(editor).qs('.field:nth-of-type(3) input').setValue('BOB')
45
+ _.dom(editor).qs('.btn.save').click()
46
+ expect( @query.results.rowAt(0)[2] ).toEqual('BOB')
47
+ done()
@@ -0,0 +1,98 @@
1
+ #= require hippo/components/grid
2
+
3
+ COLLECTION_DATA = [
4
+ {id:1, code:'TEST1', name: 'Nathan Stitt', notes: 'swell guy'}
5
+ {id:2, code:'TEST2', name: 'Nathan Stitt', notes: 'Dupe of id #1'}
6
+ ]
7
+
8
+ ROW_DATA = _.map COLLECTION_DATA, (r) -> _.values(r)
9
+
10
+ Model = Hippo.Test.defineModel(
11
+ props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
12
+ )
13
+
14
+ LAST_ROW_SELECTOR = '.grid-body .r:last-child'
15
+ ADD_ROW_SELECTOR = 'button.add-row'
16
+
17
+ RenderGrid = (q) ->
18
+ LT.renderComponent(LC.Grid, props: {
19
+ query: q, editor: true, allowCreate: true
20
+ })
21
+
22
+ RenderEdit = (q, value) ->
23
+ Hippo.Test.syncSucceedWith(ROW_DATA)
24
+ grid = RenderGrid(q)
25
+
26
+ new _.Promise (res, rej) -> _.defer ->
27
+ _.dom(grid).qs(LAST_ROW_SELECTOR).click()
28
+ editor = Hippo.Test.Utils.findRenderedComponentWithType(
29
+ grid, Hippo.Components.Grid.RowEditor
30
+ )
31
+ _.dom(editor).qs('.field:nth-of-type(2) input').change(target: {value})
32
+ res({grid, editor})
33
+
34
+
35
+
36
+ CommonSpecs = ->
37
+
38
+ it 'sets the props', (done) ->
39
+ grid = LT.renderComponent(LC.Grid, props: {
40
+ query: @query, editor: true
41
+ })
42
+ _.defer ->
43
+ _.dom(grid).qs(LAST_ROW_SELECTOR).click()
44
+ editor = Hippo.Test.Utils.findRenderedComponentWithType(grid, LC.Grid.RowEditor)
45
+ expect(editor.props.rowIndex).toEqual(1)
46
+ expect(editor.props.model).toEqual(jasmine.any(Model))
47
+ expect(editor.props.model.id).toEqual(2)
48
+ done()
49
+
50
+ it 'can edit', (done) ->
51
+ RenderEdit(@query, 'BOB').then ({editor}) =>
52
+ _.dom(editor).qs('.btn.save').click()
53
+ expect( @query.results.rowAt(1)[1] ).toEqual('BOB')
54
+ done()
55
+
56
+ it 'does not update when edit is canceled', (done) ->
57
+ expect( @query.results.rowAt(1)[1] ).toEqual('TEST2')
58
+ RenderEdit(@query, 'CANCKED').then ({editor}) =>
59
+ _.dom(editor).qs('.btn.cancel').click()
60
+ expect( @query.results.rowAt(1)[1] ).toEqual('TEST2')
61
+ done()
62
+
63
+ it 'removes an unsaved row when editing is canceled', (done) ->
64
+ grid = RenderGrid(@query)
65
+ _.defer =>
66
+ addRow = spyOn(@query.results, 'addBlankRow').and.callThrough()
67
+ removeRow = spyOn(@query.results, 'removeRow').and.callThrough()
68
+ expect(@query.results.length).toEqual(2)
69
+ _.dom(grid).qs(ADD_ROW_SELECTOR).click()
70
+ expect(@query.results.addBlankRow).toHaveBeenCalled()
71
+ editor = Hippo.Test.Utils.findRenderedComponentWithType(
72
+ grid, Hippo.Components.Grid.RowEditor
73
+ )
74
+ expect(@query.results.length).toEqual(3)
75
+ _.dom(editor).qs('.btn.cancel').click()
76
+ expect(@query.results.removeRow).toHaveBeenCalled()
77
+ expect(@query.results.length).toEqual(2)
78
+ done()
79
+
80
+ describe "Hippo.Components.Grid.RowEditor", ->
81
+
82
+ describe "using row based result set", ->
83
+ beforeEach (done) ->
84
+ @query = new Hippo.Models.Query(
85
+ fields: [ 'id', 'code', 'name', 'notes' ], src: Model
86
+ )
87
+ Hippo.Test.syncSucceedWith(ROW_DATA)
88
+ @query.ensureLoaded().then(done)
89
+ CommonSpecs()
90
+
91
+
92
+ describe "using a collection", ->
93
+ beforeEach ->
94
+ @query = new Hippo.Models.Query(
95
+ fields: [ 'id', 'code', 'name', 'notes' ],
96
+ src: new Model.Collection(COLLECTION_DATA)
97
+ )
98
+ CommonSpecs()
@@ -0,0 +1,106 @@
1
+ #= require hippo/components/select-field
2
+
3
+ Brand = Hippo.Test.defineModel(
4
+ props: {id: 'integer', code: 'string', name: 'string'}
5
+ )
6
+
7
+ BRAND_DATA = {total:3, success:true, message:"Retrieve succeeded", data:[
8
+ {id: 1, code: "GM", name: "General Motors"}
9
+ {id: 2, code: "FORD", name: "Ford Motor Co."}
10
+ {id: 3, code: "DODGE", name: "Chrysler/Dodge"}
11
+ ]}
12
+
13
+ VALUE_CLASS = '.form-control-static'
14
+
15
+ Car = Hippo.Test.defineModel(
16
+ props: {id: 'integer', code: 'string', brand_id: 'integer'}
17
+ session:
18
+ carTypes: 'array'
19
+
20
+ associations:
21
+ brand: {model: Brand}
22
+ )
23
+
24
+ describe "Hippo.Components.SelectField", ->
25
+ beforeEach (done) ->
26
+ @car = new Car
27
+ LT.syncRespondWith(BRAND_DATA)
28
+ @brands = new Brand.Collection
29
+ @brands.ensureLoaded().then(done)
30
+
31
+ it "renders read only", (done) ->
32
+ sf = LT.renderComponent(LC.SelectField,
33
+ props:{model: @car, name: 'brand', labelField: 'name'})
34
+ expect(_.dom(sf).qs(VALUE_CLASS).text).toBe('')
35
+ @car.set(brand: @brands.at(0))
36
+ _.defer ->
37
+ expect(_.dom(sf).qs(VALUE_CLASS).text).toBe('General Motors')
38
+ done()
39
+
40
+ it "renders as edit", ->
41
+ @car.set(brand: @brands.at(1))
42
+ sf = LT.renderComponent(LC.SelectField, props:{
43
+ model: @car, name: 'brand', labelField: 'name',
44
+ editOnly: true, collection: @brands })
45
+ expect(_.dom(sf).qs('input[type=text]').value).toEqual('Ford Motor Co.')
46
+
47
+ it 'uses a custom data source', (done) ->
48
+ sf = LT.renderComponent(LC.SelectField, props:{
49
+ model: @car, name: 'brand', editOnly: true
50
+ value: 4, choices: [{ label: 'Toyota', id: 4 }]
51
+ })
52
+ _.defer ->
53
+ expect(_.dom(sf).qs('input[type=text]').value).toEqual('Toyota')
54
+ done()
55
+
56
+ it 'sets value when changed', ->
57
+ @car.set(brand: @brands.at(1))
58
+ sf = LT.renderComponent(LC.SelectField, props:{
59
+ model: @car, name: 'brand', labelField: 'name',
60
+ fetchOnSelect: false, editOnly: true, choices: @brands.models
61
+ })
62
+ _.dom(sf).qs('.rw-select').click()
63
+ _.dom(sf).qs('.rw-list li:last-child').click()
64
+ expect(@car.brand.code).toEqual('DODGE')
65
+
66
+ it 'can select multiple values', (done) ->
67
+ sf = LT.renderComponent(LC.SelectField, props:{
68
+ queryModel: Car,
69
+ multiSelect: true, model: @car, name: 'carTypes', fetchOnSelect: false
70
+ labelField: 'name', editOnly: true, choices: @brands.models
71
+ })
72
+
73
+ _.dom(sf).qs('.rw-input').focus()
74
+ _.defer =>
75
+ expect( _.dom(sf).qsa('.rw-list li').length ).toEqual(@brands.length)
76
+ _.dom(sf).qs('.rw-list-option:nth-child(1)').click()
77
+ _.dom(sf).qs('.rw-input').focus()
78
+ _.dom(sf).qs('.rw-list-option:nth-child(2)').click()
79
+ expect(_.map(@car.carTypes, 'id')).toEqual([1, 3])
80
+ done()
81
+
82
+ it 'renders label for single values', ->
83
+ @car.set(brand: @brands.last())
84
+ sf = LT.renderComponent(LC.SelectField, props:{
85
+ model: @car, name: 'brand', labelField: 'name',
86
+ choices: @brands.models
87
+ })
88
+ expect(_.dom(sf).qs(VALUE_CLASS).text).toEqual('Chrysler/Dodge')
89
+
90
+ it 'renders label for multiple values', ->
91
+ @car.carTypes = [ @brands.at(0), @brands.at(2) ]
92
+ sf = LT.renderComponent(LC.SelectField, props:{
93
+ queryModel: Car, multiSelect: true, model: @car, name: 'carTypes'
94
+ labelField: 'name', choices: @brands.models
95
+ })
96
+ expect(_.dom(sf).qs(VALUE_CLASS).text).toEqual('General Motors and Chrysler/Dodge')
97
+
98
+
99
+ it "renders all choices", ->
100
+ sf = LT.renderComponent(LC.SelectField, props:{
101
+ queryModel: Car, model: @car, name: 'brand', labelField: 'name',
102
+ editOnly: true, choices: @brands.models
103
+ })
104
+ _.dom(sf).qs('.rw-select').click()
105
+ labels = _.map _.dom(sf).qsa('li.rw-list-option'), 'textContent'
106
+ expect(labels).toEqual(["General Motors", "Ford Motor Co.", "Chrysler/Dodge"])
@@ -0,0 +1,34 @@
1
+ Model = Hippo.Test.defineModel(
2
+ props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
3
+ )
4
+
5
+ describe "Hippo.Components.NetworkActivityOverlay", ->
6
+
7
+ it "doesn't render unless requesting", ->
8
+ na = LT.renderComponent(LC.NetworkActivityOverlay, props:{message: 'Lookout 4 Bears'})
9
+ expect(_.dom(na).el).toBe(null)
10
+
11
+ it "renders message", ->
12
+ na = LT.renderComponent(LC.NetworkActivityOverlay, props:{
13
+ visible: true, message: 'Lookout 4 Bears'})
14
+ expect(_.dom(na).qs('.message').text).toBe('Lookout 4 Bears')
15
+
16
+ it 'chooses message based on request type', ->
17
+ na = LT.renderComponent(LC.NetworkActivityOverlay, props:{visible:true})
18
+ na.setState(isRequesting: 'GET')
19
+ expect(_.dom(na).qs('.message').text).toBe('Loading…')
20
+ na.setState(isRequesting: 'POST')
21
+ expect(_.dom(na).qs('.message').text).toBe('Saving…')
22
+ na.setState(isRequesting: 'DELETE')
23
+ expect(_.dom(na).qs('.message').text).toBe('Deleting…')
24
+
25
+ it 'briefly displays an error message', (done) ->
26
+ model = new Model
27
+ na = LT.renderComponent(LC.NetworkActivityOverlay, props:{
28
+ errorTimeout: 2, model:model})
29
+ na.setModelState(hasError: true)
30
+ expect(_.dom(na).qs('.message').text).toBe('Error')
31
+ _.delay( ->
32
+ expect(_.dom(na).el).toBe(null)
33
+ done()
34
+ , 3)
File without changes
@@ -0,0 +1,5 @@
1
+ Hippo.Vendor.MessageBus = {
2
+ subscribe: jasmine.createSpy('subscribe')
3
+ unsubscribe: jasmine.createSpy('unsubscribe')
4
+ start: Hippo.emptyFn
5
+ }
@@ -0,0 +1,1580 @@
1
+ /*
2
+ * Copyright © Jamie Mason, @fold_left,
3
+ * https://github.com/JamieMason
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person
6
+ * obtaining a copy of this software and associated documentation files
7
+ * (the "Software"), to deal in the Software without restriction,
8
+ * including without limitation the rights to use, copy, modify, merge,
9
+ * publish, distribute, sublicense, and/or sell copies of the Software,
10
+ * and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be
14
+ * included in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ (function() {
27
+ const matchers = {};
28
+ const priv = {};
29
+
30
+ /**
31
+ * @inner
32
+ * @param {Object} object
33
+ * @param {Function} fn
34
+ */
35
+ priv.each = function(object, fn) {
36
+ for (const key in object) {
37
+ if (object.hasOwnProperty(key)) {
38
+ fn.call(this, object[key], key, object);
39
+ }
40
+ }
41
+ };
42
+
43
+ /**
44
+ * @inner
45
+ * @param {Object} object
46
+ * @param {Function} fn
47
+ * @param {*} memo
48
+ * @return {*} memo
49
+ */
50
+ priv.reduce = function(object, fn, memo) {
51
+ priv.each.call(this, object, (el, ix, list) => {
52
+ memo = fn(memo, el, ix, list);
53
+ });
54
+ return memo;
55
+ };
56
+
57
+ /**
58
+ * @inner
59
+ * @param {Array} array
60
+ * @param {Function} fn
61
+ * @return {Boolean}
62
+ */
63
+ priv.all = function(array, fn) {
64
+ let i;
65
+ const len = array.length;
66
+ for (i = 0; i < len; i++) {
67
+ if (false === fn.call(this, array[i], i, array)) {
68
+ return false;
69
+ }
70
+ }
71
+ return true;
72
+ };
73
+
74
+ /**
75
+ * @inner
76
+ * @param {String} matcherName
77
+ * @return {Boolean}
78
+ */
79
+ priv.expectAllMembers = function(matcherName) {
80
+ return priv.all.call(this, this.actual, item => matchers[matcherName].call({
81
+ actual: item,
82
+ }));
83
+ };
84
+
85
+ /**
86
+ * Assert subject is of type
87
+ * @inner
88
+ * @param {*} subject
89
+ * @param {String} type
90
+ * @return {Boolean}
91
+ */
92
+ priv.is = function(subject, type) {
93
+ return Object.prototype.toString.call(subject) === `[object ${type}]`;
94
+ };
95
+
96
+ /**
97
+ * Assert subject is an HTML Element with the given node type
98
+ * @inner
99
+ * @param {*} subject
100
+ * @param {String} type
101
+ * @return {Boolean}
102
+ */
103
+ priv.isHtmlElementOfType = function(subject, type) {
104
+ return subject && subject.nodeType === type;
105
+ };
106
+
107
+ /**
108
+ * Convert Array-like Object to true Array
109
+ * @inner
110
+ * @param {*} list
111
+ * @return {Array}
112
+ */
113
+ priv.toArray = function(list) {
114
+ return [].slice.call(list);
115
+ };
116
+
117
+ /**
118
+ * @inner
119
+ * @param {String} matcherName
120
+ * @param {String} memberName
121
+ * @param (*) ...
122
+ * @return {Boolean}
123
+ */
124
+ priv.assertMember = function(/* matcherName, memberName, ... */) {
125
+ const args = priv.toArray(arguments);
126
+ const matcherName = args.shift();
127
+ const memberName = args.shift();
128
+ return priv.is(this.actual, 'Object') && matchers[matcherName].apply({
129
+ actual: this.actual[memberName],
130
+ }, args);
131
+ };
132
+
133
+ /**
134
+ * @summary
135
+ * Format the failure message for member matchers such as toHaveString('surname').
136
+ *
137
+ * @inner
138
+ * @param {Object} util Provided by Jasmine.
139
+ * @param {String} name Name of the matcher, such as toBeString.
140
+ * @param {Array} args converted arguments.
141
+ * @param {Boolean} pass Whether the test passed.
142
+ * @param {*} actual The expected value.
143
+ * @return {String} The message to display on failure.
144
+ */
145
+ priv.formatFailMessage = function(util, name, args, pass, actual) {
146
+ if (-1 === name.search(/^toHave/)) {
147
+ return util.buildFailureMessage.apply(null, [name, pass, actual].concat(args));
148
+ }
149
+ const memberName = args.shift();
150
+ return util.buildFailureMessage.apply(null, [name, pass, actual].concat(args))
151
+ .replace('Expected', `Expected member "${memberName}" of`)
152
+ .replace(' to have ', ' to be ');
153
+ };
154
+
155
+ /**
156
+ * @summary
157
+ * Convert Jasmine 1.0 matchers into the format introduced in Jasmine 2.0.
158
+ *
159
+ * @inner
160
+ * @param {Object} v1Matchers
161
+ * @return {Object} v2Matchers
162
+ */
163
+ priv.adaptMatchers = function(v1Matchers) {
164
+ return priv.reduce(v1Matchers, (v2Matchers, matcher, name) => {
165
+ v2Matchers[name] = function(util) {
166
+ return {
167
+ compare(actual /* , expected, ...*/) {
168
+ const args = priv.toArray(arguments).slice(1);
169
+ const pass = matcher.apply({
170
+ actual,
171
+ }, args);
172
+ return {
173
+ pass,
174
+ message: priv.formatFailMessage(util, name, args, pass, actual),
175
+ };
176
+ },
177
+ };
178
+ };
179
+ return v2Matchers;
180
+ }, {});
181
+ };
182
+
183
+ /**
184
+ * @file Arrays
185
+ *
186
+ * @description
187
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
188
+ */
189
+
190
+ /**
191
+ * @alias
192
+ * expect(array):toBeArray
193
+ *
194
+ * @summary
195
+ * Assert subject is a true Array, created in the parent document — those created and imported
196
+ * from within iframes or other windows will not match.
197
+ *
198
+ * @return {Boolean}
199
+ */
200
+ matchers.toBeArray = function() {
201
+ return this.actual instanceof Array;
202
+ };
203
+
204
+ /**
205
+ * @alias
206
+ * expect(array):toBeArrayOfSize
207
+ *
208
+ * @summary
209
+ * Assert subject is not only a true Array, but one with a specific number of members.
210
+ *
211
+ * @param {Number} size
212
+ * @return {Boolean}
213
+ */
214
+ matchers.toBeArrayOfSize = function(size) {
215
+ return priv.is(this.actual, 'Array') && this.actual.length === size;
216
+ };
217
+
218
+ /**
219
+ * @alias
220
+ * expect(array):toBeEmptyArray
221
+ *
222
+ * @summary
223
+ * Assert subject is not only a true Array, but one without any members.
224
+ *
225
+ * @return {Boolean}
226
+ */
227
+ matchers.toBeEmptyArray = function() {
228
+ return matchers.toBeArrayOfSize.call(this, 0);
229
+ };
230
+
231
+ /**
232
+ * @alias
233
+ * expect(array):toBeNonEmptyArray
234
+ *
235
+ * @summary
236
+ * Assert subject is not only a true Array, but one with at least one member.
237
+ *
238
+ * @return {Boolean}
239
+ */
240
+ matchers.toBeNonEmptyArray = function() {
241
+ return priv.is(this.actual, 'Array') && 0 < this.actual.length;
242
+ };
243
+
244
+ /**
245
+ * @inner
246
+ * @param {String} toBeX
247
+ * @return {Function}
248
+ */
249
+ priv.createToBeArrayOfXsMatcher = function(toBeX) {
250
+ return function() {
251
+ return priv.is(this.actual, 'Array') && priv.expectAllMembers.call(this, toBeX);
252
+ };
253
+ };
254
+
255
+ /**
256
+ * @alias
257
+ * expect(array):toBeArrayOfObjects
258
+ *
259
+ * @summary
260
+ * Assert subject is an Array which is either empty or contains only Objects.
261
+ *
262
+ * @return {Boolean}
263
+ */
264
+ matchers.toBeArrayOfObjects = function() {
265
+ return priv.is(this.actual, 'Array') && priv.expectAllMembers.call(this, 'toBeObject');
266
+ };
267
+
268
+ /**
269
+ * @alias
270
+ * expect(array):toBeArrayOfStrings
271
+ *
272
+ * @summary
273
+ * Assert subject is an Array which is either empty or contains only Strings.
274
+ *
275
+ * @return {Boolean}
276
+ */
277
+ matchers.toBeArrayOfStrings = function() {
278
+ return priv.is(this.actual, 'Array') && priv.expectAllMembers.call(this, 'toBeString');
279
+ };
280
+
281
+ /**
282
+ * @alias
283
+ * expect(array):toBeArrayOfNumbers
284
+ *
285
+ * @summary
286
+ * Assert subject is an Array which is either empty or contains only Numbers.
287
+ *
288
+ * @return {Boolean}
289
+ */
290
+ matchers.toBeArrayOfNumbers = function() {
291
+ return priv.is(this.actual, 'Array') && priv.expectAllMembers.call(this, 'toBeNumber');
292
+ };
293
+
294
+ /**
295
+ * @alias
296
+ * expect(array):toBeArrayOfBooleans
297
+ *
298
+ * @summary
299
+ * Assert subject is an Array which is either empty or contains only Booleans.
300
+ *
301
+ * @return {Boolean}
302
+ */
303
+ matchers.toBeArrayOfBooleans = function() {
304
+ return priv.is(this.actual, 'Array') && priv.expectAllMembers.call(this, 'toBeBoolean');
305
+ };
306
+
307
+ /**
308
+ * @file Booleans
309
+ *
310
+ * @description
311
+ * See {@link http://git.io/jasmine-boolean-testing|Unit testing Booleans with Jasmine}.
312
+ */
313
+
314
+ /**
315
+ * @alias
316
+ * expect(boolean):toBeBoolean
317
+ *
318
+ * @summary
319
+ * Assert subject is not only truthy or falsy, but an actual Boolean.
320
+ *
321
+ * @return {Boolean}
322
+ */
323
+ matchers.toBeBoolean = function() {
324
+ return matchers.toBeTrue.call(this) || matchers.toBeFalse.call(this);
325
+ };
326
+
327
+ /**
328
+ * @alias
329
+ * expect(boolean):toBeTrue
330
+ *
331
+ * @summary
332
+ * Assert subject is not only truthy, but an actual Boolean true.
333
+ *
334
+ * @return {Boolean}
335
+ */
336
+ matchers.toBeTrue = function() {
337
+ return true === this.actual || this.actual instanceof Boolean && true === this.actual.valueOf();
338
+ };
339
+
340
+ /**
341
+ * @alias
342
+ * expect(boolean):toBeFalse
343
+ *
344
+ * @summary
345
+ * Assert subject is not only falsy, but an actual Boolean false.
346
+ *
347
+ * @return {Boolean}
348
+ */
349
+ matchers.toBeFalse = function() {
350
+ return false === this.actual || this.actual instanceof Boolean && false === this.actual.valueOf();
351
+ };
352
+
353
+ /**
354
+ * @file Browser
355
+ *
356
+ * @description
357
+ * See {@link http://git.io/jasmine-browser-testing|Unit testing Browsers with Jasmine}.
358
+ */
359
+
360
+ /**
361
+ * @alias
362
+ * expect(window):toBeWindow
363
+ *
364
+ * @summary
365
+ * Assert subject is a browser Window global, whether that be the parent window or those
366
+ * created within iframes or other windows.
367
+ *
368
+ * @return {Boolean}
369
+ */
370
+ matchers.toBeWindow = function() {
371
+ return this.actual && 'object' === typeof this.actual && this.actual.window === this.actual;
372
+ };
373
+
374
+ /**
375
+ * @alias
376
+ * expect(document):toBeDocument
377
+ *
378
+ * @summary
379
+ * Assert subject is a browser Window global, whether that be the parent window or those
380
+ * created within iframes or other windows.
381
+ *
382
+ * @return {Boolean}
383
+ */
384
+ matchers.toBeDocument = function() {
385
+ return this.actual && 'object' === typeof this.actual && this.actual instanceof window.HTMLDocument;
386
+ };
387
+
388
+ /**
389
+ * @alias
390
+ * expect(htmlElement):toBeHtmlNode
391
+ *
392
+ * @summary
393
+ * Assert subject is an HTML Element.
394
+ *
395
+ * @return {Boolean}
396
+ */
397
+ matchers.toBeHtmlNode = function() {
398
+ return priv.isHtmlElementOfType(this.actual, 1);
399
+ };
400
+
401
+ /**
402
+ * @alias
403
+ * expect(htmlElement):toBeHtmlTextNode
404
+ *
405
+ * @summary
406
+ * Assert subject is an HTML Text Element.
407
+ *
408
+ * @return {Boolean}
409
+ */
410
+ matchers.toBeHtmlTextNode = function() {
411
+ return priv.isHtmlElementOfType(this.actual, 3);
412
+ };
413
+
414
+ /**
415
+ * @alias
416
+ * expect(htmlElement):toBeHtmlCommentNode
417
+ *
418
+ * @summary
419
+ * Assert subject is an HTML Comment Element.
420
+ *
421
+ * @return {Boolean}
422
+ */
423
+ matchers.toBeHtmlCommentNode = function() {
424
+ return priv.isHtmlElementOfType(this.actual, 8);
425
+ };
426
+
427
+ /**
428
+ * @file Dates
429
+ *
430
+ * @description
431
+ * See {@link http://git.io/jasmine-date-testing|Unit testing Dates with Jasmine}.
432
+ */
433
+
434
+ /**
435
+ * @alias
436
+ * expect(date):toBeDate
437
+ *
438
+ * @summary
439
+ * Assert subject is a true Date, created in the parent document — those created and imported
440
+ * from within iframes or other windows will not match.
441
+ *
442
+ * @return {Boolean}
443
+ */
444
+ matchers.toBeDate = function() {
445
+ return this.actual instanceof Date;
446
+ };
447
+
448
+ /**
449
+ * @alias
450
+ * expect(string):toBeIso8601
451
+ *
452
+ * @summary
453
+ * Assert subject is a Date String conforming to the ISO 8601 standard.
454
+ *
455
+ * @return {Boolean}
456
+ */
457
+ matchers.toBeIso8601 = function() {
458
+ return matchers.toBeString.call(this)
459
+ && 10 <= this.actual.length
460
+ && 'Invalid Date' !== new Date(this.actual).toString()
461
+ && new Date(this.actual).toISOString().slice(0, this.actual.length) === this.actual;
462
+ };
463
+
464
+ /**
465
+ * @alias
466
+ * expect(date):toBeBefore
467
+ *
468
+ * @summary
469
+ * Assert subject is a Date occurring before another Date.
470
+ *
471
+ * @param {Date} date
472
+ * @return {Boolean}
473
+ */
474
+ matchers.toBeBefore = function(date) {
475
+ return matchers.toBeDate.call(this) && matchers.toBeDate.call({ actual: date }) && this.actual.getTime() < date.getTime();
476
+ };
477
+
478
+ /**
479
+ * @alias
480
+ * expect(date):toBeAfter
481
+ *
482
+ * @summary
483
+ * Assert subject is a Date occurring after another Date.
484
+ *
485
+ * @param {Date} date
486
+ * @return {Boolean}
487
+ */
488
+ matchers.toBeAfter = function(date) {
489
+ return matchers.toBeBefore.call({ actual: date }, this.actual);
490
+ };
491
+
492
+ /**
493
+ * @file Errors
494
+ *
495
+ * @description
496
+ * See {@link http://git.io/jasmine-error-testing|Unit testing Errors with Jasmine}.
497
+ */
498
+
499
+ /**
500
+ * @alias
501
+ * expect(function):toThrowError
502
+ *
503
+ * @summary
504
+ * Asserts subject throws an Error of any type.
505
+ *
506
+ * @return {Boolean}
507
+ */
508
+ matchers.toThrowError = function() {
509
+ let threwError = false;
510
+ try {
511
+ this.actual();
512
+ } catch (e) {
513
+ threwError = true;
514
+ }
515
+ return threwError;
516
+ };
517
+
518
+ /**
519
+ * @alias
520
+ * expect(function):toThrowErrorOfType
521
+ *
522
+ * @summary
523
+ * Asserts subject throws an Error of a specific type, such as "TypeError".
524
+ *
525
+ * @param {String} type
526
+ * @return {Boolean}
527
+ */
528
+ matchers.toThrowErrorOfType = function(type) {
529
+ let threwErrorOfType = false;
530
+ try {
531
+ this.actual();
532
+ } catch (e) {
533
+ threwErrorOfType = (e.name === type);
534
+ }
535
+ return threwErrorOfType;
536
+ };
537
+
538
+ /**
539
+ * @file Numbers
540
+ *
541
+ * @description
542
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
543
+ */
544
+
545
+ /**
546
+ * @alias
547
+ * expect(number):toBeNumber
548
+ *
549
+ * @summary
550
+ * Assert subject is not only calculable, but an actual Number
551
+ *
552
+ * @return {Boolean}
553
+ */
554
+ matchers.toBeNumber = function() {
555
+ return !isNaN(parseFloat(this.actual)) && !priv.is(this.actual, 'String');
556
+ };
557
+
558
+ /**
559
+ * @alias
560
+ * expect(number):toBeEvenNumber
561
+ *
562
+ * @summary
563
+ * Assert subject is an even Number.
564
+ *
565
+ * @return {Boolean}
566
+ */
567
+ matchers.toBeEvenNumber = function() {
568
+ return matchers.toBeNumber.call(this) && 0 === this.actual % 2;
569
+ };
570
+
571
+ /**
572
+ * @alias
573
+ * expect(number):toBeOddNumber
574
+ *
575
+ * @summary
576
+ * Assert subject is an odd Number.
577
+ *
578
+ * @return {Boolean}
579
+ */
580
+ matchers.toBeOddNumber = function() {
581
+ return matchers.toBeNumber.call(this) && 0 !== this.actual % 2;
582
+ };
583
+
584
+ /**
585
+ * @alias
586
+ * expect(mixed):toBeCalculable
587
+ *
588
+ * @summary
589
+ * Assert subject can be used in Mathemetic calculations, despite not being an actual Number.
590
+ *
591
+ * @example
592
+ * // If all strings are numeric, JavaScript will cast them all as expect(number):
593
+ * "1" * "2" === 2 (pass)
594
+ *
595
+ * @example
596
+ * // If any string is not numeric, JavaScript will cast them all as Strings.
597
+ * "wut?" * 2 === NaN (fail)
598
+ *
599
+ * @return {Boolean}
600
+ */
601
+ matchers.toBeCalculable = function() {
602
+ return !isNaN(this.actual * 2);
603
+ };
604
+
605
+ /**
606
+ * @alias
607
+ * expect(number):toBeWithinRange
608
+ *
609
+ * @summary
610
+ * Assert value falls on or between floor and ceiling.
611
+ *
612
+ * @param {Number} floor
613
+ * @param {Number} ceiling
614
+ * @return {Boolean}
615
+ */
616
+ matchers.toBeWithinRange = function(floor, ceiling) {
617
+ return matchers.toBeNumber.call(this) && this.actual >= floor && this.actual <= ceiling;
618
+ };
619
+
620
+ /**
621
+ * @alias
622
+ * expect(number):toBeWholeNumber
623
+ *
624
+ * @summary
625
+ * Assert value is a number with no decimal places.
626
+ *
627
+ * @return {Boolean}
628
+ */
629
+ matchers.toBeWholeNumber = function() {
630
+ return matchers.toBeNumber.call(this) && (0 === this.actual || 0 === this.actual % 1);
631
+ };
632
+
633
+ /**
634
+ * @file Objects
635
+ *
636
+ * @description
637
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
638
+ */
639
+
640
+ /**
641
+ * @inner
642
+ *
643
+ * @summary
644
+ * Report how many instance members the given Object has.
645
+ *
646
+ * @param {Object} object
647
+ * @return {Number}
648
+ */
649
+ priv.countMembers = function(object) {
650
+ return priv.reduce(object, (memo, el, ix) => memo + 1, 0);
651
+ };
652
+
653
+ /**
654
+ * @alias
655
+ * expect(object):toBeObject
656
+ *
657
+ * @summary
658
+ * Assert subject is a true Object, created in the parent document — those created and imported
659
+ * from within iframes or other windows will not match.
660
+ *
661
+ * @return {Boolean}
662
+ */
663
+ matchers.toBeObject = function() {
664
+ return this.actual instanceof Object;
665
+ };
666
+
667
+ /**
668
+ * @alias
669
+ * expect(object):toBeEmptyObject
670
+ *
671
+ * @summary
672
+ * Assert subject is a true Object with no instance members.
673
+ *
674
+ * @return {Boolean}
675
+ */
676
+ matchers.toBeEmptyObject = function() {
677
+ return priv.is(this.actual, 'Object') && 0 === priv.countMembers(this.actual);
678
+ };
679
+
680
+ /**
681
+ * @alias
682
+ * expect(object):toBeNonEmptyObject
683
+ *
684
+ * @summary
685
+ * Assert subject is a true Object with at least one instance member.
686
+ *
687
+ * @return {Boolean}
688
+ */
689
+ matchers.toBeNonEmptyObject = function() {
690
+ return priv.is(this.actual, 'Object') && 0 < priv.countMembers(this.actual);
691
+ };
692
+
693
+ /**
694
+ * @alias
695
+ * expect(object):toImplement
696
+ *
697
+ * @summary
698
+ * Assert subject is a true Object which features at least the same keys as `other` (regardless of
699
+ * whether it also has other members).
700
+ *
701
+ * @param {Object} other
702
+ * @return {Boolean}
703
+ */
704
+ matchers.toImplement = function(other) {
705
+ if (!priv.is(this.actual, 'Object') || !priv.is(other, 'Object')) {
706
+ return false;
707
+ }
708
+ for (const key in other) {
709
+ if (key in this.actual) {
710
+ continue;
711
+ }
712
+ return false;
713
+ }
714
+ return true;
715
+ };
716
+
717
+ /**
718
+ * @alias
719
+ * expect(function):toBeFunction
720
+ *
721
+ * @summary
722
+ * Assert subject is a true Function, created in the parent document — those created and imported
723
+ * from within iframes or other windows will not match.
724
+ *
725
+ * @return {Boolean}
726
+ */
727
+ matchers.toBeFunction = function() {
728
+ return this.actual instanceof Function;
729
+ };
730
+
731
+ /**
732
+ * @file Strings
733
+ *
734
+ * @description
735
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
736
+ */
737
+
738
+ /**
739
+ * @alias
740
+ * expect(string):toBeString
741
+ *
742
+ * @summary
743
+ * Assert subject is a String.
744
+ *
745
+ * @return {Boolean}
746
+ */
747
+ matchers.toBeString = function() {
748
+ return priv.is(this.actual, 'String');
749
+ };
750
+
751
+ /**
752
+ * @alias
753
+ * expect(string):toBeEmptyString
754
+ *
755
+ * @summary
756
+ * Assert subject is a String of length 0.
757
+ *
758
+ * @return {Boolean}
759
+ */
760
+ matchers.toBeEmptyString = function() {
761
+ return '' === this.actual;
762
+ };
763
+
764
+ /**
765
+ * @alias
766
+ * expect(string):toBeNonEmptyString
767
+ *
768
+ * @summary
769
+ * Assert subject is a String with at least 1 character.
770
+ *
771
+ * @return {Boolean}
772
+ */
773
+ matchers.toBeNonEmptyString = function() {
774
+ return matchers.toBeString.call(this) && 0 < this.actual.length;
775
+ };
776
+
777
+ /**
778
+ * @alias
779
+ * expect(string):toBeHtmlString
780
+ *
781
+ * @summary
782
+ * Assert subject is string containing HTML Markup.
783
+ *
784
+ * @return {Boolean}
785
+ */
786
+ matchers.toBeHtmlString = function() {
787
+ // < start with opening tag "<"
788
+ // ( start group 1
789
+ // "[^"]*" allow string in "double quotes"
790
+ // | OR
791
+ // '[^']*' allow string in "single quotes"
792
+ // | OR
793
+ // [^'">] cant contains one single quotes, double quotes and ">"
794
+ // ) end group 1
795
+ // * 0 or more
796
+ // > end with closing tag ">"
797
+ return matchers.toBeString.call(this) && -1 !== this.actual.search(/<("[^"]*"|'[^']*'|[^'">])*>/);
798
+ };
799
+
800
+ /**
801
+ * @alias
802
+ * expect(string):toBeJsonString
803
+ *
804
+ * @summary
805
+ * Assert subject is string containing parseable JSON.
806
+ *
807
+ * @return {Boolean}
808
+ */
809
+ matchers.toBeJsonString = function() {
810
+ let isParseable;
811
+ let json;
812
+ try {
813
+ json = JSON.parse(this.actual);
814
+ } catch (e) {
815
+ isParseable = false;
816
+ }
817
+ return false !== isParseable && null !== json;
818
+ };
819
+
820
+ /**
821
+ * @alias
822
+ * expect(string):toBeWhitespace
823
+ *
824
+ * @summary
825
+ * Assert subject is a String containing nothing but whitespace.
826
+ *
827
+ * @return {Boolean}
828
+ */
829
+ matchers.toBeWhitespace = function() {
830
+ return matchers.toBeString.call(this) && -1 === this.actual.search(/\S/);
831
+ };
832
+
833
+ /**
834
+ * @alias
835
+ * expect(string):toStartWith
836
+ *
837
+ * @summary
838
+ * Assert subject is a String whose first characters match our expected string.
839
+ *
840
+ * @param {String} expected
841
+ * @return {Boolean}
842
+ */
843
+ matchers.toStartWith = function(expected) {
844
+ if (!matchers.toBeNonEmptyString.call(this) || !matchers.toBeNonEmptyString.call({
845
+ actual: expected,
846
+ })) {
847
+ return false;
848
+ }
849
+ return this.actual.slice(0, expected.length) === expected;
850
+ };
851
+
852
+ /**
853
+ * @alias
854
+ * expect(string):toEndWith
855
+ *
856
+ * @summary
857
+ * Assert subject is a String whose last characters match our expected string.
858
+ *
859
+ * @param {String} expected
860
+ * @return {Boolean}
861
+ */
862
+ matchers.toEndWith = function(expected) {
863
+ if (!matchers.toBeNonEmptyString.call(this) || !matchers.toBeNonEmptyString.call({
864
+ actual: expected,
865
+ })) {
866
+ return false;
867
+ }
868
+ return this.actual.slice(this.actual.length - expected.length, this.actual.length) === expected;
869
+ };
870
+
871
+ /**
872
+ * @alias
873
+ * expect(string):toBeLongerThan
874
+ *
875
+ * @summary
876
+ * Assert subject is a String whose length is greater than our other string.
877
+ *
878
+ * @param {String} other
879
+ * @return {Boolean}
880
+ */
881
+ matchers.toBeLongerThan = function(other) {
882
+ return matchers.toBeString.call(this) && matchers.toBeString.call({
883
+ actual: other,
884
+ }) && this.actual.length > other.length;
885
+ };
886
+
887
+ /**
888
+ * @alias
889
+ * expect(string):toBeShorterThan
890
+ *
891
+ * @summary
892
+ * Assert subject is a String whose length is greater than our other string.
893
+ *
894
+ * @param {String} other
895
+ * @return {Boolean}
896
+ */
897
+ matchers.toBeShorterThan = function(other) {
898
+ return matchers.toBeString.call(this) && matchers.toBeString.call({
899
+ actual: other,
900
+ }) && this.actual.length < other.length;
901
+ };
902
+
903
+ /**
904
+ * @alias
905
+ * expect(string):toBeSameLengthAs
906
+ *
907
+ * @summary
908
+ * Assert subject is a String whose length is equal to our other string.
909
+ *
910
+ * @param {String} other
911
+ * @return {Boolean}
912
+ */
913
+ matchers.toBeSameLengthAs = function(other) {
914
+ return matchers.toBeString.call(this) && matchers.toBeString.call({
915
+ actual: other,
916
+ }) && this.actual.length === other.length;
917
+ };
918
+
919
+ /**
920
+ * ArrayMembers
921
+ */
922
+
923
+ /**
924
+ * @alias
925
+ * expect(object):toHaveArray
926
+ *
927
+ * @summary
928
+ * .
929
+ *
930
+ * @description
931
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
932
+ *
933
+ * @param {String} memberName
934
+ * @return {Boolean}
935
+ */
936
+ matchers.toHaveArray = function(memberName) {
937
+ return priv.assertMember.call(this, 'toBeArray', memberName);
938
+ };
939
+
940
+ /**
941
+ * @alias
942
+ * expect(object):toHaveArrayOfBooleans
943
+ *
944
+ * @summary
945
+ * .
946
+ *
947
+ * @description
948
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
949
+ *
950
+ * @param {String} memberName
951
+ * @return {Boolean}
952
+ */
953
+ matchers.toHaveArrayOfBooleans = function(memberName) {
954
+ return priv.assertMember.call(this, 'toBeArrayOfBooleans', memberName);
955
+ };
956
+
957
+ /**
958
+ * @alias
959
+ * expect(object):toHaveArrayOfNumbers
960
+ *
961
+ * @summary
962
+ * .
963
+ *
964
+ * @description
965
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
966
+ *
967
+ * @param {String} memberName
968
+ * @return {Boolean}
969
+ */
970
+ matchers.toHaveArrayOfNumbers = function(memberName) {
971
+ return priv.assertMember.call(this, 'toBeArrayOfNumbers', memberName);
972
+ };
973
+
974
+ /**
975
+ * @alias
976
+ * expect(object):toHaveArrayOfObjects
977
+ *
978
+ * @summary
979
+ * .
980
+ *
981
+ * @description
982
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
983
+ *
984
+ * @param {String} memberName
985
+ * @return {Boolean}
986
+ */
987
+ matchers.toHaveArrayOfObjects = function(memberName) {
988
+ return priv.assertMember.call(this, 'toBeArrayOfObjects', memberName);
989
+ };
990
+
991
+ /**
992
+ * @alias
993
+ * expect(object):toHaveArrayOfSize
994
+ *
995
+ * @summary
996
+ * .
997
+ *
998
+ * @description
999
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
1000
+ *
1001
+ * @param {String} memberName
1002
+ * @param {Number} size
1003
+ * @return {Boolean}
1004
+ */
1005
+ matchers.toHaveArrayOfSize = function(memberName, size) {
1006
+ return priv.assertMember.call(this, 'toBeArrayOfSize', memberName, size);
1007
+ };
1008
+
1009
+ /**
1010
+ * @alias
1011
+ * expect(object):toHaveNonEmptyArray
1012
+ *
1013
+ * @summary
1014
+ * .
1015
+ *
1016
+ * @description
1017
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
1018
+ *
1019
+ * @param {String} memberName
1020
+ * @return {Boolean}
1021
+ */
1022
+ matchers.toHaveNonEmptyArray = function(memberName) {
1023
+ return priv.assertMember.call(this, 'toBeNonEmptyArray', memberName);
1024
+ };
1025
+
1026
+ /**
1027
+ * @alias
1028
+ * expect(object):toHaveEmptyArray
1029
+ *
1030
+ * @summary
1031
+ * .
1032
+ *
1033
+ * @description
1034
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
1035
+ *
1036
+ * @param {String} memberName
1037
+ * @return {Boolean}
1038
+ */
1039
+ matchers.toHaveEmptyArray = function(memberName) {
1040
+ return priv.assertMember.call(this, 'toBeEmptyArray', memberName);
1041
+ };
1042
+
1043
+ /**
1044
+ * @alias
1045
+ * expect(object):toHaveArrayOfStrings
1046
+ *
1047
+ * @summary
1048
+ * .
1049
+ *
1050
+ * @description
1051
+ * See {@link http://git.io/jasmine-array-testing|Unit testing Arrays with Jasmine}.
1052
+ *
1053
+ * @param {String} memberName
1054
+ * @return {Boolean}
1055
+ */
1056
+ matchers.toHaveArrayOfStrings = function(memberName) {
1057
+ return priv.assertMember.call(this, 'toBeArrayOfStrings', memberName);
1058
+ };
1059
+
1060
+ /**
1061
+ * BooleanMembers
1062
+ */
1063
+
1064
+ /**
1065
+ * @alias
1066
+ * expect(object):toHaveBoolean
1067
+ *
1068
+ * @summary
1069
+ * .
1070
+ *
1071
+ * @description
1072
+ * See {@link http://git.io/jasmine-boolean-testing|Unit testing Booleans with Jasmine}.
1073
+ *
1074
+ * @param {String} memberName
1075
+ * @return {Boolean}
1076
+ */
1077
+ matchers.toHaveBoolean = function(memberName) {
1078
+ return priv.assertMember.call(this, 'toBeBoolean', memberName);
1079
+ };
1080
+
1081
+ /**
1082
+ * @alias
1083
+ * expect(object):toHaveFalse
1084
+ *
1085
+ * @summary
1086
+ * .
1087
+ *
1088
+ * @description
1089
+ * See {@link http://git.io/jasmine-boolean-testing|Unit testing Booleans with Jasmine}.
1090
+ *
1091
+ * @param {String} memberName
1092
+ * @return {Boolean}
1093
+ */
1094
+ matchers.toHaveFalse = function(memberName) {
1095
+ return priv.assertMember.call(this, 'toBeFalse', memberName);
1096
+ };
1097
+
1098
+ /**
1099
+ * @alias
1100
+ * expect(object):toHaveTrue
1101
+ *
1102
+ * @summary
1103
+ * .
1104
+ *
1105
+ * @description
1106
+ * See {@link http://git.io/jasmine-boolean-testing|Unit testing Booleans with Jasmine}.
1107
+ *
1108
+ * @param {String} memberName
1109
+ * @return {Boolean}
1110
+ */
1111
+ matchers.toHaveTrue = function(memberName) {
1112
+ return priv.assertMember.call(this, 'toBeTrue', memberName);
1113
+ };
1114
+
1115
+ /**
1116
+ * BrowserMembers
1117
+ */
1118
+
1119
+ /**
1120
+ * @alias
1121
+ * expect(object):toHaveHtmlNode
1122
+ *
1123
+ * @summary
1124
+ * Assert subject is a true Object containing a property at memberName which is an HTML Element.
1125
+ *
1126
+ * @description
1127
+ * See {@link http://git.io/jasmine-browser-testing|Unit testing Browsers with Jasmine}.
1128
+ *
1129
+ * @param {Boolean} memberName
1130
+ * @return {Boolean}
1131
+ */
1132
+ matchers.toHaveHtmlNode = function(memberName) {
1133
+ return priv.assertMember.call(this, 'toBeHtmlNode', memberName);
1134
+ };
1135
+
1136
+ /**
1137
+ * DateMembers
1138
+ */
1139
+
1140
+ /**
1141
+ * @alias
1142
+ * expect(object):toHaveDate
1143
+ *
1144
+ * @summary
1145
+ * .
1146
+ *
1147
+ * @description
1148
+ * See {@link http://git.io/jasmine-date-testing|Unit testing Dates with Jasmine}.
1149
+ *
1150
+ * @param {String} memberName
1151
+ * @return {Boolean}
1152
+ */
1153
+ matchers.toHaveDate = function(memberName) {
1154
+ return priv.assertMember.call(this, 'toBeDate', memberName);
1155
+ };
1156
+
1157
+ /**
1158
+ * @alias
1159
+ * expect(object):toHaveDateAfter
1160
+ *
1161
+ * @summary
1162
+ * .
1163
+ *
1164
+ * @description
1165
+ * See {@link http://git.io/jasmine-bdate-testing|Unit testing Dates with Jasmine}.
1166
+ *
1167
+ * @param {String} memberName
1168
+ * @param {Date} date
1169
+ * @return {Boolean}
1170
+ */
1171
+ matchers.toHaveDateAfter = function(memberName, date) {
1172
+ return priv.assertMember.call(this, 'toBeDateAfter', memberName, date);
1173
+ };
1174
+
1175
+ /**
1176
+ * @alias
1177
+ * expect(object):toHaveDateBefore
1178
+ *
1179
+ * @summary
1180
+ * .
1181
+ *
1182
+ * @description
1183
+ * See {@link http://git.io/jasmine-browser-date|Unit testing Browsers with Dates}.
1184
+ *
1185
+ * @param {String} memberName
1186
+ * @param {Date} date
1187
+ * @return {Boolean}
1188
+ */
1189
+ matchers.toHaveDateBefore = function(memberName, date) {
1190
+ return priv.assertMember.call(this, 'toBeDateBefore', memberName, date);
1191
+ };
1192
+
1193
+ /**
1194
+ * @alias
1195
+ * expect(object):toHaveIso8601
1196
+ *
1197
+ * @summary
1198
+ * .
1199
+ *
1200
+ * @description
1201
+ * See {@link http://git.io/jasmine-date-testing|Unit testing Dates with Jasmine}.
1202
+ *
1203
+ * @param {String} memberName
1204
+ * @return {Boolean}
1205
+ */
1206
+ matchers.toHaveIso8601 = function(memberName) {
1207
+ return priv.assertMember.call(this, 'toBeIso8601', memberName);
1208
+ };
1209
+
1210
+ /**
1211
+ * NumberMembers
1212
+ */
1213
+
1214
+ /**
1215
+ * @alias
1216
+ * expect(object):toHaveNumber
1217
+ *
1218
+ * @summary
1219
+ * .
1220
+ *
1221
+ * @description
1222
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1223
+ *
1224
+ * @param {String} memberName
1225
+ * @return {Boolean}
1226
+ */
1227
+ matchers.toHaveNumber = function(memberName) {
1228
+ return priv.assertMember.call(this, 'toBeNumber', memberName);
1229
+ };
1230
+
1231
+ /**
1232
+ * @alias
1233
+ * expect(object):toHaveNumberWithinRange
1234
+ *
1235
+ * @summary
1236
+ * .
1237
+ *
1238
+ * @description
1239
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1240
+ *
1241
+ * @param {String} memberName
1242
+ * @param {Number} floor
1243
+ * @param {Number} ceiling
1244
+ * @return {Boolean}
1245
+ */
1246
+ matchers.toHaveNumberWithinRange = function(memberName, floor, ceiling) {
1247
+ return priv.assertMember.call(this, 'toBeWithinRange', memberName, floor, ceiling);
1248
+ };
1249
+
1250
+ /**
1251
+ * @alias
1252
+ * expect(object):toHaveCalculable
1253
+ *
1254
+ * @summary
1255
+ * .
1256
+ *
1257
+ * @description
1258
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1259
+ *
1260
+ * @param {String} memberName
1261
+ * @return {Boolean}
1262
+ */
1263
+ matchers.toHaveCalculable = function(memberName) {
1264
+ return priv.assertMember.call(this, 'toBeCalculable', memberName);
1265
+ };
1266
+
1267
+ /**
1268
+ * @alias
1269
+ * expect(object):toHaveEvenNumber
1270
+ *
1271
+ * @summary
1272
+ * .
1273
+ *
1274
+ * @description
1275
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1276
+ *
1277
+ * @param {String} memberName
1278
+ * @return {Boolean}
1279
+ */
1280
+ matchers.toHaveEvenNumber = function(memberName) {
1281
+ return priv.assertMember.call(this, 'toBeEvenNumber', memberName);
1282
+ };
1283
+
1284
+ /**
1285
+ * @alias
1286
+ * expect(object):toHaveOddNumber
1287
+ *
1288
+ * @summary
1289
+ * .
1290
+ *
1291
+ * @description
1292
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1293
+ *
1294
+ * @param {String} memberName
1295
+ * @return {Boolean}
1296
+ */
1297
+ matchers.toHaveOddNumber = function(memberName) {
1298
+ return priv.assertMember.call(this, 'toBeOddNumber', memberName);
1299
+ };
1300
+
1301
+ /**
1302
+ * @alias
1303
+ * expect(object):toHaveWholeNumber
1304
+ *
1305
+ * @summary
1306
+ * .
1307
+ *
1308
+ * @description
1309
+ * See {@link http://git.io/jasmine-number-testing|Unit testing Numbers with Jasmine}.
1310
+ *
1311
+ * @param {String} memberName
1312
+ * @return {Boolean}
1313
+ */
1314
+ matchers.toHaveWholeNumber = function(memberName) {
1315
+ return priv.assertMember.call(this, 'toBeWholeNumber', memberName);
1316
+ };
1317
+
1318
+ /**
1319
+ * ObjectMembers
1320
+ */
1321
+
1322
+ /**
1323
+ * @alias
1324
+ * expect(object):toHaveMethod
1325
+ *
1326
+ * @summary
1327
+ * Assert subject is a true Object containing a property at memberName which is a Function.
1328
+ *
1329
+ * @description
1330
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
1331
+ *
1332
+ * @param {Boolean} memberName
1333
+ * @return {Boolean}
1334
+ */
1335
+ matchers.toHaveMethod = function(memberName) {
1336
+ return priv.assertMember.call(this, 'toBeFunction', memberName);
1337
+ };
1338
+
1339
+ /**
1340
+ * @alias
1341
+ * expect(object):toHaveObject
1342
+ *
1343
+ * @summary
1344
+ * Assert subject is a true Object containing a property at memberName which is a true Object.
1345
+ *
1346
+ * @description
1347
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
1348
+ *
1349
+ * @param {Boolean} memberName
1350
+ * @return {Boolean}
1351
+ */
1352
+ matchers.toHaveObject = function(memberName) {
1353
+ return priv.assertMember.call(this, 'toBeObject', memberName);
1354
+ };
1355
+
1356
+ /**
1357
+ * @alias
1358
+ * expect(object):toHaveEmptyObject
1359
+ *
1360
+ * @summary
1361
+ * Assert subject is a true Object containing a property at memberName which is a true Object with
1362
+ * no instance members.
1363
+ *
1364
+ * @description
1365
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
1366
+ *
1367
+ * @param {Boolean} memberName
1368
+ * @return {Boolean}
1369
+ */
1370
+ matchers.toHaveEmptyObject = function(memberName) {
1371
+ return priv.assertMember.call(this, 'toBeEmptyObject', memberName);
1372
+ };
1373
+
1374
+ /**
1375
+ * @alias
1376
+ * expect(object):toHaveNonEmptyObject
1377
+ *
1378
+ * @summary
1379
+ * Assert subject is a true Object containing a property at memberName which is a true Object with
1380
+ * at least one instance member.
1381
+ *
1382
+ * @description
1383
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
1384
+ *
1385
+ * @param {Boolean} memberName
1386
+ * @return {Boolean}
1387
+ */
1388
+ matchers.toHaveNonEmptyObject = function(memberName) {
1389
+ return priv.assertMember.call(this, 'toBeNonEmptyObject', memberName);
1390
+ };
1391
+
1392
+ /**
1393
+ * @alias
1394
+ * expect(object):toHaveMember
1395
+ *
1396
+ * @summary
1397
+ * Assert subject is a true Object containing a property at memberName which is of any value,
1398
+ * including undefined.
1399
+ *
1400
+ * @description
1401
+ * See {@link http://git.io/jasmine-object-testing|Unit testing Objects with Jasmine}.
1402
+ *
1403
+ * @param {Boolean} memberName
1404
+ * @return {Boolean}
1405
+ */
1406
+ matchers.toHaveMember = function(memberName) {
1407
+ return memberName && priv.is(this.actual, 'Object') && memberName in this.actual;
1408
+ };
1409
+
1410
+ /**
1411
+ * StringMembers
1412
+ */
1413
+
1414
+ /**
1415
+ * @alias
1416
+ * expect(object):toHaveEmptyString
1417
+ *
1418
+ * @summary
1419
+ * .
1420
+ *
1421
+ * @description
1422
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1423
+ *
1424
+ * @param {String} memberName
1425
+ * @return {Boolean}
1426
+ */
1427
+ matchers.toHaveEmptyString = function(memberName) {
1428
+ return priv.assertMember.call(this, 'toBeEmptyString', memberName);
1429
+ };
1430
+
1431
+ /**
1432
+ * @alias
1433
+ * expect(object):toHaveHtmlString
1434
+ *
1435
+ * @summary
1436
+ * .
1437
+ *
1438
+ * @description
1439
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1440
+ *
1441
+ * @param {String} memberName
1442
+ * @return {Boolean}
1443
+ */
1444
+ matchers.toHaveHtmlString = function(memberName) {
1445
+ return priv.assertMember.call(this, 'toBeHtmlString', memberName);
1446
+ };
1447
+
1448
+ /**
1449
+ * @alias
1450
+ * expect(object):toHaveJsonString
1451
+ *
1452
+ * @summary
1453
+ * .
1454
+ *
1455
+ * @description
1456
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1457
+ *
1458
+ * @param {String} memberName
1459
+ * @return {Boolean}
1460
+ */
1461
+ matchers.toHaveJsonString = function(memberName) {
1462
+ return priv.assertMember.call(this, 'toBeJsonString', memberName);
1463
+ };
1464
+
1465
+ /**
1466
+ * @alias
1467
+ * expect(object):toHaveNonEmptyString
1468
+ *
1469
+ * @summary
1470
+ * .
1471
+ *
1472
+ * @description
1473
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1474
+ *
1475
+ * @param {String} memberName
1476
+ * @return {Boolean}
1477
+ */
1478
+ matchers.toHaveNonEmptyString = function(memberName) {
1479
+ return priv.assertMember.call(this, 'toBeNonEmptyString', memberName);
1480
+ };
1481
+
1482
+ /**
1483
+ * @alias
1484
+ * expect(object):toHaveString
1485
+ *
1486
+ * @summary
1487
+ * .
1488
+ *
1489
+ * @description
1490
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1491
+ *
1492
+ * @param {String} memberName
1493
+ * @return {Boolean}
1494
+ */
1495
+ matchers.toHaveString = function(memberName) {
1496
+ return priv.assertMember.call(this, 'toBeString', memberName);
1497
+ };
1498
+
1499
+ /**
1500
+ * @alias
1501
+ * expect(object):toHaveStringLongerThan
1502
+ *
1503
+ * @summary
1504
+ * .
1505
+ *
1506
+ * @description
1507
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1508
+ *
1509
+ * @param {String} memberName
1510
+ * @param {String} other
1511
+ * @return {Boolean}
1512
+ */
1513
+ matchers.toHaveStringLongerThan = function(memberName, other) {
1514
+ return priv.assertMember.call(this, 'toBeLongerThan', memberName, other);
1515
+ };
1516
+
1517
+ /**
1518
+ * @alias
1519
+ * expect(object):toHaveStringSameLengthAs
1520
+ *
1521
+ * @summary
1522
+ * .
1523
+ *
1524
+ * @description
1525
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1526
+ *
1527
+ * @param {String} memberName
1528
+ * @param {String} other
1529
+ * @return {Boolean}
1530
+ */
1531
+ matchers.toHaveStringSameLengthAs = function(memberName, other) {
1532
+ return priv.assertMember.call(this, 'toBeSameLengthAs', memberName, other);
1533
+ };
1534
+
1535
+ /**
1536
+ * @alias
1537
+ * expect(object):toHaveStringShorterThan
1538
+ *
1539
+ * @summary
1540
+ * .
1541
+ *
1542
+ * @description
1543
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1544
+ *
1545
+ * @param {String} memberName
1546
+ * @param {String} other
1547
+ * @return {Boolean}
1548
+ */
1549
+ matchers.toHaveStringShorterThan = function(memberName, other) {
1550
+ return priv.assertMember.call(this, 'toBeShorterThan', memberName, other);
1551
+ };
1552
+
1553
+ /**
1554
+ * @alias
1555
+ * expect(object):toHaveWhitespaceString
1556
+ *
1557
+ * @summary
1558
+ * .
1559
+ *
1560
+ * @description
1561
+ * See {@link http://git.io/jasmine-string-testing|Unit testing Strings with Jasmine}.
1562
+ *
1563
+ * @param {String} memberName
1564
+ * @return {Boolean}
1565
+ */
1566
+ matchers.toHaveWhitespaceString = function(memberName) {
1567
+ return priv.assertMember.call(this, 'toBeWhitespace', memberName);
1568
+ };
1569
+
1570
+ // Create adapters for the original matchers so they can be compatible with Jasmine 2.0.
1571
+ const matchersV2 = priv.adaptMatchers(matchers);
1572
+
1573
+ beforeEach(function() {
1574
+ if ('function' === typeof this.addMatchers) {
1575
+ this.addMatchers(matchers);
1576
+ } else if ('function' === typeof jasmine.addMatchers) {
1577
+ jasmine.addMatchers(matchersV2);
1578
+ }
1579
+ });
1580
+ }());