Skip to content

Commit 8c12b54

Browse files
committed
Test fix
1 parent a0c0933 commit 8c12b54

File tree

6 files changed

+17
-23
lines changed

6 files changed

+17
-23
lines changed

@types/router/template-factory.d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export class TemplateFactoryProvider {
1414
| ((
1515
$http: ng.HttpService,
1616
$templateCache: ng.TemplateCacheService,
17-
$templateRequest: any,
17+
$templateRequest: ng.TemplateRequestService,
1818
$injector: import("../core/di/internal-injector.js").InjectorService,
1919
) => this)
2020
)[];
21-
$templateRequest: any;
21+
$templateRequest: import("../services/template-request/interface.ts").TemplateRequestService;
2222
$http: import("../services/http/interface.ts").HttpService;
2323
$templateCache: ng.TemplateCacheService;
2424
$injector: import("../core/di/internal-injector.js").InjectorService;
@@ -62,10 +62,9 @@ export class TemplateFactoryProvider {
6262
* @param {string|Function} url url of the template to load, or a function
6363
* that returns a url.
6464
* @param {Object} params Parameters to pass to the url function.
65-
* @return {string|Promise.<string>} The template html as a string, or a promise
66-
* for that string.
65+
* @return {Promise<string>}
6766
*/
68-
fromUrl(url: string | Function, params: any): string | Promise<string>;
67+
fromUrl(url: string | Function, params: any): Promise<string>;
6968
/**
7069
* Creates a template by invoking an injectable provider function.
7170
*

@types/services/template-request/template-request.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
export class TemplateRequestProvider {
99
/** @type {ng.RequestShortcutConfig|undefined} */
1010
httpOptions: ng.RequestShortcutConfig | undefined;
11-
/** @returns {Array} DI tokens for Angular.ts injection */
1211
$get: (
1312
| string
1413
| ((

src/core/compile/compile.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const TEST_URL = "src/core/compile/compile.html?random=false";
55
test("unit tests contain no errors", async ({ page }) => {
66
await page.goto(TEST_URL);
77
await page.content();
8-
await page.waitForTimeout(4000);
8+
await page.waitForTimeout(5000);
99
await expect(page.locator(".jasmine-overall-result")).toHaveText(
1010
/ 0 failures/,
1111
);

src/router/template-factory.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class TemplateFactoryProvider {
3535
/**
3636
* @param {ng.HttpService} $http
3737
* @param {ng.TemplateCacheService} $templateCache
38-
* @param {any} $templateRequest
38+
* @param {ng.TemplateRequestService} $templateRequest
3939
* @param {import("../core/di/internal-injector.js").InjectorService} $injector
4040
* @returns
4141
*/
@@ -135,8 +135,7 @@ export class TemplateFactoryProvider {
135135
* @param {string|Function} url url of the template to load, or a function
136136
* that returns a url.
137137
* @param {Object} params Parameters to pass to the url function.
138-
* @return {string|Promise.<string>} The template html as a string, or a promise
139-
* for that string.
138+
* @return {Promise<string>}
140139
*/
141140
fromUrl(url, params) {
142141
if (isFunction(url)) url = /** @type {Function} */ (url)(params);
@@ -154,7 +153,7 @@ export class TemplateFactoryProvider {
154153
});
155154
}
156155

157-
return this.$templateRequest(url);
156+
return this.$templateRequest(/** @type {string} */ (url));
158157
}
159158

160159
/**

src/router/template-factory.spec.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("templateFactory", () => {
3838

3939
describe("template URL behavior", () => {
4040
it("fetches relative URLs correctly", async () => {
41-
const res = $templateFactory.fromUrl("/mock/hello");
41+
const res = await $templateFactory.fromUrl("/mock/hello");
4242
await wait(100);
4343
expect(await res).toEqual("Hello");
4444
});
@@ -86,13 +86,9 @@ describe("templateFactory", () => {
8686
});
8787
});
8888

89-
it("does not restrict URL loading", function () {
90-
expect(() => {
91-
$templateFactory.fromUrl("http://evil.com/views/view.html");
92-
}).not.toThrowError();
93-
94-
expect(() => {
95-
$templateFactory.fromUrl("data:text/html,foo");
89+
it("does not restrict URL loading", async () => {
90+
expect(async () => {
91+
await $templateFactory.fromUrl("data:text/html,foo");
9692
}).not.toThrowError();
9793
});
9894
});
@@ -142,14 +138,14 @@ describe("templateFactory", () => {
142138
component: "dataComponent",
143139
});
144140
$stateService.go("cmp");
145-
await wait();
141+
await wait(100);
146142
expect(el.innerHTML).toMatch(/\<x-data-component/);
147143
});
148144

149145
it("should prefix the components dom element with x- for components named xFoo", async () => {
150146
$stateRegistry.register({ name: "cmp", component: "xComponent" });
151147
$stateService.go("cmp");
152-
await wait();
148+
await wait(100);
153149
expect(el.innerHTML).toMatch(/\<x-x-component/);
154150
});
155151
});

src/services/template-request/template-request.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export class TemplateRequestProvider {
1313
/** @type {ng.RequestShortcutConfig|undefined} */
1414
httpOptions;
1515

16-
/** @returns {Array} DI tokens for Angular.ts injection */
1716
$get = [
1817
$injectTokens._templateCache,
1918
$injectTokens._http,
@@ -56,7 +55,9 @@ export class TemplateRequestProvider {
5655

5756
return response.data;
5857
},
59-
(resp) => Promise.reject(resp),
58+
(resp) => {
59+
return Promise.reject(resp);
60+
},
6061
);
6162
};
6263

0 commit comments

Comments
 (0)