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


TypeScript proxyquire.default方法代码示例

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


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

示例1: it

    it('should by default error when workingDirectory is a root directory with a package.json', done => {
      const debug = new Debug({}, packageInfo);
      /*
       * `path.sep` represents a root directory on both Windows and Unix.
       * On Windows, `path.sep` resolves to the current drive.
       *
       * That is, after opening a command prompt in Windows, relative to the
       * drive C: and starting the Node REPL, the value of `path.sep`
       * represents `C:\\'.
       *
       * If `D:` is entered at the prompt to switch to the D: drive before
       * starting the Node REPL, `path.sep` represents `D:\\`.
       */
      const root = path.sep;
      const mockedDebuglet = proxyquire('../src/agent/debuglet', {
        /*
         * Mock the 'fs' module to verify that if the root directory is used,
         * and the root directory is reported to contain a `package.json`
         * file, then the agent still produces an `initError` when the
         * working directory is the root directory.
         */
        fs: {
          stat: (
            filepath: string | Buffer,
            cb: (err: Error | null, stats: {}) => void
          ) => {
            if (filepath === path.join(root, 'package.json')) {
              // The key point is that looking for `package.json` in the
              // root directory does not cause an error.
              return cb(null, {});
            }
            fs.stat(filepath, cb);
          },
        },
      });
      const config = extend({}, defaultConfig, {workingDirectory: root});
      const debuglet = new mockedDebuglet.Debuglet(debug, config);
      let text = '';
      debuglet.logger.error = (str: string) => {
        text += str;
      };

      debuglet.on('initError', (err: Error) => {
        const errorMessage =
          'The working directory is a root ' +
          'directory. Disabling to avoid a scan of the entire filesystem ' +
          'for JavaScript files. Use config `allowRootAsWorkingDirectory` ' +
          'if you really want to do this.';
        assert.ok(err);
        assert.strictEqual(err.message, errorMessage);
        assert.ok(text.includes(errorMessage));
        done();
      });

      debuglet.once('started', () => {
        assert.fail('Should not start if workingDirectory is a root directory');
      });

      debuglet.start();
    });
开发者ID:GoogleCloudPlatform,项目名称:cloud-debug-nodejs,代码行数:60,代码来源:test-debuglet.ts

示例2: beforeEach

    beforeEach(() => {
        serverStub = sinon.stub({
            get: () => this,
            registerServiceClass: (target: any) => this,
            registerServiceMethod: (target: any, propertyKey: string) => this
        });
        propertyType = sinon.stub();
        reflectGetMetadata = sinon.stub(Reflect, 'getMetadata');
        reflectGetOwnMetadata = sinon.stub(Reflect, 'getOwnMetadata');

        serviceDecorators = proxyquire('../../src/decorators/services', {
            '../server/server-container': { ServerContainer: serverStub }
        });
        parameterDecorators = proxyquire('../../src/decorators/parameters', {
            '../server/server-container': { ServerContainer: serverStub }
        });
        methodDecorators = proxyquire('../../src/decorators/methods', {
            '../server/server-container': { ServerContainer: serverStub }
        });

        serviceClass = new ServiceClass(TestService);
        serviceMethod = new ServiceMethod();

        serverStub.registerServiceMethod.returns(serviceMethod);
        serverStub.registerServiceClass.returns(serviceClass);
        serverStub.get.returns(serverStub);
        reflectGetMetadata.returns(propertyType);
        reflectGetOwnMetadata.returns(propertyType);
    });
开发者ID:thiagobustamante,项目名称:typescript-rest,代码行数:29,代码来源:decorators.spec.ts

示例3: beforeEach

 beforeEach(() => {
   consoleLogSpy.reset();
   consoleWarnSpy.reset();
   const logger = proxyquire("./logger", { "./config": { config: { logging: false } } }).logger;
   logger.info("this will be ignored");
   logger.warn("this will be ignored at warn");
 });
开发者ID:elliottmurray,项目名称:pact-js,代码行数:7,代码来源:logger.spec.ts

示例4: before

 before(function () {
   proxyq.noCallThru();
   CompositionRootService = proxyq(
     '../../src/services/compositionRootService',
     { vscode },
   ).CompositionRootService;
 });
