hippo-fw 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dir-locals.el +8 -0
- data/.eslintrc.js +7 -0
- data/.flowconfig +2 -0
- data/.gitignore +22 -0
- data/.jshintrc +3 -0
- data/.rubocop.yml +9 -0
- data/.ruby-version +1 -0
- data/.travis.yml +24 -0
- data/Gemfile +17 -0
- data/Guardfile +19 -0
- data/LICENSE-MIT.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +39 -0
- data/bin/hippo +5 -0
- data/client/extension.js +0 -0
- data/client/hippo/__mocks__/config.js +17 -0
- data/client/hippo/access/index.js +4 -0
- data/client/hippo/access/login-dialog.jsx +38 -0
- data/client/hippo/access/styles.scss +0 -0
- data/client/hippo/boot.jsx +41 -0
- data/client/hippo/components/asset.jsx +81 -0
- data/client/hippo/components/asset.scss +15 -0
- data/client/hippo/components/calendar/Calendar.jsx +25 -0
- data/client/hippo/components/calendar/index.js +3 -0
- data/client/hippo/components/calendar/styles.scss +3 -0
- data/client/hippo/components/data-list.jsx +105 -0
- data/client/hippo/components/data-table.jsx +243 -0
- data/client/hippo/components/data-table/header-cell.jsx +94 -0
- data/client/hippo/components/data-table/table-styles.scss +34 -0
- data/client/hippo/components/enabled.js.erb +5 -0
- data/client/hippo/components/field-validation.js +7 -0
- data/client/hippo/components/form.jsx +65 -0
- data/client/hippo/components/form/field-prop-type.js +16 -0
- data/client/hippo/components/form/fields.jsx +76 -0
- data/client/hippo/components/form/fields/checkbox-wrapper.jsx +21 -0
- data/client/hippo/components/form/fields/date-wrapper.jsx +49 -0
- data/client/hippo/components/form/fields/form-field.scss +4 -0
- data/client/hippo/components/form/fields/select-wrapper.jsx +31 -0
- data/client/hippo/components/form/fields/text-wrapper.jsx +20 -0
- data/client/hippo/components/form/model.js +95 -0
- data/client/hippo/components/form/validations.js +0 -0
- data/client/hippo/components/form/wrapper.jsx +40 -0
- data/client/hippo/components/grid/config.json +3 -0
- data/client/hippo/components/grid/editors.scss +78 -0
- data/client/hippo/components/grid/index.js +2 -0
- data/client/hippo/components/grid/row-editor.scss +74 -0
- data/client/hippo/components/grid/styles.scss +118 -0
- data/client/hippo/components/icon.jsx +70 -0
- data/client/hippo/components/index.js +3 -0
- data/client/hippo/components/modal/index.js +1 -0
- data/client/hippo/components/modal/styles.scss +12 -0
- data/client/hippo/components/network-activity-overlay.jsx +127 -0
- data/client/hippo/components/network-activity-overlay.scss +52 -0
- data/client/hippo/components/query-builder.jsx +157 -0
- data/client/hippo/components/record-finder.jsx +95 -0
- data/client/hippo/components/record-finder/config.json +3 -0
- data/client/hippo/components/record-finder/query-layer.jsx +74 -0
- data/client/hippo/components/record-finder/record-finder.scss +12 -0
- data/client/hippo/components/request-spinner/index.js +1 -0
- data/client/hippo/components/screen.jsx +34 -0
- data/client/hippo/components/select-field/index.js +2 -0
- data/client/hippo/components/select-field/styles.scss +27 -0
- data/client/hippo/components/shared/AssetsListing.jsx +23 -0
- data/client/hippo/components/shared/Checkbox.jsx +49 -0
- data/client/hippo/components/shared/CountBadge.jsx +13 -0
- data/client/hippo/components/shared/DateTime.jsx +58 -0
- data/client/hippo/components/shared/DisplayValue.jsx +15 -0
- data/client/hippo/components/shared/ErrorDisplay.jsx +37 -0
- data/client/hippo/components/shared/FieldMixin.jsx +254 -0
- data/client/hippo/components/shared/FieldSet.jsx +52 -0
- data/client/hippo/components/shared/FieldWrapper.jsx +94 -0
- data/client/hippo/components/shared/FormGroup.jsx +41 -0
- data/client/hippo/components/shared/GenericField.jsx +7 -0
- data/client/hippo/components/shared/IconButton.jsx +13 -0
- data/client/hippo/components/shared/ImageAsset.jsx +78 -0
- data/client/hippo/components/shared/IndeterminateCheckbox.jsx +31 -0
- data/client/hippo/components/shared/Input.jsx +16 -0
- data/client/hippo/components/shared/InputFieldMixin.jsx +78 -0
- data/client/hippo/components/shared/JobProgress.jsx +46 -0
- data/client/hippo/components/shared/NumberInput.jsx +37 -0
- data/client/hippo/components/shared/PanelHeader.jsx +15 -0
- data/client/hippo/components/shared/RadioField.jsx +33 -0
- data/client/hippo/components/shared/ResizeSensor.jsx +18 -0
- data/client/hippo/components/shared/ScreenWrapper.jsx +17 -0
- data/client/hippo/components/shared/TextArea.jsx +19 -0
- data/client/hippo/components/shared/Throbber.jsx +8 -0
- data/client/hippo/components/shared/ToggleField.jsx +2 -0
- data/client/hippo/components/shared/Tooltip.jsx +23 -0
- data/client/hippo/components/shared/fields.scss +58 -0
- data/client/hippo/components/shared/fieldset.scss +27 -0
- data/client/hippo/components/shared/image-asset.scss +53 -0
- data/client/hippo/components/shared/index.js +5 -0
- data/client/hippo/components/shared/overlay.scss +83 -0
- data/client/hippo/components/shared/resize-sensor.scss +30 -0
- data/client/hippo/components/shared/styles.scss +64 -0
- data/client/hippo/components/shared/throbber.scss +53 -0
- data/client/hippo/components/toolbar/changes-notification.scss +63 -0
- data/client/hippo/components/toolbar/index.js +3 -0
- data/client/hippo/components/toolbar/styles.scss +74 -0
- data/client/hippo/components/warning-notification.jsx +14 -0
- data/client/hippo/config.js +72 -0
- data/client/hippo/extensions/EarlyExtensions.js.erb +3 -0
- data/client/hippo/extensions/LateLoaded.js.erb +4 -0
- data/client/hippo/extensions/base.js +23 -0
- data/client/hippo/extensions/hippo.js +11 -0
- data/client/hippo/extensions/index.js +47 -0
- data/client/hippo/extensions/namespace-available.js.erb +3 -0
- data/client/hippo/fonts/fontawesome-webfont.woff +0 -0
- data/client/hippo/fonts/fontawesome-webfont.woff2 +0 -0
- data/client/hippo/index.js +1 -0
- data/client/hippo/index.scss.erb +31 -0
- data/client/hippo/lib/__mocks__/loader.js +11 -0
- data/client/hippo/lib/__mocks__/request-assets.js +6 -0
- data/client/hippo/lib/all.js +14 -0
- data/client/hippo/lib/bootstrap.js +45 -0
- data/client/hippo/lib/index.js.erb +6 -0
- data/client/hippo/lib/loader.js +67 -0
- data/client/hippo/lib/request-assets.js +38 -0
- data/client/hippo/lib/smooth-scroll.js +68 -0
- data/client/hippo/lib/util.js +101 -0
- data/client/hippo/models/PubSub.js +208 -0
- data/client/hippo/models/__mocks__/sync.js +17 -0
- data/client/hippo/models/asset.js +104 -0
- data/client/hippo/models/base.js +142 -0
- data/client/hippo/models/collection.js +58 -0
- data/client/hippo/models/decorators.js +72 -0
- data/client/hippo/models/index.js +10 -0
- data/client/hippo/models/query.js +116 -0
- data/client/hippo/models/query/array-result.js +188 -0
- data/client/hippo/models/query/clause.js +52 -0
- data/client/hippo/models/query/field.js +63 -0
- data/client/hippo/models/query/info.js +43 -0
- data/client/hippo/models/query/operator.js +21 -0
- data/client/hippo/models/query/result.js +21 -0
- data/client/hippo/models/query/types.js +5 -0
- data/client/hippo/models/sync.js +135 -0
- data/client/hippo/models/system-setting.js +26 -0
- data/client/hippo/react/DefaultComponentNotFound.jsx +23 -0
- data/client/hippo/react/Root.jsx +24 -0
- data/client/hippo/react/index.js +7 -0
- data/client/hippo/react/viewport-root.jsx +44 -0
- data/client/hippo/screens/all.js.erb +3 -0
- data/client/hippo/screens/definition.js +67 -0
- data/client/hippo/screens/group.js +35 -0
- data/client/hippo/screens/index.js +34 -0
- data/client/hippo/screens/instance.js +99 -0
- data/client/hippo/screens/mixins/index.js +0 -0
- data/client/hippo/screens/register.js.erb +14 -0
- data/client/hippo/screens/styles.scss +8 -0
- data/client/hippo/screens/system-settings.jsx +92 -0
- data/client/hippo/screens/system-settings/mailer-config.jsx +53 -0
- data/client/hippo/screens/system-settings/system-settings.scss +8 -0
- data/client/hippo/screens/user-management.jsx +67 -0
- data/client/hippo/screens/user-management/edit-form.jsx +94 -0
- data/client/hippo/screens/user-management/index.scss +7 -0
- data/client/hippo/styles/fonts.scss +23 -0
- data/client/hippo/styles/fonts/_animated.scss +34 -0
- data/client/hippo/styles/fonts/_bordered-pulled.scss +25 -0
- data/client/hippo/styles/fonts/_core.scss +12 -0
- data/client/hippo/styles/fonts/_fixed-width.scss +6 -0
- data/client/hippo/styles/fonts/_icons.scss +789 -0
- data/client/hippo/styles/fonts/_larger.scss +13 -0
- data/client/hippo/styles/fonts/_list.scss +19 -0
- data/client/hippo/styles/fonts/_mixins.scss +60 -0
- data/client/hippo/styles/fonts/_path.scss +10 -0
- data/client/hippo/styles/fonts/_rotated-flipped.scss +20 -0
- data/client/hippo/styles/fonts/_screen-reader.scss +5 -0
- data/client/hippo/styles/fonts/_stacked.scss +20 -0
- data/client/hippo/styles/fonts/_variables.scss +800 -0
- data/client/hippo/styles/fonts/font-awesome.scss +18 -0
- data/client/hippo/styles/fonts/index.scss +2 -0
- data/client/hippo/styles/global.scss +3 -0
- data/client/hippo/styles/global/fancy-header.scss +14 -0
- data/client/hippo/styles/global/mixins.scss +5 -0
- data/client/hippo/styles/global/styles.scss +6 -0
- data/client/hippo/styles/variables.scss +28 -0
- data/client/hippo/testing/index.js +6 -0
- data/client/hippo/testing/matchers.js +14 -0
- data/client/hippo/testing/mocks/fetch.js +54 -0
- data/client/hippo/testing/screens.js +64 -0
- data/client/hippo/testing/utils.js +1 -0
- data/client/hippo/user.js +93 -0
- data/client/hippo/workspace/content.jsx +22 -0
- data/client/hippo/workspace/foo.js +0 -0
- data/client/hippo/workspace/index.jsx +85 -0
- data/client/hippo/workspace/menu-group.jsx +39 -0
- data/client/hippo/workspace/menu-option.jsx +41 -0
- data/client/hippo/workspace/menu.jsx +71 -0
- data/client/hippo/workspace/navbar.jsx +46 -0
- data/client/hippo/workspace/screen.jsx +50 -0
- data/client/hippo/workspace/styles.scss +61 -0
- data/client/hippo/workspace/styles/forms.scss +4 -0
- data/client/hippo/workspace/styles/header.scss +69 -0
- data/client/hippo/workspace/styles/keybindings.scss +6 -0
- data/client/hippo/workspace/styles/layout.scss +230 -0
- data/client/hippo/workspace/styles/screens.scss +15 -0
- data/client/hippo/workspace/styles/tabs.scss +141 -0
- data/client/hippo/workspace/tabs.jsx +60 -0
- data/client/hippo/workspace/viewport.jsx +82 -0
- data/client/images/hippo/ajax-loader.gif +0 -0
- data/client/images/hippo/logo-sm.png +0 -0
- data/coffeelint.json +49 -0
- data/command-reference-files/initial/.babelrc +20 -0
- data/command-reference-files/initial/.eslintrc.js +7 -0
- data/command-reference-files/initial/.gitignore +4 -0
- data/command-reference-files/initial/.rubocop.yml +9 -0
- data/command-reference-files/initial/Gemfile +9 -0
- data/command-reference-files/initial/Guardfile +13 -0
- data/command-reference-files/initial/Rakefile +2 -0
- data/command-reference-files/initial/client/appy-app/components/.gitkeep +0 -0
- data/command-reference-files/initial/client/appy-app/extension.js +32 -0
- data/command-reference-files/initial/client/appy-app/index.js +6 -0
- data/command-reference-files/initial/client/appy-app/models/.gitkeep +0 -0
- data/command-reference-files/initial/client/appy-app/models/base.js +11 -0
- data/command-reference-files/initial/client/appy-app/screens/.gitkeep +0 -0
- data/command-reference-files/initial/client/appy-app/styles.scss +1 -0
- data/command-reference-files/initial/config.ru +7 -0
- data/command-reference-files/initial/config/database.yml +11 -0
- data/command-reference-files/initial/config/initialize.rb +10 -0
- data/command-reference-files/initial/config/jest.config.json +19 -0
- data/command-reference-files/initial/config/jest/babel-transform.js +47 -0
- data/command-reference-files/initial/config/routes.rb +4 -0
- data/command-reference-files/initial/config/screens.rb +10 -0
- data/command-reference-files/initial/config/webpack.config.js +106 -0
- data/command-reference-files/initial/db/.gitkeep +0 -0
- data/command-reference-files/initial/lib/appy-app.rb +15 -0
- data/command-reference-files/initial/lib/appy-app/extension.rb +22 -0
- data/command-reference-files/initial/lib/appy-app/model.rb +11 -0
- data/command-reference-files/initial/lib/appy-app/version.rb +3 -0
- data/command-reference-files/initial/package.json +6 -0
- data/command-reference-files/initial/spec/client/.eslintrc.js +20 -0
- data/command-reference-files/initial/spec/client/setup.js +17 -0
- data/command-reference-files/initial/spec/server/spec_helper.rb +8 -0
- data/command-reference-files/initial/views/index.html +69 -0
- data/command-reference-files/model/client/appy-app/models/test_test.js +12 -0
- data/command-reference-files/model/config/routes.rb +4 -0
- data/command-reference-files/model/db/migrate/20150218032025_create_test_tests.rb +10 -0
- data/command-reference-files/model/lib/appy-app/model.rb +12 -0
- data/command-reference-files/model/lib/appy-app/models/test_test.rb +7 -0
- data/command-reference-files/model/spec/client/models/test_test.spec.js +8 -0
- data/command-reference-files/model/spec/fixtures/appy-app/test_test.yml +11 -0
- data/command-reference-files/model/spec/server/test_test_spec.rb +10 -0
- data/command-reference-files/screen/client/appy-app/extension.js +32 -0
- data/command-reference-files/screen/client/appy-app/screens/ready-set-go.jsx +22 -0
- data/command-reference-files/screen/config/screens.rb +19 -0
- data/command-reference-files/screen/spec/client/screens/ready-set-go.spec.jsx +12 -0
- data/config.ru +5 -0
- data/config/database.yml +9 -0
- data/config/jest.config.json +27 -0
- data/config/jest/babel-transform.js +47 -0
- data/config/jest/style-mock.js +2 -0
- data/config/jest/yaml-transform.js +19 -0
- data/config/routes.rb +28 -0
- data/config/screens.rb +42 -0
- data/config/webpack.config.js +105 -0
- data/db/migrate/01_create_system_settings.rb +10 -0
- data/db/migrate/02_create_assets.rb +13 -0
- data/db/migrate/20140615031600_create_users.rb +12 -0
- data/db/seed.rb +1 -0
- data/docs/command.md +114 -0
- data/docs/model.md +217 -0
- data/docs/react.md +137 -0
- data/docs/todo-example-part-1.md +69 -0
- data/docs/welcome.md +0 -0
- data/hippo-fw.gemspec +79 -0
- data/lib/generators/hippo/migrations/install_generator.rb +42 -0
- data/lib/hippo-fw.rb +1 -0
- data/lib/hippo.rb +34 -0
- data/lib/hippo/access.rb +49 -0
- data/lib/hippo/access/authentication_provider.rb +79 -0
- data/lib/hippo/access/config/database.yml +9 -0
- data/lib/hippo/access/config/routes.rb +20 -0
- data/lib/hippo/access/locked_fields.rb +43 -0
- data/lib/hippo/access/public/files/1nty/7ebo/n7k0/8b2ac0bbd97f401951fe40546f977200.png +0 -0
- data/lib/hippo/access/public/files/6hgp/eiw1/8dua/ba944287e36e101713a9c1ad793353b8.png +0 -0
- data/lib/hippo/access/public/files/94bd/9agc/2ua3/33800e285d7145760650ac88d1c558fb.png +0 -0
- data/lib/hippo/access/public/files/cr1e/vfwc/fvrh/0e7fe6ef12d622bfb93e024883c2f81c.png +0 -0
- data/lib/hippo/access/public/files/kezo/fm8j/u6xl/dfc47658aedd8e546abff63366a7285d.png +0 -0
- data/lib/hippo/access/public/files/n5c4/uovf/jec6/7ee9a3519e2b60430e095160a23f1d77.png +0 -0
- data/lib/hippo/access/role.rb +86 -0
- data/lib/hippo/access/role_collection.rb +88 -0
- data/lib/hippo/access/roles/administrator.rb +32 -0
- data/lib/hippo/access/roles/basic_user.rb +13 -0
- data/lib/hippo/access/roles/support.rb +15 -0
- data/lib/hippo/access/test_fixture_extensions.rb +16 -0
- data/lib/hippo/access/track_modifications.rb +79 -0
- data/lib/hippo/access/version.rb +5 -0
- data/lib/hippo/api.rb +23 -0
- data/lib/hippo/api/cable.rb +57 -0
- data/lib/hippo/api/controller_base.rb +299 -0
- data/lib/hippo/api/default_routes.rb +38 -0
- data/lib/hippo/api/error_formatter.rb +37 -0
- data/lib/hippo/api/formatted_reply.rb +62 -0
- data/lib/hippo/api/generic_controller.rb +35 -0
- data/lib/hippo/api/handlers/asset.rb +38 -0
- data/lib/hippo/api/handlers/print.rb +15 -0
- data/lib/hippo/api/handlers/user_session.rb +42 -0
- data/lib/hippo/api/helper_methods.rb +58 -0
- data/lib/hippo/api/pub_sub.rb +36 -0
- data/lib/hippo/api/request_wrapper.rb +105 -0
- data/lib/hippo/api/root.rb +70 -0
- data/lib/hippo/api/routing.rb +111 -0
- data/lib/hippo/api/sprockets_extension.rb +105 -0
- data/lib/hippo/api/to_json.rb +7 -0
- data/lib/hippo/api/updates.rb +37 -0
- data/lib/hippo/asset.rb +18 -0
- data/lib/hippo/capistrano.rb +30 -0
- data/lib/hippo/cli.rb +50 -0
- data/lib/hippo/command.rb +43 -0
- data/lib/hippo/command/app.rb +90 -0
- data/lib/hippo/command/client_config.rb +69 -0
- data/lib/hippo/command/client_model_update.rb +65 -0
- data/lib/hippo/command/console.rb +23 -0
- data/lib/hippo/command/db.rb +36 -0
- data/lib/hippo/command/db.usage +1 -0
- data/lib/hippo/command/generate.rb +24 -0
- data/lib/hippo/command/generate_component.rb +28 -0
- data/lib/hippo/command/generate_component.usage +11 -0
- data/lib/hippo/command/generate_migration.rb +33 -0
- data/lib/hippo/command/generate_model.rb +91 -0
- data/lib/hippo/command/generate_model.usage +45 -0
- data/lib/hippo/command/generate_screen.rb +40 -0
- data/lib/hippo/command/generate_screen.usage +8 -0
- data/lib/hippo/command/guard.rb +18 -0
- data/lib/hippo/command/jest.rb +40 -0
- data/lib/hippo/command/migration_support.rb +29 -0
- data/lib/hippo/command/model_attribute.rb +193 -0
- data/lib/hippo/command/named_command.rb +33 -0
- data/lib/hippo/command/puma.rb +56 -0
- data/lib/hippo/command/server.rb +19 -0
- data/lib/hippo/command/server.usage +3 -0
- data/lib/hippo/command/update.rb +13 -0
- data/lib/hippo/command/update_model.rb +127 -0
- data/lib/hippo/command/update_model.usage +2 -0
- data/lib/hippo/command/webpack.rb +57 -0
- data/lib/hippo/command/webpack_view.rb +32 -0
- data/lib/hippo/concerns/all.rb +15 -0
- data/lib/hippo/concerns/api_path.rb +21 -0
- data/lib/hippo/concerns/asset_uploader.rb +38 -0
- data/lib/hippo/concerns/association_extensions.rb +94 -0
- data/lib/hippo/concerns/attr_accessor_with_default.rb +68 -0
- data/lib/hippo/concerns/code_identifier.rb +43 -0
- data/lib/hippo/concerns/export_associations.rb +52 -0
- data/lib/hippo/concerns/export_join_tables.rb +39 -0
- data/lib/hippo/concerns/export_methods.rb +104 -0
- data/lib/hippo/concerns/export_scope.rb +64 -0
- data/lib/hippo/concerns/exported_limit_evaluator.rb +17 -0
- data/lib/hippo/concerns/pub_sub.rb +127 -0
- data/lib/hippo/concerns/queries.rb +24 -0
- data/lib/hippo/concerns/random_identifier.rb +37 -0
- data/lib/hippo/concerns/sanitize_fields.rb +32 -0
- data/lib/hippo/concerns/set_attribute_data.rb +125 -0
- data/lib/hippo/concerns/sorting_expressions.rb +34 -0
- data/lib/hippo/configuration.rb +143 -0
- data/lib/hippo/db.rb +57 -0
- data/lib/hippo/db/migrations.rb +32 -0
- data/lib/hippo/environment.rb +22 -0
- data/lib/hippo/extension.rb +112 -0
- data/lib/hippo/extension/definition.rb +90 -0
- data/lib/hippo/guard_tasks.rb +62 -0
- data/lib/hippo/hippo_guard_plugin.rb +80 -0
- data/lib/hippo/job.rb +82 -0
- data/lib/hippo/job/failure_logger.rb +33 -0
- data/lib/hippo/logger.rb +64 -0
- data/lib/hippo/mailer.rb +28 -0
- data/lib/hippo/model.rb +24 -0
- data/lib/hippo/multi_server_boot.rb +26 -0
- data/lib/hippo/numbers.rb +72 -0
- data/lib/hippo/rails_engine.rb +5 -0
- data/lib/hippo/rake_tasks.rb +69 -0
- data/lib/hippo/redis.rb +13 -0
- data/lib/hippo/reloadable_sinatra.rb +24 -0
- data/lib/hippo/reloadable_view.rb +13 -0
- data/lib/hippo/screen.rb +152 -0
- data/lib/hippo/spec_helper.rb +141 -0
- data/lib/hippo/strings.rb +56 -0
- data/lib/hippo/system_settings.rb +72 -0
- data/lib/hippo/templates/base.rb +44 -0
- data/lib/hippo/templates/latex.rb +101 -0
- data/lib/hippo/templates/liquid.rb +28 -0
- data/lib/hippo/user.rb +152 -0
- data/lib/hippo/validators/all.rb +2 -0
- data/lib/hippo/validators/email.rb +17 -0
- data/lib/hippo/validators/set.rb +18 -0
- data/lib/hippo/version.rb +5 -0
- data/lib/hippo/workspace.rb +4 -0
- data/lib/hippo/workspace/config/screens.rb +6 -0
- data/package.json +82 -0
- data/spec/client/.eslintrc.js +20 -0
- data/spec/client/access/login-dialog.spec.jsx +28 -0
- data/spec/client/components/__snapshots__/asset.spec.jsx.snap +48 -0
- data/spec/client/components/__snapshots__/network-activity-overlay.spec.jsx.snap +35 -0
- data/spec/client/components/__snapshots__/query-builder.spec.jsx.snap +82 -0
- data/spec/client/components/asset.spec.jsx +16 -0
- data/spec/client/components/data-list.spec.jsx +36 -0
- data/spec/client/components/data-table.spec.jsx +55 -0
- data/spec/client/components/form.spec.jsx +63 -0
- data/spec/client/components/network-activity-overlay.spec.jsx +30 -0
- data/spec/client/components/query-builder.spec.jsx +45 -0
- data/spec/client/components/record-finder.spec.jsx +45 -0
- data/spec/client/extension/base.spec.js +15 -0
- data/spec/client/lib/util.spec.js +48 -0
- data/spec/client/models/asset.spec.js +50 -0
- data/spec/client/models/base.spec.js +95 -0
- data/spec/client/models/collection.spec.js +51 -0
- data/spec/client/models/query.spec.js +243 -0
- data/spec/client/models/sync.spec.js +42 -0
- data/spec/client/models/system-setting.spec.js +19 -0
- data/spec/client/screens/__snapshots__/system-settings.spec.jsx.snap +364 -0
- data/spec/client/screens/__snapshots__/tabs.spec.jsx.snap +127 -0
- data/spec/client/screens/definition.spec.js +24 -0
- data/spec/client/screens/group.spec.js +33 -0
- data/spec/client/screens/instance.spec.js +61 -0
- data/spec/client/screens/system-settings.spec.jsx +22 -0
- data/spec/client/screens/tabs.spec.jsx +36 -0
- data/spec/client/screens/user-management.spec.jsx +48 -0
- data/spec/client/setup.js +12 -0
- data/spec/client/test-logo.json +41 -0
- data/spec/client/test-models.js +94 -0
- data/spec/client/user.spec.js +19 -0
- data/spec/client/workspace/__snapshots__/menu.spec.jsx.snap +380 -0
- data/spec/client/workspace/menu.spec.jsx +52 -0
- data/spec/factories/user.rb +11 -0
- data/spec/fixtures/logo.png +0 -0
- data/spec/fixtures/system_settings.yml +8 -0
- data/spec/fixtures/test_printer.tex +22 -0
- data/spec/fixtures/user.yml +2 -0
- data/spec/hippo/components/grid/GridSpec.coffee +56 -0
- data/spec/hippo/components/grid/PopoverEditorSpec.coffee +47 -0
- data/spec/hippo/components/grid/RowEditorSpec.coffee +98 -0
- data/spec/hippo/components/select-field/SelectFieldSpec.coffee +106 -0
- data/spec/hippo/components/shared/NetworkActivityOverlaySpec.coffee +34 -0
- data/spec/hippo/helpers/.gitkeep +0 -0
- data/spec/hippo/helpers/hippo-helpers.coffee +5 -0
- data/spec/hippo/helpers/jasmine-matchers.js +1580 -0
- data/spec/hippo/helpers/mock-ajax.js +573 -0
- data/spec/hippo/models/AssociationMapSpec.coffee +85 -0
- data/spec/hippo/models/AssociationProxySpec.coffee +76 -0
- data/spec/hippo/models/BaseSpec.coffee +155 -0
- data/spec/hippo/models/CollectionSpec.coffee +32 -0
- data/spec/hippo/models/EnumMapSpec.coffee +26 -0
- data/spec/hippo/models/PubSubSpec.coffee +71 -0
- data/spec/hippo/models/QuerySpec.coffee +19 -0
- data/spec/hippo/models/SyncSpec.coffee +28 -0
- data/spec/hippo/models/UserSpec.coffee +17 -0
- data/spec/hippo/react/mixins/DataSpec.coffee +74 -0
- data/spec/hippo/screens/DefinitionsSpec.coffee +33 -0
- data/spec/hippo/views/BaseSpec.coffee +147 -0
- data/spec/hippo/views/FormBindingsSpec.coffee +32 -0
- data/spec/server/api/controller_base_spec.rb +101 -0
- data/spec/server/assertions.rb +11 -0
- data/spec/server/asset_spec.rb +42 -0
- data/spec/server/command_spec.rb +73 -0
- data/spec/server/concerns/api_path_spec.rb +20 -0
- data/spec/server/concerns/association_extensions_spec.rb +24 -0
- data/spec/server/concerns/attr_accessor_with_default_spec.rb +63 -0
- data/spec/server/concerns/export_methods_spec.rb +34 -0
- data/spec/server/concerns/export_scope_spec.rb +14 -0
- data/spec/server/concerns/exported_limits_spec.rb +51 -0
- data/spec/server/concerns/pub_sub_spec.rb +132 -0
- data/spec/server/concerns/set_attribute_data_spec.rb +76 -0
- data/spec/server/concerns/sorting_expressions_spec.rb +34 -0
- data/spec/server/concerns/track_modifications_spec.rb +18 -0
- data/spec/server/configuration_spec.rb +26 -0
- data/spec/server/job_spec.rb +54 -0
- data/spec/server/mailer_spec.rb +33 -0
- data/spec/server/numbers_spec.rb +25 -0
- data/spec/server/print/form_spec.rb +29 -0
- data/spec/server/spec_helper.rb +74 -0
- data/spec/server/strings_spec.rb +41 -0
- data/spec/server/system_settings_spec.rb +39 -0
- data/tasks/migrations.rake +22 -0
- data/tasks/publish.rake +8 -0
- data/templates/.babelrc +20 -0
- data/templates/.gitignore +4 -0
- data/templates/Gemfile +9 -0
- data/templates/Guardfile +13 -0
- data/templates/Rakefile +2 -0
- data/templates/client/components/.gitkeep +0 -0
- data/templates/client/components/BaseComponent.coffee +9 -0
- data/templates/client/components/Component.cjsx +4 -0
- data/templates/client/components/template.html +3 -0
- data/templates/client/extension.js +32 -0
- data/templates/client/index.js +6 -0
- data/templates/client/models/base.js +11 -0
- data/templates/client/models/model.js +17 -0
- data/templates/client/screens/screen.jsx +22 -0
- data/templates/client/styles.scss +1 -0
- data/templates/config.ru +7 -0
- data/templates/config/database.yml +11 -0
- data/templates/config/initialize.rb +10 -0
- data/templates/config/jest.config.json +19 -0
- data/templates/config/jest/babel-transform.js +47 -0
- data/templates/config/routes.rb +4 -0
- data/templates/config/screen.rb +9 -0
- data/templates/config/screens.rb +10 -0
- data/templates/config/webpack.config.js +106 -0
- data/templates/db/create_table_migration.rb +19 -0
- data/templates/gitignore +4 -0
- data/templates/js/config-data.js +10 -0
- data/templates/js/jest.config.json +11 -0
- data/templates/js/root-view.html +71 -0
- data/templates/js/screen-definitions.js +22 -0
- data/templates/lib/namespace.rb +15 -0
- data/templates/lib/namespace/base_model.rb +11 -0
- data/templates/lib/namespace/extension.rb +22 -0
- data/templates/lib/namespace/model.rb +7 -0
- data/templates/lib/namespace/version.rb +3 -0
- data/templates/public/.gitkeep +0 -0
- data/templates/spec/client/components/ComponentSpec.coffee +5 -0
- data/templates/spec/client/models/model.spec.js +8 -0
- data/templates/spec/client/screen.spec.jsx +12 -0
- data/templates/spec/client/setup.js +17 -0
- data/templates/spec/fixtures/namespace/model.yml +16 -0
- data/templates/spec/server/model_spec.rb +10 -0
- data/templates/spec/server/spec_helper.rb +8 -0
- data/test.js +7 -0
- data/views/hippo_root_view.erb +68 -0
- data/views/index.html +71 -0
- data/yard_ext/all.rb +9 -0
- data/yard_ext/code_identifier_handler.rb +33 -0
- data/yard_ext/concern_meta_methods.rb +60 -0
- data/yard_ext/config_options.rb +27 -0
- data/yard_ext/exported_scope.rb +4 -0
- data/yard_ext/immutable_handler.rb +17 -0
- data/yard_ext/json_attr_accessor.rb +22 -0
- data/yard_ext/locked_fields_handler.rb +21 -0
- data/yard_ext/templates/default/layout/html/layout.erb +20 -0
- data/yard_ext/templates/default/method_details/html/github_link.erb +1 -0
- data/yard_ext/templates/default/method_details/setup.rb +3 -0
- data/yard_ext/validators.rb +1 -0
- data/yard_ext/visible_id_handler.rb +38 -0
- data/yarn.lock +6562 -0
- 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,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,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,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
|
+
}());
|