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


TypeScript mockery.registerMock函数代码示例

本文整理汇总了TypeScript中mockery.registerMock函数的典型用法代码示例。如果您正苦于以下问题:TypeScript registerMock函数的具体用法?TypeScript registerMock怎么用?TypeScript registerMock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: beforeEach

  beforeEach(() => {

    mockery.enable({
      warnOnReplace: false,
      warnOnUnregistered: false,
      useCleanCache: true
    });

    let requestDeferred: IDeferred<any> = defer();
    requestDeferred.resolve({ statusCode: 200 });

    requestPromiseStub = sinon.stub().returns(requestDeferred.promise);

    mockery.registerMock('request-promise', requestPromiseStub);
    mockery.registerMock('node-sp-auth', {
      getAuth: (data: any) => {
        return Promise.resolve({});
      }
    });

    sprequest = require('./../../src/core/SPRequest');
  });
开发者ID:s-KaiNet,项目名称:sp-request,代码行数:22,代码来源:SPRequest.spec.ts

示例2: test

        test('win', () => {
            // Overwrite the statSync mock to say the x86 path doesn't exist
            const statSync = (aPath: string) => {
                if (aPath.indexOf('(x86)') >= 0) throw new Error('Not found');
            };
            mockery.registerMock('fs', { statSync });

            const Utilities = getUtilities();
            assert.equal(Utilities.getPlatform(), Utilities.Platform.Windows);
            assert.equal(
                Utilities.getBrowserPath(),
                'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe');
        });
开发者ID:MartinMa,项目名称:vscode-chrome-debug,代码行数:13,代码来源:utilities.test.ts

示例3: test

        test('handles a relative path with a generated script url', () => {
            const utilsMock = Mock.ofInstance(utils);
            utilsMock.callBase = true;
            mockery.registerMock('../utils', utilsMock.object);

            testUtils.registerMockGetURL('../utils', GENERATED_SCRIPT_URL + '.map', FILEDATA, utilsMock);
            setExpectedConstructorArgs(GENERATED_SCRIPT_URL, FILEDATA, PATHMAPPING);

            return sourceMapFactory.getMapForGeneratedPath(GENERATED_SCRIPT_URL, 'script.js.map').then(sourceMap => {
                assert(sourceMap);
                utilsMock.verifyAll();
            });
        });
开发者ID:Microsoft,项目名称:vscode-chrome-debug-core,代码行数:13,代码来源:sourceMapFactory.test.ts

示例4: it

        it("Speaks With Custom URL", function(done) {
            process.argv = command("node bst-intend.js HelloIntent --url https://proxy.bespoken.tools");
            mockery.registerMock("../lib/client/bst-virtual-alexa", {
                BSTVirtualAlexa: function (url: string) {
                    this.url = url;
                    this.start = function() {};
                    assert.equal(this.url, "https://proxy.bespoken.tools");
                    done();
                }
            });

            NodeUtil.load("../../bin/bst-intend.js");
        });
开发者ID:bespoken,项目名称:bst,代码行数:13,代码来源:bst-intend-test.ts

示例5: it

        it("Generates a launch request with Application ID", function(done) {
            process.argv = command("node bst-launch.js --appId 1234567890");
            mockery.registerMock("../lib/client/bst-virtual-alexa", {
                BSTVirtualAlexa: function (skillURL: any, interactionModel: any, intentSchemaFile: any, sampleUtterancesFile: any, applicationID: string) {
                    assert.equal(applicationID, "1234567890");
                    this.start = function () {};
                    this.launched = function (callback: any) {};
                    done();
                }
            });

            NodeUtil.load("../../bin/bst-launch.js");
        });
开发者ID:bespoken,项目名称:bst,代码行数:13,代码来源:bst-launch-test.ts

示例6: it

        it("Speaks With Application ID Succinct Syntax", function(done) {
            process.argv = command("node bst-utter.js Hello -a 1234567890");
            mockery.registerMock("../lib/client/bst-virtual-alexa", {
                BSTVirtualAlexa: function (skillURL: any, interactionModel: any, intentSchemaFile: any, sampleUtterancesFile: any, applicationID: string) {
                    assert.equal(applicationID, "1234567890");
                    this.start = function () {};
                    this.spoken = function (utterance: string, callback: any) {};

                    done();
                }
            });

            NodeUtil.load("../../bin/bst-utter.js");
        });
开发者ID:bespoken,项目名称:bst,代码行数:14,代码来源:bst-utter-test.ts

示例7: it

    it('gets correct local registries', () => {
        let mockParser = {
            GetRegistries: (npmrc: string) => [
                'http://registry.com/npmRegistry/',
                'http://example.pkgs.visualstudio.com/npmRegistry/',
                'http://localTFSServer/npmRegistry/'
            ]
        };
        mockery.registerMock('./npmrcparser', mockParser);
        let mockTask = {
            getVariable: (v: string) => {
                if (v === 'System.TeamFoundationCollectionUri') {
                    return 'http://example.visualstudio.com';
                }
            },
            debug: (message: string) => {
                // no-op
            },
            loc: (key: string) => {
                // no-op
            }
        };
        mockery.registerMock('vsts-task-lib/task', mockTask);

        let npmutil = require('../npm/npmutil');

        return npmutil.getLocalRegistries(['http://example.pkgs.visualstudio.com/', 'http://example.com'], '').then((registries: string[]) => {
            assert.equal(registries.length, 1);
            assert.equal(registries[0], 'http://example.pkgs.visualstudio.com/npmRegistry/');

            mockTask.getVariable = () => 'http://localTFSServer/';
            return npmutil.getLocalRegistries(['http://localTFSServer/', 'http://example.com'], '').then((registries: string[]) => {
                assert.equal(registries.length, 1);
                assert.equal(registries[0], 'http://localTFSServer/npmRegistry/');
            });
        });
    });
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:37,代码来源:npmL0.ts

示例8: it

it('fails if installing packages to the base environment fails', async function () {
    mockery.registerMock('vsts-task-lib/task', mockTask);

    const findConda = sinon.stub().returns('path-to-conda');
    const prependCondaToPath = sinon.spy();
    const installPackagesGlobally = sinon.stub().rejects(new Error('installPackagesGlobally'));

    mockery.registerMock('./conda_internal', {
        findConda,
        prependCondaToPath,
        installPackagesGlobally
    });

    const uut = reload('../conda');
    const parameters = {
        createCustomEnvironment: false,
        packageSpecs: 'pytest',
        updateConda: false
    };

    // Can't use `assert.throws` with an async function
    // Node 10: use `assert.rejects`
    let error: any | undefined;
    try {
        await uut.condaEnvironment(parameters, Platform.Linux);
    } catch (e) {
        error = e;
    }

    assert(error instanceof Error);
    assert.strictEqual(error.message, 'installPackagesGlobally');

    assert(findConda.calledOnceWithExactly(Platform.Linux));
    assert(prependCondaToPath.calledOnceWithExactly('path-to-conda', Platform.Linux));
    assert(installPackagesGlobally.calledOnceWithExactly('pytest', Platform.Linux, undefined));
});
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:36,代码来源:L0_conda.ts


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