开发者ID:robertohuertasm,项目名称:vscode-icons,代码行数:7,代码来源:compositionRoot.test.ts

示例5: it

        it("check main flow", () => {
            const AppProxy = Proxyquire("../app", {
                express: Sinon.stub().returns(express),
            });

            const application = new AppProxy.Application();
            const stubInitSessionManagement = Sinon.stub(application, "initSessionManagement");
            const stubInitPassport = Sinon.stub(application, "initPassport");
            const stubInitSessionFiltering = Sinon.stub(application, "initSessionFiltering");
            const stubInitRestEndpoints = Sinon.stub(application, "initRestEndpoints");
            const stubInitStaticContent = Sinon.stub(application, "initStaticContent");
            const stubStartServer = Sinon.stub(application, "startServer");

            application.initExpress();
            stubInitSessionManagement.restore();
            stubInitPassport.restore();
            stubInitSessionFiltering.restore();
            stubInitRestEndpoints.restore();
            stubInitStaticContent.restore();
            stubStartServer.restore();

            Sinon.assert.callOrder(
                stubInitSessionManagement.withArgs(express),
                stubInitPassport.withArgs(express),
                stubInitSessionFiltering.withArgs(express),
                stubInitRestEndpoints.withArgs(express),
                stubInitStaticContent.withArgs(express),
                stubStartServer.withArgs(express),
            );
        });
开发者ID:YuriyGorvitovskiy,项目名称:Taskenize,代码行数:30,代码来源:app.ts

示例6: before

 before(() => {
   GrpcOperation =
       proxyquire('../src/operation', {
         './service-object': {GrpcServiceObject: FakeGrpcServiceObject},
         './service': {GrpcService: FakeGrpcService}
       }).GrpcOperation;
 });
开发者ID:foggg7777,项目名称:nodejs-common-grpc,代码行数:7,代码来源:operation.ts

示例7: proxyquire

        o.test('should return only directories', t => {
            let directories = ['dir1', 'another-dir', 'test'];
            t.plan(directories.length);

            let files = ['test.jpg', 'another-test.docx'];

            let nodeFsStub = {
                readdirSync: (path: string) => directories.concat(files),
                statSync: (path: string) => {
                    return {
                        isDirectory: () => {
                            return directories.indexOf(path) !== -1;
                        }
                    };
                }
            };

            let FileSystem = proxyquire('tidyfolders/src/file-system', {'fs': nodeFsStub}).FileSystem;

            let fileSystem = new FileSystem(moveDirStub);
            let returnedDirectories: Array<DirectoryModel> = fileSystem.getAllDirectories('');
            let returnedDirectoriesNames = returnedDirectories.map(d => d.getName());

            for (let i = 0; i < directories.length; i++) {
                t.equal(returnedDirectoriesNames[i], directories[i]);
            }
        });
开发者ID:Jameskmonger,项目名称:tidyfolders,代码行数:27,代码来源:file-system.test.ts

示例8: beforeEach

    beforeEach(() => {
        authenticator = sinon.stub();
        initializer = sinon.stub();
        sessionHandler = sinon.stub();

        expressStub = sinon.stub({
            use: (...handlers: Array<RequestHandler>) => this
        });

        passportStub = sinon.stub({
            authenticate: (strategy: string | Array<string>, options: AuthenticateOptions,
                callback?: (...args: Array<any>) => any) => true,
            deserializeUser: (user: string, done: (a: any, b: any) => void) => this,
            initialize: () => this,
            serializeUser: (user: any, done: (a: any, b: string) => void) => this,
            session: () => this,
            use: (name: string, strategy: Strategy) => this
        });

        passportStub.authenticate.returns(authenticator);
        passportStub.initialize.returns(initializer);
        passportStub.session.returns(sessionHandler);

        PassportAuthenticator = proxyquire('../../src/authenticator/passport', {
            'passport': passportStub
        }).PassportAuthenticator;
    });
开发者ID:thiagobustamante,项目名称:typescript-rest,代码行数:27,代码来源:passport-authenticator.spec.ts

示例9: i18n

function i18n(lang) {
	return proxyquire('./i18n', {
		'os-locale': {
			sync: () => lang,
		},
	});
}
开发者ID:jedmao,项目名称:eclint,代码行数:7,代码来源:i18n.spec.ts


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