本文整理汇总了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);
}