@angular-wave/angular.ts 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/animations/raf-scheduler.d.ts +2 -2
- package/@types/animations/shared.d.ts +0 -1
- package/@types/core/compile/attributes.d.ts +3 -3
- package/@types/core/compile/compile.d.ts +1 -1
- package/@types/core/di/injector.d.ts +0 -1
- package/@types/core/di/internal-injector.d.ts +1 -0
- package/@types/core/di/ng-module.d.ts +5 -0
- package/@types/core/filter/filter.d.ts +11 -13
- package/@types/core/parse/parse.d.ts +6 -7
- package/@types/core/sanitize/sanitize-uri.d.ts +3 -6
- package/@types/core/scope/scope.d.ts +1 -1
- package/@types/directive/attrs/attrs.d.ts +7 -1
- package/@types/directive/bind/bind.d.ts +2 -1
- package/@types/directive/events/events.d.ts +9 -3
- package/@types/directive/http/http.d.ts +6 -2
- package/@types/directive/include/include.d.ts +2 -2
- package/@types/directive/input/input.d.ts +2 -12
- package/@types/directive/messages/messages.d.ts +9 -48
- package/@types/directive/model/model.d.ts +3 -3
- package/@types/directive/options/options.d.ts +13 -20
- package/@types/directive/switch/switch.d.ts +1 -0
- package/@types/directive/transclude/transclude.d.ts +10 -6
- package/@types/index.d.ts +1 -1
- package/@types/interface.d.ts +56 -18
- package/@types/{public.d.ts → ng.d.ts} +2 -2
- package/@types/router/directives/view-directive.d.ts +2 -19
- package/@types/router/{common → glob}/glob.d.ts +5 -1
- package/@types/router/globals.d.ts +2 -3
- package/@types/router/path/path-utils.d.ts +8 -11
- package/@types/router/state/interface.d.ts +1 -1
- package/@types/router/state/state-object.d.ts +1 -1
- package/@types/router/state/state-registry.d.ts +1 -2
- package/@types/router/state/state-service.d.ts +8 -7
- package/@types/router/state-filters.d.ts +24 -2
- package/@types/router/transition/transition.d.ts +12 -15
- package/@types/router/url/url-matcher.d.ts +3 -3
- package/@types/router/url/url-rule.d.ts +1 -0
- package/@types/router/url/url-rules.d.ts +26 -6
- package/@types/router/url/url-service.d.ts +30 -42
- package/@types/services/anchor-scroll.d.ts +1 -1
- package/@types/{core → services/exception}/exception-handler.d.ts +4 -4
- package/@types/{core/error-handler.d.ts → services/exception/interface.d.ts} +1 -1
- package/@types/services/http/http.d.ts +48 -3
- package/@types/services/http/interface.d.ts +2 -2
- package/@types/services/http-backend/http-backend.d.ts +49 -44
- package/@types/services/location/interface.d.ts +63 -0
- package/@types/services/location/location.d.ts +330 -0
- package/@types/{core → services}/sce/sce.d.ts +1 -1
- package/@types/services/template-cache/interface.d.ts +8 -2
- package/@types/services/template-cache/template-cache.d.ts +1 -1
- package/@types/services/template-request.d.ts +1 -1
- package/@types/shared/cache.d.ts +0 -2
- package/@types/shared/common.d.ts +0 -2
- package/@types/shared/dom.d.ts +6 -0
- package/@types/shared/interface.d.ts +0 -4
- package/@types/{router/common → shared}/queue.d.ts +2 -2
- package/@types/shared/test-utils.d.ts +1 -0
- package/@types/shared/url-utils/interface.d.ts +46 -0
- package/@types/shared/url-utils/url-utils.d.ts +64 -0
- package/@types/shared/utils.d.ts +44 -6
- package/Makefile +8 -4
- package/dist/angular-ts.esm.js +1889 -2199
- package/dist/angular-ts.umd.js +1889 -2199
- package/dist/angular-ts.umd.min.js +1 -1
- package/docs/assets/scss/index.scss +23 -0
- package/docs/content/_index.md +9 -8
- package/docs/content/docs/_index.md +1 -1
- package/docs/content/docs/directive/app.md +1 -1
- package/docs/content/docs/directive/bind.md +10 -8
- package/docs/content/docs/directive/blur.md +1 -1
- package/docs/content/docs/directive/channel.md +2 -2
- package/docs/content/docs/directive/class-even.md +1 -1
- package/docs/content/docs/directive/class-odd.md +1 -1
- package/docs/content/docs/directive/class.md +1 -1
- package/docs/content/docs/directive/click.md +1 -1
- package/docs/content/docs/directive/copy.md +1 -1
- package/docs/content/docs/directive/cut.md +1 -1
- package/docs/content/docs/directive/dblclick.md +1 -1
- package/docs/content/docs/directive/focus.md +1 -1
- package/docs/content/docs/directive/get.md +203 -0
- package/docs/content/docs/directive/keydown.md +1 -1
- package/docs/content/docs/directive/keyup.md +1 -1
- package/docs/content/docs/directive/load.md +1 -1
- package/docs/content/docs/directive/mousedown.md +1 -1
- package/docs/content/docs/directive/mouseenter.md +1 -1
- package/docs/content/docs/directive/mouseleave.md +1 -1
- package/docs/content/docs/directive/mousemove.md +1 -1
- package/docs/content/docs/directive/mouseout.md +1 -1
- package/docs/content/docs/directive/mouseover.md +1 -1
- package/docs/content/docs/directive/mouseup.md +1 -1
- package/docs/content/docs/directive/non-bindable.md +28 -0
- package/docs/content/docs/provider/locationProvider.md +26 -0
- package/docs/content/docs/provider/templateCacheProvider.md +66 -1
- package/docs/content/docs/service/location.md +57 -0
- package/docs/content/docs/service/templateCache.md +2 -2
- package/docs/content/docs/service/url.md +5 -0
- package/docs/layouts/partials/hooks/head-end.html +1 -1
- package/docs/layouts/shortcodes/showcss.html +2 -0
- package/docs/layouts/shortcodes/version.html +1 -0
- package/docs/static/examples/counter/counter-test.html +0 -4
- package/docs/static/examples/eventbus/eventbus-test.html +0 -4
- package/docs/static/examples/ng-bind/ng-bind.html +2 -2
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +13 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +3 -0
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +11 -0
- package/docs/static/typedoc/assets/hierarchy.js +1 -1
- package/docs/static/typedoc/assets/highlight.css +6 -6
- package/docs/static/typedoc/assets/navigation.js +1 -1
- package/docs/static/typedoc/assets/search.js +1 -1
- package/docs/static/typedoc/classes/Location.html +55 -0
- package/docs/static/typedoc/classes/LocationProvider.html +20 -0
- package/docs/static/typedoc/classes/NgModule.html +32 -0
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +1 -1
- package/docs/static/typedoc/hierarchy.html +1 -1
- package/docs/static/typedoc/index.html +1 -1
- package/docs/static/typedoc/interfaces/DefaultPorts.html +5 -0
- package/docs/static/typedoc/interfaces/Directive.html +5 -4
- package/docs/static/typedoc/interfaces/Html5Mode.html +23 -0
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +1 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +2 -3
- package/docs/static/typedoc/interfaces/Provider.html +16 -10
- package/docs/static/typedoc/interfaces/RequestConfig.html +1 -1
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +1 -1
- package/docs/static/typedoc/interfaces/TemplateCache.html +7 -0
- package/docs/static/typedoc/interfaces/UrlParts.html +9 -0
- package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +1 -0
- package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
- package/docs/static/typedoc/types/DirectiveFactory.html +1 -2
- package/docs/static/typedoc/types/DirectiveFactoryFn.html +1 -0
- package/docs/static/typedoc/types/Expression.html +1 -1
- package/docs/static/typedoc/types/HttpResponseStatus.html +1 -0
- package/docs/static/typedoc/types/{TemplateCache.html → SwapModeType.html} +1 -1
- package/docs/static/typedoc/types/UrlChangeListener.html +5 -0
- package/docs/static/typedoc/variables/SwapMode.html +11 -0
- package/docs/static/version.js +13 -0
- package/docs/test-results/.last-run.json +4 -0
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +50 -0
- package/legacy.d.ts +0 -10
- package/package.json +1 -3
- package/src/{loader.js → angular.js} +5 -10
- package/src/angular.spec.js +189 -21
- package/src/animations/animate-children-directive.js +2 -2
- package/src/animations/animate-css.js +17 -18
- package/src/animations/animate.spec.js +1 -1
- package/src/animations/raf-scheduler.js +1 -1
- package/src/animations/shared.js +2 -12
- package/src/binding.spec.js +1 -1
- package/src/core/compile/attributes.js +1 -1
- package/src/core/compile/compile.js +7 -10
- package/src/core/compile/compile.spec.js +1 -1
- package/src/core/controller/controller.spec.js +1 -1
- package/src/core/controller/controller.test.js +1 -0
- package/src/core/di/injector.js +11 -25
- package/src/core/di/injector.spec.js +2 -2
- package/src/core/di/injector.test.js +2 -2
- package/src/core/di/internal-injector.js +7 -7
- package/src/core/di/ng-module.js +12 -27
- package/src/core/filter/filter.js +28 -28
- package/src/core/filter/filter.spec.js +1 -1
- package/src/core/filter/filter.test.js +1 -0
- package/src/core/interpolate/interpolate.js +4 -6
- package/src/core/interpolate/interpolate.spec.js +1 -1
- package/src/core/interpolate/interpolate.test.js +1 -0
- package/src/core/parse/ast/ast.spec.js +1 -1
- package/src/core/parse/ast/ast.test.js +1 -1
- package/src/core/parse/interpreter.js +32 -38
- package/src/core/parse/lexer/lexer.spec.js +1 -1
- package/src/core/parse/parse.js +150 -146
- package/src/core/parse/parse.spec.js +17 -16
- package/src/core/prop.spec.js +1 -1
- package/src/core/root-element.spec.js +1 -1
- package/src/core/sanitize/sanitize-uri.js +3 -3
- package/src/core/scope/scope.js +12 -13
- package/src/core/scope/scope.spec.js +3 -4
- package/src/directive/aria/aria.spec.js +1 -1
- package/src/directive/aria/aria.test.js +1 -0
- package/src/directive/attrs/attrs.js +7 -4
- package/src/directive/attrs/attrs.spec.js +1 -1
- package/src/directive/attrs/attrs.test.js +1 -0
- package/src/directive/attrs/boolean.spec.js +1 -1
- package/src/directive/attrs/boolean.test.js +1 -0
- package/src/directive/attrs/element-style.spec.js +1 -1
- package/src/directive/attrs/element-style.test.js +1 -0
- package/src/directive/attrs/src.spec.js +1 -1
- package/src/directive/attrs/src.test.js +1 -0
- package/src/directive/bind/bind-html.spec.js +1 -1
- package/src/directive/bind/bind.js +1 -0
- package/src/directive/bind/bind.spec.js +1 -1
- package/src/directive/bind/bind.test.js +1 -0
- package/src/directive/channel/channel.spec.js +1 -1
- package/src/directive/channel/channel.test.js +1 -0
- package/src/directive/class/class.spec.js +1 -1
- package/src/directive/class/class.test.js +1 -0
- package/src/directive/cloak/cloak.spec.js +1 -1
- package/src/directive/cloak/cloak.test.js +1 -0
- package/src/directive/controller/controller.spec.js +1 -1
- package/src/directive/controller/controller.test.js +1 -0
- package/src/directive/events/click.spec.js +1 -1
- package/src/directive/events/event.spec.js +1 -1
- package/src/directive/events/events.js +6 -2
- package/src/directive/events/events.test.js +1 -0
- package/src/directive/form/form.js +8 -5
- package/src/directive/form/form.spec.js +1 -1
- package/src/directive/form/form.test.js +1 -0
- package/src/directive/http/delete.spec.js +3 -1
- package/src/directive/http/form-test.html +18 -0
- package/src/directive/http/get.spec.js +281 -4
- package/src/directive/http/http.js +112 -15
- package/src/directive/http/http.test.js +2 -2
- package/src/directive/http/post.spec.js +506 -9
- package/src/directive/http/put.spec.js +3 -1
- package/src/directive/if/if.spec.js +1 -1
- package/src/directive/include/include.js +7 -7
- package/src/directive/include/include.spec.js +1 -1
- package/src/directive/init/init.spec.js +1 -1
- package/src/directive/init/init.test.js +1 -0
- package/src/directive/input/input.js +19 -43
- package/src/directive/input/input.spec.js +1 -2
- package/src/directive/input/input.test.js +1 -0
- package/src/directive/messages/messages.js +4 -0
- package/src/directive/messages/messages.spec.js +1 -1
- package/src/directive/messages/messages.test.js +1 -0
- package/src/directive/model/model.js +14 -14
- package/src/directive/model/model.spec.js +1 -1
- package/src/directive/model/model.test.js +1 -0
- package/src/directive/model-options/model-option.test.js +1 -0
- package/src/directive/model-options/model-options.js +1 -1
- package/src/directive/model-options/model-options.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.spec.js +1 -1
- package/src/directive/non-bindable/non-bindable.test.js +1 -0
- package/src/directive/observe/observe.spec.js +1 -1
- package/src/directive/observe/observe.test.js +1 -0
- package/src/directive/on/on.spec.js +1 -1
- package/src/directive/on/on.test.js +1 -0
- package/src/directive/options/options.js +454 -464
- package/src/directive/options/options.spec.js +1 -1
- package/src/directive/options/options.test.js +1 -0
- package/src/directive/ref/href.spec.js +1 -1
- package/src/directive/ref/href.test.js +2 -0
- package/src/directive/ref/ref.spec.js +1 -1
- package/src/directive/repeat/repeat.spec.js +2 -3
- package/src/directive/repeat/repeat.test.js +1 -0
- package/src/directive/script/script.spec.js +1 -1
- package/src/directive/script/script.test.js +1 -0
- package/src/directive/select/select.js +1 -1
- package/src/directive/select/select.spec.js +1 -1
- package/src/directive/select/select.test.js +1 -0
- package/src/directive/setter/setter.js +12 -14
- package/src/directive/setter/setter.spec.js +40 -17
- package/src/directive/setter/setter.test.js +1 -0
- package/src/directive/show-hide/show-hide.spec.js +1 -1
- package/src/directive/show-hide/show-hide.test.js +1 -0
- package/src/directive/style/style.spec.js +1 -1
- package/src/directive/style/style.test.js +1 -0
- package/src/directive/switch/switch.js +1 -0
- package/src/directive/switch/switch.spec.js +1 -1
- package/src/directive/switch/switch.test.js +1 -0
- package/src/directive/transclude/transclude.js +87 -89
- package/src/directive/validators/validators.js +82 -84
- package/src/directive/validators/validators.spec.js +5 -4
- package/src/directive/validators/validators.test.js +1 -0
- package/src/filters/filter.spec.js +1 -1
- package/src/filters/filters.spec.js +1 -1
- package/src/filters/limit-to.js +2 -3
- package/src/filters/limit-to.spec.js +1 -1
- package/src/filters/order-by.spec.js +1 -1
- package/src/index.js +1 -1
- package/src/injection-tokens.js +6 -2
- package/src/interface.ts +70 -19
- package/src/loader.md +0 -155
- package/src/{public.js → ng.js} +16 -23
- package/src/{public.spec.js → ng.spec.js} +1 -1
- package/src/router/directives/state-directives.spec.js +9 -8
- package/src/router/directives/view-directive.js +11 -9
- package/src/router/directives/view-directive.spec.js +8 -9
- package/src/router/{common/common.html → glob/glob.html} +2 -3
- package/src/router/{common → glob}/glob.js +5 -0
- package/src/router/{common/common.test.js → glob/glob.test.js} +2 -1
- package/src/router/globals.js +1 -2
- package/src/router/path/path-utils.js +5 -0
- package/src/router/router-test-hashbang.html +45 -0
- package/src/router/services.spec.js +5 -6
- package/src/router/state/interface.ts +1 -1
- package/src/router/state/state-builder.js +3 -3
- package/src/router/state/state-builder.spec.js +1 -1
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +2 -3
- package/src/router/state/state-service.js +13 -10
- package/src/router/state/state.spec.js +23 -22
- package/src/router/state/state.test.js +1 -0
- package/src/router/state/views.js +1 -1
- package/src/router/state-filter.spec.js +1 -1
- package/src/router/state-filters.js +15 -11
- package/src/router/template-factory.js +5 -4
- package/src/router/template-factory.spec.js +1 -1
- package/src/router/transition/hook-registry.js +1 -1
- package/src/router/transition/transition-service.js +6 -5
- package/src/router/transition/transition.js +4 -4
- package/src/router/url/url-matcher.js +3 -3
- package/src/router/url/url-rule.js +1 -0
- package/src/router/url/url-rules.js +8 -5
- package/src/router/url/url-service.js +82 -85
- package/src/router/url/url-service.spec.js +55 -39
- package/src/router/url/url.test.js +1 -0
- package/src/router/view/view.js +4 -5
- package/src/router/view/view.spec.js +10 -12
- package/src/router/view/view.test.js +1 -0
- package/src/router/view-hook.spec.js +1 -1
- package/src/router/view-scroll.spec.js +1 -1
- package/src/services/anchor-scroll.html +2 -9
- package/src/services/anchor-scroll.js +6 -5
- package/src/{core → services/exception}/exception-handler.js +2 -2
- package/src/{core/error-handler.ts → services/exception/interface.ts} +1 -1
- package/src/services/http/http.js +11 -17
- package/src/services/http/http.spec.js +2 -7
- package/src/services/http/interface.ts +2 -2
- package/src/services/http/template-request.spec.js +1 -1
- package/src/services/http-backend/http-backend.js +53 -89
- package/src/services/http-backend/http-backend.spec.js +2 -6
- package/src/services/http-backend/http-backend.test.js +1 -0
- package/src/services/location/interface.ts +70 -0
- package/src/{core → services}/location/location.html +4 -1
- package/src/services/location/location.js +999 -0
- package/src/{core → services}/location/location.spec.js +911 -532
- package/src/{core → services}/location/location.test.js +2 -2
- package/src/services/log/log.spec.js +1 -1
- package/src/services/log/log.test.js +1 -0
- package/src/services/pubsub/pubsub.spec.js +1 -1
- package/src/{core → services}/sce/sce.html +1 -1
- package/src/{core → services}/sce/sce.js +14 -10
- package/src/{core → services}/sce/sce.md +2 -2
- package/src/{core → services}/sce/sce.spec.js +3 -4
- package/src/{core → services}/sce/sce.test.js +1 -1
- package/src/services/template-cache/interface.ts +8 -2
- package/src/services/template-cache/template-cache.js +3 -1
- package/src/services/template-cache/template-cache.spec.js +73 -1
- package/src/services/template-cache/template-cache.test.js +1 -0
- package/src/services/template-request.js +2 -1
- package/src/shared/cache.js +0 -2
- package/src/shared/common.js +0 -5
- package/src/shared/common.spec.js +1 -1
- package/src/shared/dom.js +10 -0
- package/src/shared/interface.ts +0 -4
- package/src/{router/common → shared}/queue.js +7 -7
- package/src/shared/shared.html +1 -0
- package/src/shared/shared.test.js +1 -0
- package/src/shared/test-utils.js +1 -0
- package/src/shared/url-utils/interface.ts +54 -0
- package/src/{core → shared}/url-utils/url-utils.html +4 -1
- package/src/{core → shared}/url-utils/url-utils.js +26 -47
- package/src/{core → shared}/url-utils/url-utils.spec.js +10 -17
- package/src/{core → shared}/url-utils/url-utils.test.js +1 -1
- package/src/shared/utils.js +60 -9
- package/src/shared/utils.spec.js +35 -1
- package/src/src.html +1 -2
- package/typedoc.json +0 -1
- package/utils/express.js +36 -2
- package/utils/version.cjs +23 -0
- package/@types/core/location/location.d.ts +0 -317
- package/@types/core/task-tracker-factory.d.ts +0 -76
- package/@types/core/url-utils/url-utils.d.ts +0 -56
- package/@types/router/state-provider.d.ts +0 -123
- package/@types/services/browser.d.ts +0 -101
- package/docs/static/typedoc/types/SwapInsertPosition.html +0 -2
- package/jsdoc.json +0 -22
- package/src/core/location/location.js +0 -984
- package/src/core/location/location.md +0 -114
- package/src/core/task-tracker-factory.js +0 -145
- package/src/core/url-utils/url-utils.md +0 -46
- package/src/directive/non-bindable/non-bindable.md +0 -17
- package/src/loader.spec.js +0 -169
- package/src/router/state-provider.js +0 -146
- package/src/services/browser.js +0 -212
- /package/@types/{loader.d.ts → angular.d.ts} +0 -0
- /package/src/router/{common → glob}/glob.spec.js +0 -0
- /package/src/{router/common → shared}/queue.spec.js +0 -0
|
@@ -1,24 +1,521 @@
|
|
|
1
|
-
import { Angular } from "../../
|
|
2
|
-
|
|
1
|
+
import { Angular } from "../../angular.js";
|
|
2
|
+
import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
3
|
+
import { dealoc } from "../../shared/dom.js";
|
|
3
4
|
|
|
4
|
-
describe("
|
|
5
|
-
let $compile, $rootScope, $
|
|
5
|
+
describe("ng-post", () => {
|
|
6
|
+
let $compile, $rootScope, $log, el;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
el = document.getElementById("app");
|
|
10
|
+
dealoc(el);
|
|
9
11
|
el.innerHTML = "";
|
|
10
12
|
let angular = new Angular();
|
|
11
|
-
angular.module("default", [])
|
|
13
|
+
angular.module("default", []).config([
|
|
14
|
+
"$stateProvider",
|
|
15
|
+
"$locationProvider",
|
|
16
|
+
($stateProvider) => {
|
|
17
|
+
$stateProvider
|
|
18
|
+
.state({
|
|
19
|
+
name: "success",
|
|
20
|
+
url: "/success",
|
|
21
|
+
template: `success`,
|
|
22
|
+
})
|
|
23
|
+
.state({
|
|
24
|
+
name: "error",
|
|
25
|
+
url: "/error",
|
|
26
|
+
template: `error`,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
12
30
|
angular
|
|
13
31
|
.bootstrap(el, ["default"])
|
|
14
|
-
.invoke((_$compile_, _$rootScope_, _$
|
|
32
|
+
.invoke((_$compile_, _$rootScope_, _$log_) => {
|
|
15
33
|
$compile = _$compile_;
|
|
16
34
|
$rootScope = _$rootScope_;
|
|
17
|
-
$
|
|
35
|
+
$log = _$log_;
|
|
18
36
|
});
|
|
19
37
|
});
|
|
20
38
|
|
|
21
|
-
it("should
|
|
22
|
-
|
|
39
|
+
it("should replace innerHTML (default) on click", async () => {
|
|
40
|
+
const scope = $rootScope.$new();
|
|
41
|
+
el.innerHTML = '<button ng-post="/mock/hello">Load</button>';
|
|
42
|
+
$compile(el)(scope);
|
|
43
|
+
browserTrigger(el.querySelector("button"), "click");
|
|
44
|
+
await wait(100);
|
|
45
|
+
expect(el.innerText).toBe("Hello");
|
|
23
46
|
});
|
|
47
|
+
|
|
48
|
+
it("should replace innerHTML (default) on click when used with expression", async () => {
|
|
49
|
+
const scope = $rootScope.$new();
|
|
50
|
+
el.innerHTML = '<button ng-post="/mock/{{a}}">Load</button>';
|
|
51
|
+
scope.a = "hello";
|
|
52
|
+
$compile(el)(scope);
|
|
53
|
+
browserTrigger(el.querySelector("button"), "click");
|
|
54
|
+
await wait(100);
|
|
55
|
+
expect(el.firstChild.innerHTML).toBe("<div>Hello</div>");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should attach parameters of a form and replace innerHTML (default) on click", async () => {
|
|
59
|
+
const scope = $rootScope.$new();
|
|
60
|
+
el.innerHTML =
|
|
61
|
+
'<form ng-post="/mock/posthtml"><input name="name" value="Bob" /><button type="submit">Load</button></form>';
|
|
62
|
+
$compile(el)(scope);
|
|
63
|
+
browserTrigger(el.querySelector("form"), "submit");
|
|
64
|
+
await wait(100);
|
|
65
|
+
expect(el.innerText).toBe("Bob");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("should use json encoding by default", async () => {
|
|
69
|
+
const scope = $rootScope.$new();
|
|
70
|
+
el.innerHTML =
|
|
71
|
+
'<form ng-post="/mock/json"> {{ name }} <input name="name" value="Bob" /><button type="submit">Load</button></form>';
|
|
72
|
+
$compile(el)(scope);
|
|
73
|
+
browserTrigger(el.querySelector("form"), "submit");
|
|
74
|
+
await wait(100);
|
|
75
|
+
expect(el.innerText).toBe("Bob Load");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should use encoding in enctype", async () => {
|
|
79
|
+
const scope = $rootScope.$new();
|
|
80
|
+
el.innerHTML = `
|
|
81
|
+
<form ng-post="/mock/urlencoded" enctype="application/x-www-form-urlencoded">
|
|
82
|
+
<input type="text" name="name" value="Bob"/>
|
|
83
|
+
<button type="submit">Load</button>
|
|
84
|
+
</form>`;
|
|
85
|
+
$compile(el)(scope);
|
|
86
|
+
browserTrigger(el.querySelector("form"), "submit");
|
|
87
|
+
await wait(100);
|
|
88
|
+
expect(el.innerText).toBe("Form data: Bob");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// it("should attach parameters of a form and replace innerHTML (default) on click in case of error", async () => {
|
|
92
|
+
// const scope = $rootScope.$new();
|
|
93
|
+
// el.innerHTML =
|
|
94
|
+
// '<form ng-post="/mock/posterror"><input name="name" value="Bob"></input><button type="submit">Load</button></form>';
|
|
95
|
+
// $compile(el)(scope);
|
|
96
|
+
// browserTrigger(el.querySelector("form"), "submit");
|
|
97
|
+
// await wait(100);
|
|
98
|
+
// expect(el.innerText).toBe("Error");
|
|
99
|
+
// });
|
|
100
|
+
|
|
101
|
+
// it("should replace innerHTML on error", async () => {
|
|
102
|
+
// const scope = $rootScope.$new();
|
|
103
|
+
// el.innerHTML = '<button ng-post="/mock/422">Load</button>';
|
|
104
|
+
// $compile(el)(scope);
|
|
105
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
106
|
+
// await wait(100);
|
|
107
|
+
// expect(el.innerText).toBe("Invalid data");
|
|
108
|
+
// });
|
|
109
|
+
|
|
110
|
+
// it("should not trigger request if element is disabled", async () => {
|
|
111
|
+
// el.innerHTML = '<button ng-post="/mock/hello" disabled>Load</button>';
|
|
112
|
+
// const scope = $rootScope.$new();
|
|
113
|
+
// $compile(el)(scope);
|
|
114
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
115
|
+
// await wait(100);
|
|
116
|
+
// expect(el.innerText).toBe("Load");
|
|
117
|
+
// });
|
|
118
|
+
|
|
119
|
+
// it("should replace innerHTML on status error without a body", async () => {
|
|
120
|
+
// const scope = $rootScope.$new();
|
|
121
|
+
// el.innerHTML = '<button ng-post="/mock/401">Load</button>';
|
|
122
|
+
// $compile(el)(scope);
|
|
123
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
124
|
+
// await wait(100);
|
|
125
|
+
// expect(el.innerText).toBe("Unauthorized");
|
|
126
|
+
// });
|
|
127
|
+
|
|
128
|
+
// describe("data-trigger", () => {
|
|
129
|
+
// it("should not trigger request on click if element has trigger attribute", async () => {
|
|
130
|
+
// el.innerHTML =
|
|
131
|
+
// '<button ng-post="/mock/hello" data-trigger="mouseover">Load</button>';
|
|
132
|
+
// const scope = $rootScope.$new();
|
|
133
|
+
// $compile(el)(scope);
|
|
134
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
135
|
+
// await wait(100);
|
|
136
|
+
// expect(el.innerText).toBe("Load");
|
|
137
|
+
// });
|
|
138
|
+
|
|
139
|
+
// it("should trigger request on new event name if element has trigger attribute", async () => {
|
|
140
|
+
// el.innerHTML =
|
|
141
|
+
// '<button ng-post="/mock/hello" data-trigger="mouseover">Load</button>';
|
|
142
|
+
// const scope = $rootScope.$new();
|
|
143
|
+
// $compile(el)(scope);
|
|
144
|
+
// browserTrigger(el.querySelector("button"), "mouseover");
|
|
145
|
+
// await wait(100);
|
|
146
|
+
// expect(el.innerText).toBe("Hello");
|
|
147
|
+
// });
|
|
148
|
+
// });
|
|
149
|
+
|
|
150
|
+
// describe("data-latch", () => {
|
|
151
|
+
// it("should trigger request on latch change", async () => {
|
|
152
|
+
// el.innerHTML =
|
|
153
|
+
// '<button ng-post="/mock/now" data-latch="{{ latch }}">Load</button>';
|
|
154
|
+
// const scope = $rootScope.$new();
|
|
155
|
+
// $compile(el)(scope);
|
|
156
|
+
// await wait(100);
|
|
157
|
+
// expect(el.innerText).toBe("Load");
|
|
158
|
+
// scope.latch = true;
|
|
159
|
+
// await wait(100);
|
|
160
|
+
// expect(el.innerText).not.toBe("Load");
|
|
161
|
+
// const firstRes = parseInt(el.innerText);
|
|
162
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
163
|
+
|
|
164
|
+
// scope.latch = !scope.latch;
|
|
165
|
+
// await wait(100);
|
|
166
|
+
// const secondRes = parseInt(el.innerText);
|
|
167
|
+
// expect(secondRes).toBeGreaterThan(firstRes);
|
|
168
|
+
|
|
169
|
+
// scope.latch = !scope.latch;
|
|
170
|
+
// await wait(100);
|
|
171
|
+
// const thirdRes = parseInt(el.innerText);
|
|
172
|
+
// expect(thirdRes).toBeGreaterThan(secondRes);
|
|
173
|
+
// });
|
|
174
|
+
|
|
175
|
+
// it("should still work with events with latch change", async () => {
|
|
176
|
+
// el.innerHTML =
|
|
177
|
+
// '<button ng-post="/mock/now" data-latch="{{ latch }}">Load</button>';
|
|
178
|
+
// const scope = $rootScope.$new();
|
|
179
|
+
// $compile(el)(scope);
|
|
180
|
+
// await wait(100);
|
|
181
|
+
// expect(el.innerText).toBe("Load");
|
|
182
|
+
// scope.latch = true;
|
|
183
|
+
// await wait(100);
|
|
184
|
+
// expect(el.innerText).not.toBe("Load");
|
|
185
|
+
// const firstRes = parseInt(el.innerText);
|
|
186
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
187
|
+
|
|
188
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
189
|
+
// await wait(100);
|
|
190
|
+
// const secondRes = parseInt(el.innerText);
|
|
191
|
+
// expect(secondRes).toBeGreaterThan(firstRes);
|
|
192
|
+
// });
|
|
193
|
+
|
|
194
|
+
// it("should still work with custom events with latch change", async () => {
|
|
195
|
+
// el.innerHTML =
|
|
196
|
+
// '<button ng-post="/mock/now" data-latch="{{ latch }}" data-trigger="mouseover">Load</button>';
|
|
197
|
+
// const scope = $rootScope.$new();
|
|
198
|
+
// $compile(el)(scope);
|
|
199
|
+
// await wait(100);
|
|
200
|
+
// expect(el.innerText).toBe("Load");
|
|
201
|
+
// scope.latch = true;
|
|
202
|
+
// await wait(100);
|
|
203
|
+
// expect(el.innerText).not.toBe("Load");
|
|
204
|
+
// const firstRes = parseInt(el.innerText);
|
|
205
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
206
|
+
|
|
207
|
+
// browserTrigger(el.querySelector("button"), "mouseover");
|
|
208
|
+
// await wait(100);
|
|
209
|
+
// const secondRes = parseInt(el.innerText);
|
|
210
|
+
// expect(secondRes).toBeGreaterThan(firstRes);
|
|
211
|
+
// });
|
|
212
|
+
|
|
213
|
+
// it("should still work with ng-event directives with latch change", async () => {
|
|
214
|
+
// el.innerHTML =
|
|
215
|
+
// '<button ng-post="/mock/now" data-latch="{{ latch }}" ng-mouseover="latch = !latch">Load</button>';
|
|
216
|
+
// const scope = $rootScope.$new();
|
|
217
|
+
// $compile(el)(scope);
|
|
218
|
+
// await wait(100);
|
|
219
|
+
// expect(el.innerText).toBe("Load");
|
|
220
|
+
// browserTrigger(el.querySelector("button"), "mouseover");
|
|
221
|
+
// await wait(100);
|
|
222
|
+
// expect(el.innerText).not.toBe("Load");
|
|
223
|
+
// const firstRes = parseInt(el.innerText);
|
|
224
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
225
|
+
|
|
226
|
+
// browserTrigger(el.querySelector("button"), "mouseover");
|
|
227
|
+
// await wait(100);
|
|
228
|
+
// const secondRes = parseInt(el.innerText);
|
|
229
|
+
// expect(secondRes).toBeGreaterThan(firstRes);
|
|
230
|
+
// });
|
|
231
|
+
// });
|
|
232
|
+
|
|
233
|
+
// describe("data-swap", () => {
|
|
234
|
+
// it("should not change anything if swap is 'none'", async () => {
|
|
235
|
+
// const scope = $rootScope.$new();
|
|
236
|
+
// el.innerHTML =
|
|
237
|
+
// '<button ng-post="/mock/div" data-swap="none" data-target="#found">Load</button><div id="found">Original</div>';
|
|
238
|
+
// $compile(el)(scope);
|
|
239
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
240
|
+
// await wait(100);
|
|
241
|
+
// const found = el.querySelector("#found");
|
|
242
|
+
// expect(found.textContent).toBe("Original");
|
|
243
|
+
// });
|
|
244
|
+
|
|
245
|
+
// it("should replace outerHTML on click", async () => {
|
|
246
|
+
// const scope = $rootScope.$new();
|
|
247
|
+
// el.innerHTML =
|
|
248
|
+
// '<button ng-post="/mock/hello" data-swap="outerHTML">Load</button>';
|
|
249
|
+
// $compile(el)(scope);
|
|
250
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
251
|
+
// await wait(100);
|
|
252
|
+
// expect(el.innerText).toBe("Hello");
|
|
253
|
+
// });
|
|
254
|
+
|
|
255
|
+
// it("should replace textcontent on click", async () => {
|
|
256
|
+
// const scope = $rootScope.$new();
|
|
257
|
+
// el.innerHTML =
|
|
258
|
+
// '<button ng-post="/mock/hello" data-swap="textContent">Load</button>';
|
|
259
|
+
// $compile(el)(scope);
|
|
260
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
261
|
+
// await wait(100);
|
|
262
|
+
// expect(el.innerText).toBe("Hello");
|
|
263
|
+
// });
|
|
264
|
+
|
|
265
|
+
// it("should replace beforebegin on click", async () => {
|
|
266
|
+
// const scope = $rootScope.$new();
|
|
267
|
+
// el.innerHTML =
|
|
268
|
+
// '<button ng-post="/mock/div" data-swap="beforebegin">Load</button>';
|
|
269
|
+
// $compile(el)(scope);
|
|
270
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
271
|
+
// await wait(100);
|
|
272
|
+
// expect(el.firstChild.innerText).toBe("Hello");
|
|
273
|
+
// });
|
|
274
|
+
|
|
275
|
+
// it("should replace beforeend on click", async () => {
|
|
276
|
+
// const scope = $rootScope.$new();
|
|
277
|
+
// el.innerHTML =
|
|
278
|
+
// '<button ng-post="/mock/div" data-swap="beforeend">Load</button>';
|
|
279
|
+
// $compile(el)(scope);
|
|
280
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
281
|
+
// await wait(100);
|
|
282
|
+
// expect(el.firstChild.lastChild.innerText).toBe("Hello");
|
|
283
|
+
// });
|
|
284
|
+
|
|
285
|
+
// it("should delete the target on click", async () => {
|
|
286
|
+
// const scope = $rootScope.$new();
|
|
287
|
+
// el.innerHTML =
|
|
288
|
+
// '<button ng-post="/mock/hello" data-swap="delete" data-target="#found">Load</button><div id="found"></div>';
|
|
289
|
+
// $compile(el)(scope);
|
|
290
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
291
|
+
// await wait(100);
|
|
292
|
+
// expect(el.querySelector("#found")).toBeNull();
|
|
293
|
+
// });
|
|
294
|
+
// });
|
|
295
|
+
|
|
296
|
+
// describe("data-target", () => {
|
|
297
|
+
// it("should remain unchanged if target is not found and log a warning", async () => {
|
|
298
|
+
// const scope = $rootScope.$new();
|
|
299
|
+
// spyOn($log, "warn");
|
|
300
|
+
// el.innerHTML =
|
|
301
|
+
// '<button ng-post="/mock/hello" data-target="#missing">Load</button>';
|
|
302
|
+
// $compile(el)(scope);
|
|
303
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
304
|
+
// await wait(100);
|
|
305
|
+
// expect(el.firstChild.innerText).toBe("Load");
|
|
306
|
+
// expect($log.warn).toHaveBeenCalled();
|
|
307
|
+
// });
|
|
308
|
+
|
|
309
|
+
// it("should replace target innerHTML (default) on click", async () => {
|
|
310
|
+
// const scope = $rootScope.$new();
|
|
311
|
+
// el.innerHTML =
|
|
312
|
+
// '<button ng-post="/mock/hello" data-target="#found">Load</button><div id="found"></div>';
|
|
313
|
+
// $compile(el)(scope);
|
|
314
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
315
|
+
// await wait(100);
|
|
316
|
+
// expect(el.lastChild.innerHTML).toBe("Hello");
|
|
317
|
+
// });
|
|
318
|
+
|
|
319
|
+
// it("should replace textcontent on click", async () => {
|
|
320
|
+
// const scope = $rootScope.$new();
|
|
321
|
+
// el.innerHTML =
|
|
322
|
+
// '<button ng-post="/mock/hello" data-swap="textContent" data-target="#found">Load</button><div id="found"></div>';
|
|
323
|
+
// $compile(el)(scope);
|
|
324
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
325
|
+
// await wait(100);
|
|
326
|
+
// expect(el.lastChild.innerText).toBe("Hello");
|
|
327
|
+
// });
|
|
328
|
+
|
|
329
|
+
// it("should replace beforebegin on click", async () => {
|
|
330
|
+
// const scope = $rootScope.$new();
|
|
331
|
+
// el.innerHTML =
|
|
332
|
+
// '<button ng-post="/mock/div" data-swap="beforebegin" data-target="#found">Load</button><div id="found"></div>';
|
|
333
|
+
// $compile(el)(scope);
|
|
334
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
335
|
+
// await wait(100);
|
|
336
|
+
// const found = el.querySelector("#found");
|
|
337
|
+
// // The sibling before #found should contain "Hello"
|
|
338
|
+
// const prevSibling = found.previousSibling;
|
|
339
|
+
// expect(prevSibling.textContent).toBe("Hello");
|
|
340
|
+
// expect(found.textContent).toBe(""); // found itself unchanged
|
|
341
|
+
// });
|
|
342
|
+
|
|
343
|
+
// it("should replace beforeend on click", async () => {
|
|
344
|
+
// const scope = $rootScope.$new();
|
|
345
|
+
// el.innerHTML =
|
|
346
|
+
// '<button ng-post="/mock/div" data-swap="beforeend" data-target="#found">Load</button><div id="found"></div>';
|
|
347
|
+
// $compile(el)(scope);
|
|
348
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
349
|
+
// await wait(100);
|
|
350
|
+
// const found = el.querySelector("#found");
|
|
351
|
+
// expect(found.textContent).toBe("Hello");
|
|
352
|
+
// });
|
|
353
|
+
|
|
354
|
+
// it("should insert afterbegin on click", async () => {
|
|
355
|
+
// const scope = $rootScope.$new();
|
|
356
|
+
// el.innerHTML =
|
|
357
|
+
// '<button ng-post="/mock/div" data-swap="afterbegin" data-target="#found">Load</button><div id="found"><div>World</div></div>';
|
|
358
|
+
// $compile(el)(scope);
|
|
359
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
360
|
+
// await wait(100);
|
|
361
|
+
// const found = el.querySelector("#found");
|
|
362
|
+
// expect(found.textContent).toBe("HelloWorld");
|
|
363
|
+
// });
|
|
364
|
+
|
|
365
|
+
// it("should insert afterend on click", async () => {
|
|
366
|
+
// const scope = $rootScope.$new();
|
|
367
|
+
// el.innerHTML =
|
|
368
|
+
// '<button ng-post="/mock/div" data-swap="afterend" data-target="#found">Load</button><div id="found"><div>World</div></div>';
|
|
369
|
+
// $compile(el)(scope);
|
|
370
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
371
|
+
// await wait(100);
|
|
372
|
+
// const found = el.querySelector("#found");
|
|
373
|
+
// const next = found.nextSibling;
|
|
374
|
+
// expect(el.lastChild.textContent).toBe("Hello");
|
|
375
|
+
// });
|
|
376
|
+
// });
|
|
377
|
+
|
|
378
|
+
// describe("data-delay", () => {
|
|
379
|
+
// it("should accept delay as a data attribute", async () => {
|
|
380
|
+
// const scope = $rootScope.$new();
|
|
381
|
+
// el.innerHTML =
|
|
382
|
+
// '<button ng-post="/mock/hello" data-delay="1000">Load</button>';
|
|
383
|
+
// $compile(el)(scope);
|
|
384
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
385
|
+
// await wait(100);
|
|
386
|
+
// expect(el.innerText).toBe("Load");
|
|
387
|
+
|
|
388
|
+
// await wait(1000);
|
|
389
|
+
// expect(el.innerText).toBe("Hello");
|
|
390
|
+
// });
|
|
391
|
+
// });
|
|
392
|
+
|
|
393
|
+
// describe("data-throttle", () => {
|
|
394
|
+
// it("should accept throttle as a data attribute", async () => {
|
|
395
|
+
// const scope = $rootScope.$new();
|
|
396
|
+
// el.innerHTML =
|
|
397
|
+
// '<button ng-post="/mock/now" data-throttle="1000">Load</button>';
|
|
398
|
+
// $compile(el)(scope);
|
|
399
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
400
|
+
// await wait(100);
|
|
401
|
+
// const firstRes = parseInt(el.innerText);
|
|
402
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
403
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
404
|
+
// await wait(100);
|
|
405
|
+
// const secondRes = parseInt(el.innerText);
|
|
406
|
+
// expect(secondRes).toBe(firstRes);
|
|
407
|
+
|
|
408
|
+
// await wait(900);
|
|
409
|
+
// // should release the throttle
|
|
410
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
411
|
+
// await wait(100);
|
|
412
|
+
// const thirdRes = parseInt(el.innerText);
|
|
413
|
+
// expect(thirdRes).toBeGreaterThan(firstRes);
|
|
414
|
+
// });
|
|
415
|
+
// });
|
|
416
|
+
|
|
417
|
+
// describe("data-interval", () => {
|
|
418
|
+
// it("should accept delay as a data attribute and should stop on $destroy", async () => {
|
|
419
|
+
// const scope = $rootScope.$new();
|
|
420
|
+
// el.innerHTML =
|
|
421
|
+
// '<button ng-post="/mock/now" data-interval="100">Load</button>';
|
|
422
|
+
// $compile(el)(scope);
|
|
423
|
+
|
|
424
|
+
// await wait(200);
|
|
425
|
+
// await wait(200);
|
|
426
|
+
// const firstRes = parseInt(el.innerText);
|
|
427
|
+
// expect(firstRes).toBeLessThan(Date.now());
|
|
428
|
+
// await wait(200);
|
|
429
|
+
// await wait(200);
|
|
430
|
+
// const secondRes = parseInt(el.innerText);
|
|
431
|
+
// expect(secondRes).toBeGreaterThan(firstRes);
|
|
432
|
+
// await wait(200);
|
|
433
|
+
// await wait(200);
|
|
434
|
+
// const thirdRes = parseInt(el.innerText);
|
|
435
|
+
// expect(thirdRes).toBeGreaterThan(secondRes);
|
|
436
|
+
|
|
437
|
+
// scope.$broadcast("$destroy");
|
|
438
|
+
|
|
439
|
+
// await wait(200);
|
|
440
|
+
// await wait(200);
|
|
441
|
+
// const finalRes = parseInt(el.innerText);
|
|
442
|
+
|
|
443
|
+
// await wait(1000);
|
|
444
|
+
// await wait(200);
|
|
445
|
+
// expect(parseInt(el.innerText)).toEqual(finalRes);
|
|
446
|
+
// });
|
|
447
|
+
// });
|
|
448
|
+
|
|
449
|
+
// describe("data-loading", () => {
|
|
450
|
+
// it("should update loading data attribute", async () => {
|
|
451
|
+
// const scope = $rootScope.$new();
|
|
452
|
+
// el.innerHTML = '<button ng-post="/mock/now" data-loading>Load</button>';
|
|
453
|
+
// $compile(el)(scope);
|
|
454
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
455
|
+
// expect(el.querySelector("button").dataset.loading).toEqual("true");
|
|
456
|
+
// await wait(200);
|
|
457
|
+
// expect(el.querySelector("button").dataset.loading).toEqual("false");
|
|
458
|
+
// });
|
|
459
|
+
// });
|
|
460
|
+
|
|
461
|
+
// describe("data-loading-class", () => {
|
|
462
|
+
// it("should update class from data-loading-class attribute", async () => {
|
|
463
|
+
// const scope = $rootScope.$new();
|
|
464
|
+
// el.innerHTML =
|
|
465
|
+
// '<button ng-post="/mock/now" data-loading-class="red">Load</button>';
|
|
466
|
+
// $compile(el)(scope);
|
|
467
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
468
|
+
// expect(el.querySelector("button").classList.contains("red")).toBeTrue();
|
|
469
|
+
// await wait(200);
|
|
470
|
+
// expect(el.querySelector("button").classList.contains("red")).toBeFalse();
|
|
471
|
+
// });
|
|
472
|
+
// });
|
|
473
|
+
|
|
474
|
+
// describe("data-success", () => {
|
|
475
|
+
// it("should evaluate expression passing result", async () => {
|
|
476
|
+
// const scope = $rootScope.$new();
|
|
477
|
+
// el.innerHTML =
|
|
478
|
+
// '<button ng-post="/mock/hello" data-success="res = $res">Load</button>';
|
|
479
|
+
// $compile(el)(scope);
|
|
480
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
481
|
+
// await wait(200);
|
|
482
|
+
// expect(scope.res).toEqual("Hello");
|
|
483
|
+
// });
|
|
484
|
+
// });
|
|
485
|
+
|
|
486
|
+
// describe("data-state-success", () => {
|
|
487
|
+
// it("should call stateService with success state", async () => {
|
|
488
|
+
// const scope = $rootScope.$new();
|
|
489
|
+
// el.innerHTML =
|
|
490
|
+
// '<button ng-post="/mock/hello" data-state-success="success">Load</button><ng-view id="view"></ng-view>';
|
|
491
|
+
// $compile(el)(scope);
|
|
492
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
493
|
+
// await wait(200);
|
|
494
|
+
// expect(document.getElementById("view").innerHTML).toEqual("success");
|
|
495
|
+
// });
|
|
496
|
+
// });
|
|
497
|
+
|
|
498
|
+
// describe("data-state-error", () => {
|
|
499
|
+
// it("should call stateService with success state", async () => {
|
|
500
|
+
// const scope = $rootScope.$new();
|
|
501
|
+
// el.innerHTML =
|
|
502
|
+
// '<button ng-post="/mock/422" data-state-success="success" data-state-error="error">Load</button><ng-view id="view"></ng-view>';
|
|
503
|
+
// $compile(el)(scope);
|
|
504
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
505
|
+
// await wait(200);
|
|
506
|
+
// expect(document.getElementById("view").innerHTML).toEqual("error");
|
|
507
|
+
// });
|
|
508
|
+
// });
|
|
509
|
+
|
|
510
|
+
// describe("data-error", () => {
|
|
511
|
+
// it("should evaluate expression passing result", async () => {
|
|
512
|
+
// const scope = $rootScope.$new();
|
|
513
|
+
// el.innerHTML =
|
|
514
|
+
// '<button ng-post="/mock/422" data-error="res = $res">Load</button>';
|
|
515
|
+
// $compile(el)(scope);
|
|
516
|
+
// browserTrigger(el.querySelector("button"), "click");
|
|
517
|
+
// await wait(200);
|
|
518
|
+
// expect(scope.res).toEqual("Invalid data");
|
|
519
|
+
// });
|
|
520
|
+
// });
|
|
24
521
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Angular } from "../../
|
|
1
|
+
import { Angular } from "../../angular.js";
|
|
2
|
+
import { dealoc } from "../../shared/dom.js";
|
|
2
3
|
// import { browserTrigger, wait } from "../../shared/test-utils.js";
|
|
3
4
|
|
|
4
5
|
describe("ngPut", () => {
|
|
@@ -6,6 +7,7 @@ describe("ngPut", () => {
|
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
el = document.getElementById("app");
|
|
10
|
+
dealoc(el);
|
|
9
11
|
el.innerHTML = "";
|
|
10
12
|
let angular = new Angular();
|
|
11
13
|
angular.module("default", []);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { isDefined } from "../../shared/utils.js";
|
|
2
2
|
import { hasAnimate } from "../../shared/utils.js";
|
|
3
|
-
import { $injectTokens } from "../../injection-tokens.js";
|
|
3
|
+
import { $injectTokens as $t } from "../../injection-tokens.js";
|
|
4
4
|
|
|
5
5
|
ngIncludeDirective.$inject = [
|
|
6
|
-
$
|
|
7
|
-
$
|
|
8
|
-
$
|
|
9
|
-
$
|
|
6
|
+
$t.$templateRequest,
|
|
7
|
+
$t.$anchorScroll,
|
|
8
|
+
$t.$animate,
|
|
9
|
+
$t.$exceptionHandler,
|
|
10
10
|
];
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -14,7 +14,7 @@ ngIncludeDirective.$inject = [
|
|
|
14
14
|
* @param {*} $templateRequest
|
|
15
15
|
* @param {import("../../services/anchor-scroll.js").AnchorScrollFunction} $anchorScroll
|
|
16
16
|
* @param {*} $animate
|
|
17
|
-
* @param {import('../../
|
|
17
|
+
* @param {import('../../services/exception/interface.ts').Interface} $exceptionHandler
|
|
18
18
|
* @returns {import('../../interface.js').Directive}
|
|
19
19
|
*/
|
|
20
20
|
export function ngIncludeDirective(
|
|
@@ -133,7 +133,7 @@ export function ngIncludeDirective(
|
|
|
133
133
|
// We need this directive so that the element content is already filled when
|
|
134
134
|
// the link function of another directive on the same element as ngInclude
|
|
135
135
|
// is called.
|
|
136
|
-
ngIncludeFillContentDirective.$inject = [
|
|
136
|
+
ngIncludeFillContentDirective.$inject = [$t.$compile];
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* @param {import("../../core/compile/compile.js").CompileFn} $compile
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElementFromHTML, dealoc, getScope } from "../../shared/dom.js";
|
|
2
|
-
import { Angular } from "../../
|
|
2
|
+
import { Angular } from "../../angular.js";
|
|
3
3
|
import { createInjector } from "../../core/di/injector.js";
|
|
4
4
|
import { wait } from "../../shared/test-utils.js";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElementFromHTML, dealoc } from "../../shared/dom.js";
|
|
2
|
-
import { Angular } from "../../
|
|
2
|
+
import { Angular } from "../../angular.js";
|
|
3
3
|
import { createInjector } from "../../core/di/injector.js";
|
|
4
4
|
import { wait } from "../../shared/test-utils.js";
|
|
5
5
|
|
|
@@ -5,6 +5,7 @@ const TEST_URL = "src/directive/init/init.html";
|
|
|
5
5
|
test("unit tests contain no errors", async ({ page }) => {
|
|
6
6
|
await page.goto(TEST_URL);
|
|
7
7
|
await page.content();
|
|
8
|
+
await page.waitForTimeout(1000);
|
|
8
9
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
10
|
/0 failures/,
|
|
10
11
|
);
|