本文整理汇总了TypeScript中aurelia-pal-browser.initialize函数的典型用法代码示例。如果您正苦于以下问题:TypeScript initialize函数的具体用法?TypeScript initialize怎么用?TypeScript initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了initialize函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: initialize
import 'babel-polyfill';
import 'aurelia-polyfills';
import {initialize} from 'aurelia-pal-browser';
initialize();
开发者ID:jmezach,项目名称:NewRelicDashboardWidgets,代码行数:4,代码来源:setup.ts
示例2: it
it("should do things on things", () => {
initialize();
// type '1', '2', 'left', 'left', 'v' should result in '12'
let inputElement = document.createElement("input");
let container = new Container();
container.makeGlobal();
container.registerInstance(Element, inputElement);
let engine = container.get(TemplatingEngine)
let mask = "(999) 999-9999";
let maskedInput = engine.createViewModelForUnitTest(MaskedInput, {
"mask": mask
});
maskedInput.isFocused = () => true;
maskedInput.isHidden = () => false;
maskedInput.value = "";
expect(maskedInput.mask).toBe(mask);
expect(maskedInput.value).toBe("");
expect(inputElement.value).toBe("");
expect(maskedInput.element).toBe(inputElement);
expect(maskedInput.getCaretPosition()).toBe(0);
maskedInput.attached();
expect(maskedInput.inputElement).toBe(inputElement);
expect(inputElement.value).toBe("(___) ___-____");
expect(maskedInput.caretPos).toBe(1);
expect(maskedInput.getCaretPosition()).toBe(1);
let focusEvent = null;
let inputEvent = null;
let keyupEvent = null;
focusEvent = makeFocusEvent();
maskedInput.onFocus(focusEvent);
expect(getCursor(inputElement)).toBe(1);
inputElement.value = "(1___) ___-____";
setCursor(inputElement, 2);
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent("1");
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(1__) ___-____");
expect(maskedInput.value).toBe("1");
expect(maskedInput.oldValue).toBe("(1__) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("1");
expect(getCursor(inputElement)).toBe(2);
inputElement.value = "(12__) ___-____";
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent("2");
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(getCursor(inputElement)).toBe(3);
setCursor(inputElement, 2);
expect(inputElement.value).toBe("(12_) ___-____");
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent(LEFT);
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(getCursor(inputElement)).toBe(2);
setCursor(inputElement, 1);
expect(inputElement.value).toBe("(12_) ___-____");
maskedInput.onInput(inputEvent);
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(maskedInput.caretPos).toBe(1);
expect(getCursor(inputElement)).toBe(1);
inputElement.value = "(v12__) ___-____";
setCursor(inputElement, 2);
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent('v');
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(getCursor(inputElement)).toBe(2);
});
开发者ID:tianyawy,项目名称:aurelia-mask,代码行数:90,代码来源:masked-input.spec.ts
注:本文中的aurelia-pal-browser.initialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论