当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Container.makeGlobal方法代码示例

本文整理汇总了TypeScript中aurelia-dependency-injection.Container.makeGlobal方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Container.makeGlobal方法的具体用法?TypeScript Container.makeGlobal怎么用?TypeScript Container.makeGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aurelia-dependency-injection.Container的用法示例。


在下文中一共展示了Container.makeGlobal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: Container

import { Database } from './database/Database';
import * as errorHandlers from './middleware/errorHandlers';
import * as queryHandlers from './middleware/queryHandlers';
import * as requestHandlers from './middleware/requestHandlers';
import { ServiceManager } from './services/ServiceManager';
import './utils/ObjectExtensions'; // add object extension methods;

const env = process.env.NODE_ENV || 'dev';

const PUBLIC_DIRECTORY = 'www';
const PORT_KEY = 'port';
const DEFAULT_PORT = 443;

// set up the dependency injection container
const container: Container = new Container();
container.makeGlobal();

const appConfig: any = new AppConfig('./config.json');
container.registerInstance(AppConfig, appConfig);

/*******  set up logging   ********/
const logOptions = appConfig.logging;
logOptions.name = appConfig.name;

const log = new Logger(logOptions);

container.registerInstance(Logger, log);
/********* end set up logging   ********/

let options: DbOptions = appConfig.database;
开发者ID:weagle08,项目名称:node-start,代码行数:30,代码来源:server.ts


注:本文中的aurelia-dependency-injection.Container.makeGlobal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。