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