本文整理匯總了TypeScript中alsatian.SpyOn函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript SpyOn函數的具體用法?TypeScript SpyOn怎麽用?TypeScript SpyOn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SpyOn函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: prismCallbackNotCalledBeforeRender
@Test("prism complete callback not called before render")
public prismCallbackNotCalledBeforeRender() {
const codeBlock = new CodeBlock({
children: "",
language: "typescript"
});
SpyOn(Prism.hooks, "run");
codeBlock.componentDidMount();
Expect(Prism.hooks.run).not.toHaveBeenCalled();
}
示例2: togglingTheMenuMakesItOpen
@Test("Initial toggle opens the menu")
public togglingTheMenuMakesItOpen() {
const navigationBar = new NavigationBarComponent();
SpyOn(navigationBar, "setState").andCall((newState: any) => {
Object.keys(newState).forEach(stateKey => {
navigationBar.state[stateKey] = newState[stateKey];
})
});
navigationBar.toggleMenu();
Expect(navigationBar.state.isMenuOpen).toBe(true);
}
示例3: prismCallbackCalledAfterRender
@Test("prism complete callback is called after render")
public prismCallbackCalledAfterRender() {
const codeBlock = new CodeBlock({
children: "",
language: "typescript"
});
SpyOn(Prism.hooks, "run");
codeBlock.render().props.children.ref({});
codeBlock.componentDidMount();
Expect(Prism.hooks.run).toHaveBeenCalledWith("complete", Any(Object));
}
示例4: prismCallbackCalledWithCodeElement
@TestCase({ fake: "codeElement" })
@TestCase({ something: "much", more: "interesting" })
@Test("prism complete callback is called with code element")
public prismCallbackCalledWithCodeElement(codeElement: any) {
const codeBlock = new CodeBlock({
children: "",
language: "typescript"
});
SpyOn(Prism.hooks, "run");
codeBlock.render().props.children.ref(codeElement);
codeBlock.componentDidMount();
Expect((Prism.hooks.run as any).calls[0].args[1].element).toBe(codeElement);
}
示例5: prismCallbackCalledWithCode
@TestCase("some code")
@TestCase("much more fancy logic")
@Test("prism complete callback is called with code")
public prismCallbackCalledWithCode(code: string) {
const codeBlock = new CodeBlock({
children: code,
language: "typescript"
});
SpyOn(Prism.hooks, "run");
codeBlock.render().props.children.ref({});
codeBlock.componentDidMount();
Expect((Prism.hooks.run as any).calls[0].args[1].code).toBe(code);
}