@angular-wave/angular.ts 0.0.1
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/.eslintignore +1 -0
- package/.eslintrc.cjs +29 -0
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +17974 -0
- package/CODE_OF_CONDUCT.md +3 -0
- package/CONTRIBUTING.md +246 -0
- package/DEVELOPERS.md +488 -0
- package/LICENSE +22 -0
- package/Makefile +31 -0
- package/README.md +115 -0
- package/RELEASE.md +98 -0
- package/SECURITY.md +16 -0
- package/TRIAGING.md +135 -0
- package/css/angular.css +22 -0
- package/dist/angular-ts.cjs.js +36843 -0
- package/dist/angular-ts.esm.js +36841 -0
- package/dist/angular-ts.umd.js +36848 -0
- package/dist/build/angular-animate.js +4272 -0
- package/dist/build/angular-aria.js +426 -0
- package/dist/build/angular-message-format.js +1072 -0
- package/dist/build/angular-messages.js +829 -0
- package/dist/build/angular-mocks.js +3757 -0
- package/dist/build/angular-parse-ext.js +1275 -0
- package/dist/build/angular-resource.js +911 -0
- package/dist/build/angular-route.js +1266 -0
- package/dist/build/angular-sanitize.js +891 -0
- package/dist/build/angular-touch.js +368 -0
- package/dist/build/angular.js +36600 -0
- package/e2e/unit.spec.ts +15 -0
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +1 -0
- package/index.html +104 -0
- package/package.json +47 -0
- package/playwright.config.ts +78 -0
- package/public/circle.html +1 -0
- package/public/my_child_directive.html +1 -0
- package/public/my_directive.html +1 -0
- package/public/my_other_directive.html +1 -0
- package/public/test.html +1 -0
- package/rollup.config.js +31 -0
- package/src/animations/animateCache.js +55 -0
- package/src/animations/animateChildrenDirective.js +105 -0
- package/src/animations/animateCss.js +1139 -0
- package/src/animations/animateCssDriver.js +291 -0
- package/src/animations/animateJs.js +367 -0
- package/src/animations/animateJsDriver.js +67 -0
- package/src/animations/animateQueue.js +851 -0
- package/src/animations/animation.js +506 -0
- package/src/animations/module.js +779 -0
- package/src/animations/ngAnimateSwap.js +119 -0
- package/src/animations/rafScheduler.js +50 -0
- package/src/animations/shared.js +378 -0
- package/src/constants.js +20 -0
- package/src/core/animate.js +845 -0
- package/src/core/animateCss.js +73 -0
- package/src/core/animateRunner.js +195 -0
- package/src/core/attributes.js +199 -0
- package/src/core/cache.js +45 -0
- package/src/core/compile.js +4727 -0
- package/src/core/controller.js +225 -0
- package/src/core/exceptionHandler.js +63 -0
- package/src/core/filter.js +146 -0
- package/src/core/interpolate.js +442 -0
- package/src/core/interval.js +188 -0
- package/src/core/intervalFactory.js +57 -0
- package/src/core/location.js +1086 -0
- package/src/core/parser/parse.js +2562 -0
- package/src/core/parser/parse.md +13 -0
- package/src/core/q.js +746 -0
- package/src/core/rootScope.js +1596 -0
- package/src/core/sanitizeUri.js +85 -0
- package/src/core/sce.js +1161 -0
- package/src/core/taskTrackerFactory.js +125 -0
- package/src/core/timeout.js +121 -0
- package/src/core/urlUtils.js +187 -0
- package/src/core/utils.js +1349 -0
- package/src/directive/a.js +37 -0
- package/src/directive/attrs.js +283 -0
- package/src/directive/bind.js +51 -0
- package/src/directive/bind.md +142 -0
- package/src/directive/change.js +12 -0
- package/src/directive/change.md +25 -0
- package/src/directive/cloak.js +12 -0
- package/src/directive/cloak.md +24 -0
- package/src/directive/events.js +75 -0
- package/src/directive/events.md +166 -0
- package/src/directive/form.js +725 -0
- package/src/directive/init.js +15 -0
- package/src/directive/init.md +41 -0
- package/src/directive/input.js +1783 -0
- package/src/directive/list.js +46 -0
- package/src/directive/list.md +22 -0
- package/src/directive/ngClass.js +249 -0
- package/src/directive/ngController.js +64 -0
- package/src/directive/ngCsp.js +82 -0
- package/src/directive/ngIf.js +134 -0
- package/src/directive/ngInclude.js +217 -0
- package/src/directive/ngModel.js +1356 -0
- package/src/directive/ngModelOptions.js +509 -0
- package/src/directive/ngOptions.js +670 -0
- package/src/directive/ngRef.js +90 -0
- package/src/directive/ngRepeat.js +650 -0
- package/src/directive/ngShowHide.js +255 -0
- package/src/directive/ngSwitch.js +178 -0
- package/src/directive/ngTransclude.js +98 -0
- package/src/directive/non-bindable.js +11 -0
- package/src/directive/non-bindable.md +17 -0
- package/src/directive/script.js +30 -0
- package/src/directive/select.js +624 -0
- package/src/directive/style.js +25 -0
- package/src/directive/style.md +23 -0
- package/src/directive/validators.js +329 -0
- package/src/exts/aria.js +544 -0
- package/src/exts/messages.js +852 -0
- package/src/filters/filter.js +207 -0
- package/src/filters/filter.md +69 -0
- package/src/filters/filters.js +239 -0
- package/src/filters/json.md +16 -0
- package/src/filters/limit-to.js +43 -0
- package/src/filters/limit-to.md +19 -0
- package/src/filters/order-by.js +183 -0
- package/src/filters/order-by.md +83 -0
- package/src/index.js +13 -0
- package/src/injector.js +1034 -0
- package/src/jqLite.js +1117 -0
- package/src/loader.js +1320 -0
- package/src/public.js +215 -0
- package/src/routeToRegExp.js +41 -0
- package/src/services/anchorScroll.js +135 -0
- package/src/services/browser.js +321 -0
- package/src/services/cacheFactory.js +398 -0
- package/src/services/cookieReader.js +72 -0
- package/src/services/document.js +64 -0
- package/src/services/http.js +1537 -0
- package/src/services/httpBackend.js +206 -0
- package/src/services/log.js +160 -0
- package/src/services/templateRequest.js +139 -0
- package/test/angular.spec.js +2153 -0
- package/test/aria/aria.spec.js +1245 -0
- package/test/binding.spec.js +504 -0
- package/test/build-test.html +14 -0
- package/test/injector.spec.js +2327 -0
- package/test/jasmine/jasmine-5.1.2/boot0.js +65 -0
- package/test/jasmine/jasmine-5.1.2/boot1.js +133 -0
- package/test/jasmine/jasmine-5.1.2/jasmine-html.js +963 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.css +320 -0
- package/test/jasmine/jasmine-5.1.2/jasmine.js +10824 -0
- package/test/jasmine/jasmine-5.1.2/jasmine_favicon.png +0 -0
- package/test/jasmine/jasmine-browser.json +17 -0
- package/test/jasmine/jasmine.json +9 -0
- package/test/jqlite.spec.js +2133 -0
- package/test/loader.spec.js +219 -0
- package/test/messages/messages.spec.js +1146 -0
- package/test/min-err.spec.js +174 -0
- package/test/mock-test.html +13 -0
- package/test/module-test.html +15 -0
- package/test/ng/anomate.spec.js +606 -0
- package/test/ng/cache-factor.spec.js +334 -0
- package/test/ng/compile.spec.js +17956 -0
- package/test/ng/controller-provider.spec.js +227 -0
- package/test/ng/cookie-reader.spec.js +98 -0
- package/test/ng/directive/a.spec.js +192 -0
- package/test/ng/directive/bind.spec.js +334 -0
- package/test/ng/directive/boolean.spec.js +136 -0
- package/test/ng/directive/change.spec.js +71 -0
- package/test/ng/directive/class.spec.js +858 -0
- package/test/ng/directive/click.spec.js +38 -0
- package/test/ng/directive/cloak.spec.js +44 -0
- package/test/ng/directive/constoller.spec.js +194 -0
- package/test/ng/directive/element-style.spec.js +92 -0
- package/test/ng/directive/event.spec.js +282 -0
- package/test/ng/directive/form.spec.js +1518 -0
- package/test/ng/directive/href.spec.js +143 -0
- package/test/ng/directive/if.spec.js +402 -0
- package/test/ng/directive/include.spec.js +828 -0
- package/test/ng/directive/init.spec.js +68 -0
- package/test/ng/directive/input.spec.js +3810 -0
- package/test/ng/directive/list.spec.js +170 -0
- package/test/ng/directive/model-options.spec.js +1008 -0
- package/test/ng/directive/model.spec.js +1905 -0
- package/test/ng/directive/non-bindable.spec.js +55 -0
- package/test/ng/directive/options.spec.js +3583 -0
- package/test/ng/directive/ref.spec.js +575 -0
- package/test/ng/directive/repeat.spec.js +1675 -0
- package/test/ng/directive/script.spec.js +52 -0
- package/test/ng/directive/scrset.spec.js +67 -0
- package/test/ng/directive/select.spec.js +2541 -0
- package/test/ng/directive/show-hide.spec.js +253 -0
- package/test/ng/directive/src.spec.js +157 -0
- package/test/ng/directive/style.spec.js +178 -0
- package/test/ng/directive/switch.spec.js +647 -0
- package/test/ng/directive/validators.spec.js +717 -0
- package/test/ng/document.spec.js +52 -0
- package/test/ng/filter/filter.spec.js +714 -0
- package/test/ng/filter/filters.spec.js +35 -0
- package/test/ng/filter/limit-to.spec.js +251 -0
- package/test/ng/filter/order-by.spec.js +891 -0
- package/test/ng/filter.spec.js +149 -0
- package/test/ng/http-backend.spec.js +398 -0
- package/test/ng/http.spec.js +4071 -0
- package/test/ng/interpolate.spec.js +642 -0
- package/test/ng/interval.spec.js +343 -0
- package/test/ng/location.spec.js +3488 -0
- package/test/ng/on.spec.js +229 -0
- package/test/ng/parse.spec.js +4655 -0
- package/test/ng/prop.spec.js +805 -0
- package/test/ng/q.spec.js +2904 -0
- package/test/ng/root-element.spec.js +16 -0
- package/test/ng/sanitize-uri.spec.js +249 -0
- package/test/ng/sce.spec.js +660 -0
- package/test/ng/scope.spec.js +3442 -0
- package/test/ng/template-request.spec.js +236 -0
- package/test/ng/timeout.spec.js +351 -0
- package/test/ng/url-utils.spec.js +156 -0
- package/test/ng/utils.spec.js +144 -0
- package/test/original-test.html +21 -0
- package/test/public.spec.js +34 -0
- package/test/sanitize/bing-html.spec.js +36 -0
- package/test/server/express.js +158 -0
- package/test/test-utils.js +11 -0
- package/tsconfig.json +17 -0
- package/types/angular.d.ts +138 -0
- package/types/global.d.ts +9 -0
- package/types/index.d.ts +2357 -0
- package/types/jqlite.d.ts +558 -0
- package/vite.config.js +14 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
import { dealoc, jqLite } from "../../../src/jqLite";
|
|
2
|
+
import { Angular } from "../../../src/loader";
|
|
3
|
+
import { createInjector } from "../../../src/injector";
|
|
4
|
+
import { publishExternalAPI } from "../../../src/public";
|
|
5
|
+
import { valueFn } from "../../../src/core/utils";
|
|
6
|
+
|
|
7
|
+
describe("ngInclude", () => {
|
|
8
|
+
describe("basic", () => {
|
|
9
|
+
let element;
|
|
10
|
+
let $rootScope;
|
|
11
|
+
let $templateCache;
|
|
12
|
+
let $compile;
|
|
13
|
+
let module;
|
|
14
|
+
let injector;
|
|
15
|
+
let angular;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
delete window.angular;
|
|
19
|
+
angular = new Angular();
|
|
20
|
+
publishExternalAPI().decorator("$exceptionHandler", function () {
|
|
21
|
+
return (exception, cause) => {
|
|
22
|
+
throw new Error(exception.message);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
// module = window.angular.module("myModule", []);
|
|
26
|
+
injector = createInjector(["ng"]);
|
|
27
|
+
$rootScope = injector.get("$rootScope");
|
|
28
|
+
$templateCache = injector.get("$templateCache");
|
|
29
|
+
$compile = injector.get("$compile");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
dealoc(element);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should trust and use literal urls", (done) => {
|
|
37
|
+
const element = jqLite(
|
|
38
|
+
"<div><div ng-include=\"'/test.html'\"></div></div>",
|
|
39
|
+
);
|
|
40
|
+
const injector = angular.bootstrap(element);
|
|
41
|
+
$rootScope = injector.get("$rootScope");
|
|
42
|
+
$rootScope.$digest();
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
expect(element.text()).toEqual("hello");
|
|
45
|
+
dealoc($rootScope);
|
|
46
|
+
done();
|
|
47
|
+
}, 200);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should trust and use trusted urls", (done) => {
|
|
51
|
+
const element = jqLite('<div><div ng-include="fooUrl">test</div></div>');
|
|
52
|
+
const injector = angular.bootstrap(element);
|
|
53
|
+
let $sce = injector.get("$sce");
|
|
54
|
+
$rootScope = injector.get("$rootScope");
|
|
55
|
+
$rootScope.fooUrl = $sce.trustAsResourceUrl(
|
|
56
|
+
"http://localhost:4000/mock/hello",
|
|
57
|
+
);
|
|
58
|
+
$rootScope.$digest();
|
|
59
|
+
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
expect(element.text()).toEqual("Hello");
|
|
62
|
+
dealoc($rootScope);
|
|
63
|
+
done();
|
|
64
|
+
}, 200);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("should include an external file", (done) => {
|
|
68
|
+
element = jqLite('<div><ng:include src="url"></ng:include></div>');
|
|
69
|
+
const body = jqLite(document.getElementById("dummy"));
|
|
70
|
+
body.append(element);
|
|
71
|
+
const injector = angular.bootstrap(element);
|
|
72
|
+
$rootScope = injector.get("$rootScope");
|
|
73
|
+
$templateCache = injector.get("$templateCache");
|
|
74
|
+
$templateCache.put("myUrl", [200, "{{name}}", {}]);
|
|
75
|
+
$rootScope.name = "misko";
|
|
76
|
+
$rootScope.url = "myUrl";
|
|
77
|
+
$rootScope.$digest();
|
|
78
|
+
setTimeout(() => {
|
|
79
|
+
expect(body.text()).toEqual("misko");
|
|
80
|
+
body.empty();
|
|
81
|
+
dealoc($rootScope);
|
|
82
|
+
done();
|
|
83
|
+
}, 200);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should support ng-include="src" syntax', (done) => {
|
|
87
|
+
element = jqLite('<div><div ng-include="url"></div></div>');
|
|
88
|
+
const injector = angular.bootstrap(element);
|
|
89
|
+
$rootScope = injector.get("$rootScope");
|
|
90
|
+
$rootScope.expr = "Alibaba";
|
|
91
|
+
$rootScope.url = "/mock/interpolation";
|
|
92
|
+
$rootScope.$digest();
|
|
93
|
+
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
expect(element.text()).toEqual("Alibaba");
|
|
96
|
+
done();
|
|
97
|
+
}, 200);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("should NOT use untrusted URL expressions ", () => {
|
|
101
|
+
element = jqLite('<ng:include src="url"></ng:include>');
|
|
102
|
+
const injector = angular.bootstrap(element);
|
|
103
|
+
$rootScope = injector.get("$rootScope");
|
|
104
|
+
$rootScope.url = "http://example.com/myUrl";
|
|
105
|
+
expect(() => {
|
|
106
|
+
$rootScope.$digest();
|
|
107
|
+
}).toThrowError(/insecurl/);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should NOT use mistyped expressions ", () => {
|
|
111
|
+
element = jqLite('<ng:include src="url"></ng:include>');
|
|
112
|
+
const injector = angular.bootstrap(element);
|
|
113
|
+
$rootScope = injector.get("$rootScope");
|
|
114
|
+
$rootScope.name = "chirayu";
|
|
115
|
+
let $sce = injector.get("$sce");
|
|
116
|
+
$rootScope.url = $sce.trustAsUrl("http://example.com/myUrl");
|
|
117
|
+
expect(() => {
|
|
118
|
+
$rootScope.$digest();
|
|
119
|
+
}).toThrowError(/insecurl/);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should remove previously included text if a falsy value is bound to src", (done) => {
|
|
123
|
+
element = jqLite('<div><ng:include src="url"></ng:include></div>');
|
|
124
|
+
const injector = angular.bootstrap(element);
|
|
125
|
+
$rootScope = injector.get("$rootScope");
|
|
126
|
+
$rootScope.expr = "igor";
|
|
127
|
+
$rootScope.url = "/mock/interpolation";
|
|
128
|
+
$rootScope.$digest();
|
|
129
|
+
setTimeout(() => {
|
|
130
|
+
expect(element.text()).toEqual("igor");
|
|
131
|
+
$rootScope.url = undefined;
|
|
132
|
+
$rootScope.$digest();
|
|
133
|
+
}, 100);
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
expect(element.text()).toEqual("");
|
|
136
|
+
done();
|
|
137
|
+
}, 300);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("should fire $includeContentRequested event on scope after making the xhr call", (done) => {
|
|
141
|
+
let called = false;
|
|
142
|
+
|
|
143
|
+
window.angular.module("myModule", []).run(($rootScope) => {
|
|
144
|
+
$rootScope.$on("$includeContentRequested", (event) => {
|
|
145
|
+
expect(event.targetScope).toBe($rootScope);
|
|
146
|
+
called = true;
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
element = jqLite(
|
|
150
|
+
'<div><div><ng:include src="url"></ng:include></div></div>',
|
|
151
|
+
);
|
|
152
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
153
|
+
$rootScope = injector.get("$rootScope");
|
|
154
|
+
$rootScope.url = "/mock/interpolation";
|
|
155
|
+
$rootScope.$digest();
|
|
156
|
+
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
expect(called).toBe(true);
|
|
159
|
+
done();
|
|
160
|
+
}, 100);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("should fire $includeContentLoaded event on child scope after linking the content", (done) => {
|
|
164
|
+
let called = false;
|
|
165
|
+
|
|
166
|
+
window.angular.module("myModule", []).run(($rootScope) => {
|
|
167
|
+
$rootScope.$on("$includeContentLoaded", (event) => {
|
|
168
|
+
expect(event.targetScope.$parent).toBe($rootScope);
|
|
169
|
+
called = true;
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
element = jqLite(
|
|
173
|
+
'<div><div><ng:include src="url"></ng:include></div></div>',
|
|
174
|
+
);
|
|
175
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
176
|
+
$rootScope = injector.get("$rootScope");
|
|
177
|
+
$rootScope.url = "/mock/interpolation";
|
|
178
|
+
$rootScope.$digest();
|
|
179
|
+
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
expect(called).toBe(true);
|
|
182
|
+
done();
|
|
183
|
+
}, 100);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("should fire $includeContentError event when content request fails", (done) => {
|
|
187
|
+
const contentLoadedSpy = jasmine.createSpy("content loaded");
|
|
188
|
+
const contentErrorSpy = jasmine.createSpy("content error");
|
|
189
|
+
|
|
190
|
+
window.angular.module("myModule", []).run(($rootScope) => {
|
|
191
|
+
$rootScope.url = "/mock/401";
|
|
192
|
+
$rootScope.$on("$includeContentLoaded", contentLoadedSpy);
|
|
193
|
+
$rootScope.$on("$includeContentError", contentErrorSpy);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
element = jqLite(
|
|
197
|
+
'<div><div><ng:include src="url"></ng:include></div></div>',
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
201
|
+
$rootScope = injector.get("$rootScope");
|
|
202
|
+
$rootScope.$digest();
|
|
203
|
+
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
expect(contentLoadedSpy).not.toHaveBeenCalled();
|
|
206
|
+
expect(contentErrorSpy).toHaveBeenCalled();
|
|
207
|
+
done();
|
|
208
|
+
}, 100);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("should evaluate onload expression when a partial is loaded", (done) => {
|
|
212
|
+
window.angular.module("myModule", []);
|
|
213
|
+
|
|
214
|
+
element = jqLite(
|
|
215
|
+
'<div><div><ng:include src="url" onload="loaded = true"></ng:include></div></div>',
|
|
216
|
+
);
|
|
217
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
218
|
+
$rootScope = injector.get("$rootScope");
|
|
219
|
+
$rootScope.$digest();
|
|
220
|
+
|
|
221
|
+
expect($rootScope.loaded).not.toBeDefined();
|
|
222
|
+
$rootScope.url = "/mock/hello";
|
|
223
|
+
$rootScope.$digest();
|
|
224
|
+
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
expect(element.text()).toEqual("Hello");
|
|
227
|
+
expect($rootScope.loaded).toBe(true);
|
|
228
|
+
done();
|
|
229
|
+
}, 100);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("should create child scope and destroy old one", (done) => {
|
|
233
|
+
window.angular.module("myModule", []);
|
|
234
|
+
|
|
235
|
+
element = jqLite('<div><ng:include src="url"></ng:include></div>');
|
|
236
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
237
|
+
$rootScope = injector.get("$rootScope");
|
|
238
|
+
$rootScope.$digest();
|
|
239
|
+
expect(element.children().scope()).toBeFalsy();
|
|
240
|
+
|
|
241
|
+
$rootScope.url = "/mock/hello";
|
|
242
|
+
$rootScope.$digest();
|
|
243
|
+
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
expect(element.children().scope().$parent).toBe($rootScope);
|
|
246
|
+
expect(element.text()).toBe("Hello");
|
|
247
|
+
|
|
248
|
+
$rootScope.url = "/mock/401";
|
|
249
|
+
$rootScope.$digest();
|
|
250
|
+
}, 100);
|
|
251
|
+
|
|
252
|
+
setTimeout(() => {
|
|
253
|
+
expect($rootScope.$$childHead).toBeFalsy();
|
|
254
|
+
expect(element.text()).toBe("");
|
|
255
|
+
|
|
256
|
+
$rootScope.url = "/mock/hello";
|
|
257
|
+
$rootScope.$digest();
|
|
258
|
+
}, 200);
|
|
259
|
+
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
expect(element.children().scope().$parent).toBe($rootScope);
|
|
262
|
+
|
|
263
|
+
$rootScope.url = null;
|
|
264
|
+
$rootScope.$digest();
|
|
265
|
+
}, 300);
|
|
266
|
+
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
expect($rootScope.$$childHead).toBeFalsy();
|
|
269
|
+
done();
|
|
270
|
+
}, 400);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("should do xhr request and cache it", (done) => {
|
|
274
|
+
window.angular.module("myModule", []);
|
|
275
|
+
element = jqLite('<div><ng:include src="url"></ng:include></div>');
|
|
276
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
277
|
+
$rootScope = injector.get("$rootScope");
|
|
278
|
+
$rootScope.url = "/mock/hello";
|
|
279
|
+
$rootScope.$digest();
|
|
280
|
+
|
|
281
|
+
setTimeout(() => {
|
|
282
|
+
expect(element.text()).toEqual("Hello");
|
|
283
|
+
$rootScope.url = null;
|
|
284
|
+
$rootScope.$digest();
|
|
285
|
+
}, 100);
|
|
286
|
+
|
|
287
|
+
setTimeout(() => {
|
|
288
|
+
expect(element.text()).toEqual("");
|
|
289
|
+
$rootScope.url = "/mock/hello";
|
|
290
|
+
$rootScope.$digest();
|
|
291
|
+
// No request being made
|
|
292
|
+
expect(element.text()).toEqual("Hello");
|
|
293
|
+
done();
|
|
294
|
+
}, 200);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("should clear content when error during xhr request", () => {
|
|
298
|
+
window.angular.module("myModule", []);
|
|
299
|
+
element = jqLite('<div><ng:include src="url">content</ng:include></div>');
|
|
300
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
301
|
+
$rootScope = injector.get("$rootScope");
|
|
302
|
+
$rootScope.url = "/mock/401";
|
|
303
|
+
$rootScope.$digest();
|
|
304
|
+
expect(element.text()).toBe("");
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("should be async even if served from cache", (done) => {
|
|
308
|
+
window.angular.module("myModule", []);
|
|
309
|
+
element = jqLite('<div><ng:include src="url"></ng:include></div>');
|
|
310
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
311
|
+
$rootScope = injector.get("$rootScope");
|
|
312
|
+
$rootScope.url = "/mock/hello";
|
|
313
|
+
|
|
314
|
+
let called = 0;
|
|
315
|
+
// we want to assert only during first watch
|
|
316
|
+
$rootScope.$watch(() => {
|
|
317
|
+
if (!called) expect(element.text()).toBe("");
|
|
318
|
+
called++;
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
$rootScope.$digest();
|
|
322
|
+
setTimeout(() => {
|
|
323
|
+
expect(element.text()).toBe("Hello");
|
|
324
|
+
done();
|
|
325
|
+
}, 200);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it("should discard pending xhr callbacks if a new template is requested before the current finished loading", (done) => {
|
|
329
|
+
window.angular.module("myModule", []);
|
|
330
|
+
element = jqLite(
|
|
331
|
+
"<div><ng:include src='templateUrl'></ng:include></div>",
|
|
332
|
+
);
|
|
333
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
334
|
+
$rootScope = injector.get("$rootScope");
|
|
335
|
+
$rootScope.templateUrl = "/mock/hello";
|
|
336
|
+
$rootScope.$digest();
|
|
337
|
+
$rootScope.expr = "test";
|
|
338
|
+
$rootScope.templateUrl = "/mock/interpolation";
|
|
339
|
+
$rootScope.$digest();
|
|
340
|
+
expect(element.text()).toBe("");
|
|
341
|
+
|
|
342
|
+
setTimeout(() => {
|
|
343
|
+
expect(element.text()).toBe("test");
|
|
344
|
+
done();
|
|
345
|
+
}, 200);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("should not break attribute bindings on the same element", (done) => {
|
|
349
|
+
window.angular.module("myModule", []);
|
|
350
|
+
element = jqLite(
|
|
351
|
+
'<div><span foo="#/{{hrefUrl}}" ng:include="includeUrl"></span></div>',
|
|
352
|
+
);
|
|
353
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
354
|
+
$rootScope = injector.get("$rootScope");
|
|
355
|
+
$rootScope.hrefUrl = "fooUrl1";
|
|
356
|
+
$rootScope.includeUrl = "/mock/hello";
|
|
357
|
+
$rootScope.$digest();
|
|
358
|
+
|
|
359
|
+
setTimeout(() => {
|
|
360
|
+
expect(element.text()).toBe("Hello");
|
|
361
|
+
expect(element.find("span").attr("foo")).toBe("#/fooUrl1");
|
|
362
|
+
|
|
363
|
+
$rootScope.hrefUrl = "fooUrl2";
|
|
364
|
+
$rootScope.$digest();
|
|
365
|
+
|
|
366
|
+
expect(element.text()).toBe("Hello");
|
|
367
|
+
expect(element.find("span").attr("foo")).toBe("#/fooUrl2");
|
|
368
|
+
|
|
369
|
+
$rootScope.includeUrl = "/mock/hello2";
|
|
370
|
+
$rootScope.$digest();
|
|
371
|
+
}, 100);
|
|
372
|
+
|
|
373
|
+
setTimeout(() => {
|
|
374
|
+
expect(element.text()).toBe("Hello2");
|
|
375
|
+
expect(element.find("span").attr("foo")).toBe("#/fooUrl2");
|
|
376
|
+
done();
|
|
377
|
+
}, 200);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it("should construct SVG template elements with correct namespace", (done) => {
|
|
381
|
+
window.angular.module("myModule", []).directive(
|
|
382
|
+
"test",
|
|
383
|
+
valueFn({
|
|
384
|
+
templateNamespace: "svg",
|
|
385
|
+
templateUrl: "/mock/my-rect.html",
|
|
386
|
+
replace: true,
|
|
387
|
+
}),
|
|
388
|
+
);
|
|
389
|
+
element = jqLite("<svg><test></test></svg>");
|
|
390
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
391
|
+
$rootScope = injector.get("$rootScope");
|
|
392
|
+
$rootScope.$digest();
|
|
393
|
+
setTimeout(() => {
|
|
394
|
+
const child = element.find("rect");
|
|
395
|
+
expect(child.length).toBe(2);
|
|
396
|
+
// // eslint-disable-next-line no-undef
|
|
397
|
+
expect(child[0] instanceof SVGRectElement).toBe(true);
|
|
398
|
+
done();
|
|
399
|
+
}, 200);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it("should compile only the template content of an SVG template", (done) => {
|
|
403
|
+
window.angular.module("myModule", []).directive(
|
|
404
|
+
"test",
|
|
405
|
+
valueFn({
|
|
406
|
+
templateNamespace: "svg",
|
|
407
|
+
templateUrl: "/mock/my-rect2.html",
|
|
408
|
+
replace: true,
|
|
409
|
+
}),
|
|
410
|
+
);
|
|
411
|
+
element = jqLite("<svg><test></test></svg>");
|
|
412
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
413
|
+
$rootScope = injector.get("$rootScope");
|
|
414
|
+
$rootScope.$digest();
|
|
415
|
+
setTimeout(() => {
|
|
416
|
+
expect(element.find("a").length).toBe(0);
|
|
417
|
+
done();
|
|
418
|
+
}, 200);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
it("should not compile template if original scope is destroyed", (done) => {
|
|
422
|
+
window.angular.module("myModule", []);
|
|
423
|
+
element = jqLite(
|
|
424
|
+
'<div ng-if="show"><div ng-include="\'/mock/hello\'"></div></div>',
|
|
425
|
+
);
|
|
426
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
427
|
+
$rootScope = injector.get("$rootScope");
|
|
428
|
+
$rootScope.show = true;
|
|
429
|
+
$rootScope.$digest();
|
|
430
|
+
$rootScope.show = false;
|
|
431
|
+
$rootScope.$digest();
|
|
432
|
+
|
|
433
|
+
setTimeout(() => {
|
|
434
|
+
expect(element.text()).toBe("");
|
|
435
|
+
done();
|
|
436
|
+
}, 200);
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it("should not trigger a digest when the include is changed", (done) => {
|
|
440
|
+
window.angular.module("myModule", []);
|
|
441
|
+
element = jqLite('<div><ng-include src="url"></ng-include></div>');
|
|
442
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
443
|
+
$rootScope = injector.get("$rootScope");
|
|
444
|
+
const spy = spyOn($rootScope, "$digest").and.callThrough();
|
|
445
|
+
|
|
446
|
+
$rootScope.url = "/mock/hello";
|
|
447
|
+
$rootScope.$digest();
|
|
448
|
+
|
|
449
|
+
setTimeout(() => {
|
|
450
|
+
expect(element.text()).toEqual("Hello");
|
|
451
|
+
$rootScope.$apply('url = "/mock/hello2"');
|
|
452
|
+
}, 200);
|
|
453
|
+
|
|
454
|
+
setTimeout(() => {
|
|
455
|
+
spy.calls.reset();
|
|
456
|
+
}, 300);
|
|
457
|
+
|
|
458
|
+
setTimeout(() => {
|
|
459
|
+
expect(element.text()).toEqual("Hello2");
|
|
460
|
+
expect(spy).not.toHaveBeenCalled();
|
|
461
|
+
done();
|
|
462
|
+
}, 400);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
describe("autoscroll", () => {
|
|
466
|
+
let autoScrollSpy;
|
|
467
|
+
let $animate;
|
|
468
|
+
|
|
469
|
+
it("should call $anchorScroll if autoscroll attribute is present", (done) => {
|
|
470
|
+
window.angular.module("myModule", [
|
|
471
|
+
function ($provide) {
|
|
472
|
+
autoScrollSpy = jasmine.createSpy("$anchorScroll");
|
|
473
|
+
$provide.value("$anchorScroll", autoScrollSpy);
|
|
474
|
+
},
|
|
475
|
+
]);
|
|
476
|
+
element = jqLite(
|
|
477
|
+
'<div><ng:include src="tpl" autoscroll></ng:include></div>',
|
|
478
|
+
);
|
|
479
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
480
|
+
$rootScope = injector.get("$rootScope");
|
|
481
|
+
$animate = injector.get("$animate");
|
|
482
|
+
$rootScope.$apply(() => {
|
|
483
|
+
$rootScope.tpl = "/mock/hello";
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
setTimeout(() => {
|
|
487
|
+
expect(autoScrollSpy).toHaveBeenCalled();
|
|
488
|
+
done();
|
|
489
|
+
}, 400);
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
it("should call $anchorScroll if autoscroll evaluates to true", (done) => {
|
|
493
|
+
window.angular.module("myModule", [
|
|
494
|
+
function ($provide) {
|
|
495
|
+
autoScrollSpy = jasmine.createSpy("$anchorScroll");
|
|
496
|
+
$provide.value("$anchorScroll", autoScrollSpy);
|
|
497
|
+
},
|
|
498
|
+
]);
|
|
499
|
+
element = jqLite(
|
|
500
|
+
'<div><ng:include src="tpl" autoscroll="value"></ng:include></div>',
|
|
501
|
+
);
|
|
502
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
503
|
+
$rootScope = injector.get("$rootScope");
|
|
504
|
+
|
|
505
|
+
$rootScope.$apply(() => {
|
|
506
|
+
$rootScope.tpl = "/mock/hello";
|
|
507
|
+
$rootScope.value = true;
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
$rootScope.$digest();
|
|
511
|
+
|
|
512
|
+
setTimeout(() => {
|
|
513
|
+
expect(autoScrollSpy).toHaveBeenCalled();
|
|
514
|
+
done();
|
|
515
|
+
}, 100);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it("should not call $anchorScroll if autoscroll attribute is not present", (done) => {
|
|
519
|
+
window.angular.module("myModule", [
|
|
520
|
+
function ($provide) {
|
|
521
|
+
autoScrollSpy = jasmine.createSpy("$anchorScroll");
|
|
522
|
+
$provide.value("$anchorScroll", autoScrollSpy);
|
|
523
|
+
},
|
|
524
|
+
]);
|
|
525
|
+
|
|
526
|
+
element = jqLite('<div><ng:include src="tpl"></ng:include></div>');
|
|
527
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
528
|
+
$rootScope = injector.get("$rootScope");
|
|
529
|
+
|
|
530
|
+
$rootScope.$apply(() => {
|
|
531
|
+
$rootScope.tpl = "/mock/hello";
|
|
532
|
+
});
|
|
533
|
+
$rootScope.$digest();
|
|
534
|
+
|
|
535
|
+
setTimeout(() => {
|
|
536
|
+
expect(autoScrollSpy).not.toHaveBeenCalled();
|
|
537
|
+
done();
|
|
538
|
+
}, 100);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
it("should not call $anchorScroll if autoscroll evaluates to false", (done) => {
|
|
542
|
+
window.angular.module("myModule", [
|
|
543
|
+
function ($provide) {
|
|
544
|
+
autoScrollSpy = jasmine.createSpy("$anchorScroll");
|
|
545
|
+
$provide.value("$anchorScroll", autoScrollSpy);
|
|
546
|
+
},
|
|
547
|
+
]);
|
|
548
|
+
|
|
549
|
+
element = jqLite(
|
|
550
|
+
'<div><ng:include src="tpl" autoscroll="value"></ng:include></div>',
|
|
551
|
+
);
|
|
552
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
553
|
+
$rootScope = injector.get("$rootScope");
|
|
554
|
+
|
|
555
|
+
$rootScope.$apply(() => {
|
|
556
|
+
$rootScope.tpl = "/mock/hello";
|
|
557
|
+
$rootScope.value = false;
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
$rootScope.$apply(() => {
|
|
561
|
+
$rootScope.tpl = "/mock/hello";
|
|
562
|
+
$rootScope.value = undefined;
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
$rootScope.$apply(() => {
|
|
566
|
+
$rootScope.tpl = "/mock/hello";
|
|
567
|
+
$rootScope.value = null;
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
setTimeout(() => {
|
|
571
|
+
expect(autoScrollSpy).not.toHaveBeenCalled();
|
|
572
|
+
done();
|
|
573
|
+
}, 100);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
// it('should only call $anchorScroll after the "enter" animation completes', inject(
|
|
577
|
+
// compileAndLink(
|
|
578
|
+
// '<div><ng:include src="tpl" autoscroll></ng:include></div>',
|
|
579
|
+
// ),
|
|
580
|
+
// ($rootScope, $animate, $timeout) => {
|
|
581
|
+
// expect(autoScrollSpy).not.toHaveBeenCalled();
|
|
582
|
+
|
|
583
|
+
// $rootScope.$apply("tpl = 'template.html'");
|
|
584
|
+
// expect($animate.queue.shift().event).toBe("enter");
|
|
585
|
+
|
|
586
|
+
// $animate.flush();
|
|
587
|
+
// $rootScope.$digest();
|
|
588
|
+
|
|
589
|
+
// expect(autoScrollSpy).toHaveBeenCalled();
|
|
590
|
+
// },
|
|
591
|
+
// ));
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
describe("and transcludes", () => {
|
|
595
|
+
let element;
|
|
596
|
+
|
|
597
|
+
afterEach(() => {
|
|
598
|
+
if (element) {
|
|
599
|
+
dealoc(element);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
it("should allow access to directive controller from children when used in a replace template", (done) => {
|
|
604
|
+
let controller;
|
|
605
|
+
window.angular
|
|
606
|
+
.module("myModule", [])
|
|
607
|
+
.directive(
|
|
608
|
+
"template",
|
|
609
|
+
valueFn({
|
|
610
|
+
template: "<div ng-include=\"'/mock/directive'\"></div>",
|
|
611
|
+
replace: true,
|
|
612
|
+
controller() {
|
|
613
|
+
this.flag = true;
|
|
614
|
+
},
|
|
615
|
+
}),
|
|
616
|
+
)
|
|
617
|
+
.directive(
|
|
618
|
+
"test",
|
|
619
|
+
valueFn({
|
|
620
|
+
require: "^template",
|
|
621
|
+
link(scope, el, attr, ctrl) {
|
|
622
|
+
controller = ctrl;
|
|
623
|
+
},
|
|
624
|
+
}),
|
|
625
|
+
);
|
|
626
|
+
element = jqLite("<div><div template></div></div>");
|
|
627
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
628
|
+
$rootScope = injector.get("$rootScope");
|
|
629
|
+
|
|
630
|
+
$rootScope.$apply();
|
|
631
|
+
setTimeout(() => {
|
|
632
|
+
expect(controller.flag).toBe(true);
|
|
633
|
+
done();
|
|
634
|
+
}, 100);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
it("should compile its content correctly (although we remove it later)", (done) => {
|
|
638
|
+
let testElement;
|
|
639
|
+
window.angular.module("myModule", []).directive("test", () => ({
|
|
640
|
+
link(scope, element) {
|
|
641
|
+
testElement = element;
|
|
642
|
+
},
|
|
643
|
+
}));
|
|
644
|
+
|
|
645
|
+
element = jqLite(
|
|
646
|
+
"<div><div ng-include=\"'/mock/empty'\"><div test></div></div></div>",
|
|
647
|
+
);
|
|
648
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
649
|
+
$rootScope = injector.get("$rootScope");
|
|
650
|
+
$rootScope.$apply();
|
|
651
|
+
setTimeout(() => {
|
|
652
|
+
expect(testElement[0].nodeName).toBe("DIV");
|
|
653
|
+
done();
|
|
654
|
+
}, 100);
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
it("should link directives on the same element after the content has been loaded", (done) => {
|
|
658
|
+
let contentOnLink;
|
|
659
|
+
window.angular.module("myModule", []).directive("test", () => ({
|
|
660
|
+
link(scope, element) {
|
|
661
|
+
contentOnLink = element.text();
|
|
662
|
+
},
|
|
663
|
+
}));
|
|
664
|
+
element = jqLite("<div><div ng-include=\"'/mock/hello'\" test></div>");
|
|
665
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
666
|
+
$rootScope = injector.get("$rootScope");
|
|
667
|
+
$rootScope.$apply();
|
|
668
|
+
|
|
669
|
+
setTimeout(() => {
|
|
670
|
+
expect(contentOnLink).toBe("Hello");
|
|
671
|
+
done();
|
|
672
|
+
}, 100);
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
it("should add the content to the element before compiling it", (done) => {
|
|
676
|
+
let root;
|
|
677
|
+
window.angular.module("myModule", []).directive("test", () => ({
|
|
678
|
+
link(scope, el) {
|
|
679
|
+
root = el.parent().parent().parent();
|
|
680
|
+
},
|
|
681
|
+
}));
|
|
682
|
+
element = jqLite("<div><div ng-include=\"'/mock/directive'\"></div>");
|
|
683
|
+
const injector = angular.bootstrap(element, ["myModule"]);
|
|
684
|
+
$rootScope = injector.get("$rootScope");
|
|
685
|
+
$rootScope.$apply();
|
|
686
|
+
|
|
687
|
+
setTimeout(() => {
|
|
688
|
+
expect(root[0]).toBe(element[0]);
|
|
689
|
+
done();
|
|
690
|
+
}, 100);
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
// describe("and animations", () => {
|
|
695
|
+
// let body;
|
|
696
|
+
// let element;
|
|
697
|
+
// let $rootElement;
|
|
698
|
+
|
|
699
|
+
// function html(content) {
|
|
700
|
+
// $rootElement.html(content);
|
|
701
|
+
// element = $rootElement.children().eq(0);
|
|
702
|
+
// return element;
|
|
703
|
+
// }
|
|
704
|
+
|
|
705
|
+
// // beforeEach(
|
|
706
|
+
// // module(
|
|
707
|
+
// // () =>
|
|
708
|
+
// // // we need to run animation on attached elements;
|
|
709
|
+
// // function (_$rootElement_) {
|
|
710
|
+
// // $rootElement = _$rootElement_;
|
|
711
|
+
// // body = jqLite(window.document.body);
|
|
712
|
+
// // body.append($rootElement);
|
|
713
|
+
// // },
|
|
714
|
+
// // ),
|
|
715
|
+
// // );
|
|
716
|
+
|
|
717
|
+
// afterEach(() => {
|
|
718
|
+
// dealoc(body);
|
|
719
|
+
// dealoc(element);
|
|
720
|
+
// });
|
|
721
|
+
|
|
722
|
+
// // beforeEach(module("ngAnimateMock"));
|
|
723
|
+
|
|
724
|
+
// afterEach(() => {
|
|
725
|
+
// dealoc(element);
|
|
726
|
+
// });
|
|
727
|
+
|
|
728
|
+
// it("should fire off the enter animation", () => {
|
|
729
|
+
// let item;
|
|
730
|
+
|
|
731
|
+
// $templateCache.put("enter", [200, "<div>data</div>", {}]);
|
|
732
|
+
// $rootScope.tpl = "enter";
|
|
733
|
+
// element = $compile(
|
|
734
|
+
// html("<div><div " + 'ng-include="tpl">' + "</div></div>"),
|
|
735
|
+
// )($rootScope);
|
|
736
|
+
// $rootScope.$digest();
|
|
737
|
+
|
|
738
|
+
// const animation = $animate.queue.pop();
|
|
739
|
+
// expect(animation.event).toBe("enter");
|
|
740
|
+
// expect(animation.element.text()).toBe("data");
|
|
741
|
+
// });
|
|
742
|
+
|
|
743
|
+
// it("should fire off the leave animation", () => {
|
|
744
|
+
// let item;
|
|
745
|
+
// $templateCache.put("enter", [200, "<div>data</div>", {}]);
|
|
746
|
+
// $rootScope.tpl = "enter";
|
|
747
|
+
// element = $compile(
|
|
748
|
+
// html("<div><div " + 'ng-include="tpl">' + "</div></div>"),
|
|
749
|
+
// )($rootScope);
|
|
750
|
+
// $rootScope.$digest();
|
|
751
|
+
|
|
752
|
+
// let animation = $animate.queue.shift();
|
|
753
|
+
// expect(animation.event).toBe("enter");
|
|
754
|
+
// expect(animation.element.text()).toBe("data");
|
|
755
|
+
|
|
756
|
+
// $rootScope.tpl = "";
|
|
757
|
+
// $rootScope.$digest();
|
|
758
|
+
|
|
759
|
+
// animation = $animate.queue.shift();
|
|
760
|
+
// expect(animation.event).toBe("leave");
|
|
761
|
+
// expect(animation.element.text()).toBe("data");
|
|
762
|
+
// });
|
|
763
|
+
|
|
764
|
+
// it("should animate two separate ngInclude elements", () => {
|
|
765
|
+
// let item;
|
|
766
|
+
// $templateCache.put("one", [200, "one", {}]);
|
|
767
|
+
// $templateCache.put("two", [200, "two", {}]);
|
|
768
|
+
// $rootScope.tpl = "one";
|
|
769
|
+
// element = $compile(
|
|
770
|
+
// html("<div><div " + 'ng-include="tpl">' + "</div></div>"),
|
|
771
|
+
// )($rootScope);
|
|
772
|
+
// $rootScope.$digest();
|
|
773
|
+
|
|
774
|
+
// const item1 = $animate.queue.shift().element;
|
|
775
|
+
// expect(item1.text()).toBe("one");
|
|
776
|
+
|
|
777
|
+
// $rootScope.tpl = "two";
|
|
778
|
+
// $rootScope.$digest();
|
|
779
|
+
|
|
780
|
+
// const itemA = $animate.queue.shift().element;
|
|
781
|
+
// const itemB = $animate.queue.shift().element;
|
|
782
|
+
// expect(itemA.attr("ng-include")).toBe("tpl");
|
|
783
|
+
// expect(itemB.attr("ng-include")).toBe("tpl");
|
|
784
|
+
// expect(itemA).not.toEqual(itemB);
|
|
785
|
+
// });
|
|
786
|
+
|
|
787
|
+
// it("should destroy the previous leave animation if a new one takes place", () => {
|
|
788
|
+
// module(($provide) => {
|
|
789
|
+
// $provide.decorator("$animate", ($delegate, $$q) => {
|
|
790
|
+
// const emptyPromise = $$q.defer().promise;
|
|
791
|
+
// emptyPromise.done = () => {};
|
|
792
|
+
|
|
793
|
+
// $delegate.leave = function () {
|
|
794
|
+
// return emptyPromise;
|
|
795
|
+
// };
|
|
796
|
+
// return $delegate;
|
|
797
|
+
// });
|
|
798
|
+
// });
|
|
799
|
+
// () => {
|
|
800
|
+
// let item;
|
|
801
|
+
// const $scope = $rootScope.$new();
|
|
802
|
+
// element = $compile(
|
|
803
|
+
// html("<div>" + '<div ng-include="inc">Yo</div>' + "</div>"),
|
|
804
|
+
// )($scope);
|
|
805
|
+
|
|
806
|
+
// $templateCache.put("one", [200, "<div>one</div>", {}]);
|
|
807
|
+
// $templateCache.put("two", [200, "<div>two</div>", {}]);
|
|
808
|
+
|
|
809
|
+
// $scope.$apply('inc = "one"');
|
|
810
|
+
|
|
811
|
+
// let destroyed;
|
|
812
|
+
// const inner = element.children(0);
|
|
813
|
+
// inner.on("$destroy", () => {
|
|
814
|
+
// destroyed = true;
|
|
815
|
+
// });
|
|
816
|
+
|
|
817
|
+
// $scope.$apply('inc = "two"');
|
|
818
|
+
|
|
819
|
+
// $scope.$apply('inc = "one"');
|
|
820
|
+
|
|
821
|
+
// $scope.$apply('inc = "two"');
|
|
822
|
+
|
|
823
|
+
// expect(destroyed).toBe(true);
|
|
824
|
+
// };
|
|
825
|
+
// });
|
|
826
|
+
// });
|
|
827
|
+
});
|
|
828
|
+
});
|