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


TypeScript mock-fs.default方法代码示例

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


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

示例1: if

		beforeEach(function(){
			if (get_boot_project_counter === 0){
				mock({ '/opt/Bela/startup_env': 'ACTIVE=1\nPROJECT=test_project' });
			} else if (get_boot_project_counter === 1){
				mock({ '/opt/Bela/startup_env': 'ACTIVE=0\nPROJECT=test_project' });
			} else if (get_boot_project_counter === 2){
				mock({});
			}
			get_boot_project_counter += 1;
		});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:10,代码来源:RunOnBoot.spec.ts

示例2: createMockFileSystem

function createMockFileSystem() {
  mockFs({
    '/node_modules/@angular': loadAngularPackages(),
    '/node_modules/rxjs': loadDirectory(resolveNpmTreeArtifact('rxjs', 'index.js')),
    '/node_modules/tslib': loadDirectory(resolveNpmTreeArtifact('tslib', 'tslib.js')),
    '/node_modules/test-package': {
      'package.json': '{"name": "test-package", "es2015": "./index.js", "typings": "./index.d.ts"}',
      // no metadata.json file so not compiled by Angular.
      'index.js':
          'import {AppModule} from "@angular/common"; export class MyApp extends AppModule {};',
      'index.d.ts':
          'import {AppModule} from "@angular/common"; export declare class MyApp extends AppModule;',
    },
    '/dist/local-package': {
      'package.json':
          '{"name": "local-package", "es2015": "./index.js", "typings": "./index.d.ts"}',
      'index.metadata.json': 'DUMMY DATA',
      'index.js': `
          import {Component} from '@angular/core';
          export class AppComponent {};
          AppComponent.decorators = [
            { type: Component, args: [{selector: 'app', template: '<h2>Hello</h2>'}] }
          ];`,
      'index.d.ts': `
          export declare class AppComponent {};`,
    },
  });
}
开发者ID:marclaval,项目名称:angular,代码行数:28,代码来源:ngcc_spec.ts

示例3: it

    it("displays versions skews correctly for hidden app roots", () => {
      mock({
        "test/fixtures/hidden-app-roots": fixtureDirs["test/fixtures/hidden-app-roots"],
      });

      return hiddenAppRootsInstance.template.text()
        .then((textStr) => {
          expect(textStr).to.eql(`
inspectpack --action=versions
=============================

## Summary
* Packages with skews:      1
* Total resolved versions:  2
* Total installed packages: 2
* Total depended packages:  2
* Total bundled files:      3

## \`bundle.js\`
* foo
  * 1.1.1
    * ~/foo
      * Num deps: 1, files: 1
      * package1@1.1.1 -> foo@^1.0.0
  * 3.3.3
    * ~/different-foo/~/foo
      * Num deps: 1, files: 2
      * package1@1.1.1 -> different-foo@^1.0.1 -> foo@^3.0.1
          `.trim());
        });
    });
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:31,代码来源:versions.spec.ts

示例4: Error

      it("errors for unset name@version for non-root level", () => {
        mock({
          "test/fixtures/duplicates-cjs": {
            "node_modules": {
              foo: {
                "package.json": JSON.stringify({
                  name: "foo",
                }),
              },
            },
            "package.json": JSON.stringify({
              dependencies: {
                "different-foo": "^1.0.1",
                "flattened-foo": "^1.1.0",
                "foo": "^1.0.0",
                "uses-foo": "^1.0.9",
              },
              name: "duplicates-cjs",
              version: "1.2.3",
            }),
          },
        });

        return dupsCjsInstance.getData()
          .then(() => {
            throw new Error("test should throw");
          })
          .catch((err) => {
            expect(err).to.have.property("message").that.contains("package without version");
          });
      });
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:31,代码来源:versions.spec.ts

示例5: _packageRoots

    it("handles simple cases", () => {
      mock({
        "my-app": {
          "package.json": JSON.stringify({
            name: "my-app",
          }, null, 2),
        },
      });

      return _packageRoots([
        {
          identifier: resolve("my-app/src/baz/index.js"),
          isNodeModules: false,
        },
        {
          identifier: resolve("my-app/node_modules/foo/index.js"),
          isNodeModules: true,
        },
        {
          identifier: resolve("my-app/node_modules/foo/node_modules/bug/bug.js"),
          isNodeModules: true,
        },
      ]).then((pkgRoots) => {
        expect(pkgRoots).to.eql([
          resolve("my-app"),
        ]);
      });
    });
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:28,代码来源:versions.spec.ts

示例6: it

 it('should handle searching up the home directory', () => {
   mockFs({
     [`$hotexamples_com/.angular-cli.json`]: 'foo'
   });
   const result = getProjectDetails();
   expect(result).toEqual(null);
 });
开发者ID:headinclouds,项目名称:angular-cli,代码行数:7,代码来源:project.spec.ts

示例7: Error

        it("errors on bad JSON", () => {
          mock({
            "package.json": "THIS_IS_NOT_JSON",
          });

          const cache = useCache ? {} : undefined;
          return Promise.all([
            readPackage("./package.json", cache),
            readPackage("./package.json", cache),
            readPackage("./NOT_FOUND/package.json", cache),
            readPackage("./package.json", cache),
          ])
            .then(() => {
              throw new Error("Should not reach then");
            })
            .catch((err) => {
              expect(err)
                .to.be.an.instanceOf(SyntaxError).and
                .to.have.property("message").that.contains("Unexpected token");

              // **Potentially brittle**: Because we invoke all in parallel, we
              // should have cache populated _first_ before any error strikes.
              //
              // **Note**: can remove this assert if it ends up being flaky.
              expect(_files.readJson).to.have.callCount(useCache ? 2 : 4);
            });
        });
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:27,代码来源:dependencies.spec.ts

示例8: before

 before(() => mockFS({
   migrations: {
     '1.test.sql': 'CREATE TABLE a (a INTEGER);\n---\nDROP TABLE a;\n',
     '1.test.up.sql': 'CREATE TABLE a (a INTEGER);\n',
     '1.test.down.sql': 'DROP TABLE a;\n'
   }
 }));
开发者ID:programble,项目名称:careen,代码行数:7,代码来源:files.ts

示例9: readPackages

    it("errors on bad package.json's", () => {
      const pkg = {
        name: "foo",
        version: "1.0.0",
      };

      mock({
        "node_modules": {
          bad: {
            "package.json": "THIS_IS_NOT_JSON",
          },
        },
        "package.json": JSON.stringify(pkg),
      });

      return readPackages(".")
        .then(_resolvePackageMap)
        .then(() => {
          throw new Error("Should not reach then");
        })
        .catch((err) => {
          expect(err)
            .to.be.an.instanceOf(SyntaxError).and
            .to.have.property("message").that.contains("Unexpected token");
        });
    });
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:26,代码来源:dependencies.spec.ts


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