當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript proxyquire類代碼示例

本文整理匯總了TypeScript中proxyquire的典型用法代碼示例。如果您正苦於以下問題:TypeScript proxyquire類的具體用法?TypeScript proxyquire怎麽用?TypeScript proxyquire使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了proxyquire類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

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

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

示例3: before

 before(() => {
   GrpcOperation =
       proxyquire('../src/operation', {
         './service-object': {GrpcServiceObject: FakeGrpcServiceObject},
         './service': {GrpcService: FakeGrpcService}
       }).GrpcOperation;
 });
開發者ID:foggg7777,項目名稱:nodejs-common-grpc,代碼行數:7,代碼來源:operation.ts

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

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

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

示例7: i18n

function i18n(lang) {
	return proxyquire('./i18n', {
		'os-locale': {
			sync: () => lang,
		},
	});
}
開發者ID:jedmao,項目名稱:eclint,代碼行數:7,代碼來源:i18n.spec.ts

示例8: before

 before(function () {
   proxyq.noCallThru();
   CompositionRootService = proxyq(
     '../../src/services/compositionRootService',
     { vscode },
   ).CompositionRootService;
 });
開發者ID:robertohuertasm,項目名稱:vscode-icons,代碼行數:7,代碼來源:compositionRoot.test.ts

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


注:本文中的proxyquire類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。