本文整理汇总了TypeScript中@ember/test-helpers.getContext函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getContext函数的具体用法?TypeScript getContext怎么用?TypeScript getContext使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getContext函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getContext
export function getService<T>(name: string): T {
const { owner } = getContext();
const service = owner.lookup<T>(`service:${name}`);
return service;
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:7,代码来源:get-service.ts
示例2: refresh
export async function refresh(mocking: () => void = () => undefined) {
const url = currentURL();
const ctx = getContext();
await teardownContext(ctx);
await setupContext(ctx);
await mocking();
await visit(url);
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:8,代码来源:refresh.ts
示例3: getContext
export const textFor = (selector: string): string => {
const context = getContext();
const root = context.element;
const element = root.querySelector(selector);
const content = element && element.textContent;
const text = (content && content.trim()) || '';
return text;
};
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:10,代码来源:text-for.ts
示例4: cleanEverything
async function cleanEverything() {
const context = getContext();
if (context) {
const adapter = context.owner.lookup('adapter:application');
await adapter.cache.clear();
}
// specifically, offline storage
await localforage.clear();
await localStorage.clear();
}
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:12,代码来源:clear-local-storage.ts
示例5: getContext
export const stubService = (name: string, hash = {}, injections?: IInjection[]) => {
let stubbedService;
// TODO: need to be able to use an extended service that uses services. :)
if (hash instanceof Function) {
stubbedService = hash;
} else {
stubbedService = Service.extend(hash);
}
let { owner } = getContext();
let serviceName = `service:${name}`;
owner.register(serviceName, stubbedService);
if (injections) {
injections.forEach(injection => {
owner.application.inject(injection.in, injection.as, serviceName);
});
}
};
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:21,代码来源:stub-service.ts
注:本文中的@ember/test-helpers.getContext函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论