本文整理汇总了TypeScript中mock-fs类的典型用法代码示例。如果您正苦于以下问题:TypeScript mock-fs类的具体用法?TypeScript mock-fs怎么用?TypeScript mock-fs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mock-fs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
* [email protected] -> foo@^1.0.0
* 3.3.3
* ~/different-foo/~/foo
* Num deps: 1, files: 2
* [email protected] -> 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
示例10: createMockFileSystem
function createMockFileSystem() {
mockFs({
'/some_package': {
'valid_entry_point': {
'package.json': createPackageJson('valid_entry_point'),
'valid_entry_point.metadata.json': 'some meta data',
},
'missing_package_json': {
// no package.json!
'missing_package_json.metadata.json': 'some meta data',
},
'missing_typings': {
'package.json': createPackageJson('missing_typings', {exclude: 'typings'}),
'missing_typings.metadata.json': 'some meta data',
},
'missing_esm2015': {
'package.json': createPackageJson('missing_esm2015', {exclude: 'esm2015'}),
'missing_esm2015.metadata.json': 'some meta data',
},
'missing_metadata': {
'package.json': createPackageJson('missing_metadata'),
// no metadata.json!
}
}
});
}
开发者ID:KaneFreeman,项目名称:angular,代码行数:26,代码来源:entry_point_spec.ts
示例11: function
it('should return repoExists = false if a repo does not exist', async function(){
mock({});
let data: any = {currentProject: 'test_project'};
await git_manager.info(data);
data.repoExists.should.equal(false);
exec_stub.callCount.should.equal(0);
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:7,代码来源:GitManager.spec.ts
示例12:
before(function(){
mock({
'/root/Bela/examples/01-basics/test_example': {
'render.cpp': 'test_content'
}
});
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:7,代码来源:ProjectManager.spec.ts
示例13: beforeEach
beforeEach(() => {
mockFs( {
'1.ts': `
import {NgModule} from '@angular/core';
@NgModule({
declarations: []
})
class Module {}`,
'2.ts': `
import {NgModule} from '@angular/core';
@NgModule({
declarations: [
Other
]
})
class Module {}`,
'3.ts': `
import {NgModule} from '@angular/core';
@NgModule({
})
class Module {}`,
'4.ts': `
import {NgModule} from '@angular/core';
@NgModule({
field1: [],
field2: {}
})
class Module {}`
});
});
开发者ID:AppasThirdLeftFoot,项目名称:angular-cli,代码行数:34,代码来源:ast-utils.spec.ts
示例14: beforeEach
beforeEach(() => {
mockFs({
'project-root': {
'fileA.ts': stripIndents`
const r1 = {
"loadChildren": "moduleA"
};
const r2 = {
loadChildren: "moduleB"
};
const r3 = {
'loadChildren': 'moduleC'
};
const r4 = {
"loadChildren": 'app/+workspace/+settings/settings.module#SettingsModule'
};
const r5 = {
loadChildren: 'unexistentModule'
};
`,
// Create those files too as they have to exist.
'moduleA.ts': '',
'moduleB.ts': '',
'moduleC.ts': '',
'moduleD.ts': '',
'app': { '+workspace': { '+settings': { 'settings.module.ts': '' } } }
}
});
});
开发者ID:JasonGoemaat,项目名称:angular-cli,代码行数:29,代码来源:find-lazy-module.spec.ts
示例15: function
before(async function(){
let settings = project_settings.default_project_settings();
settings.CLArgs.make = 'AT;LDFLAGS=um';
mock({
'/root/Bela/projects/test/settings.json': JSON.stringify(settings)
});
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:7,代码来源:ProjectSettings.spec.ts
示例16: dependencies
it("handles empty root path", () => {
mock({});
return dependencies(".")
.then((deps) => {
expect(deps).to.equal(null);
});
});
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:7,代码来源:dependencies.spec.ts
示例17: before
before(() =>
mockFS({
'migrations': {
'1.first.sql': '---',
'2.second.sql': '---'
}
})
开发者ID:programble,项目名称:careen,代码行数:7,代码来源:migrations.ts
示例18:
before(function(){
let mock_dir: any = {};
mock_dir[file_list[0]] = 'test';
mock_dir[file_list[1]] = 'test';
mock_dir[file_list[2]] = 'test';
mock({ 'test_dir': mock_dir });
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:7,代码来源:FileManager.spec.ts
示例19: function
it('should set stats.exists to false if the backup file does not exist', async function(){
mock({
'/root/Bela/IDE/.lockfile': '/root/Bela/projects/test_project/test_file',
});
await IDE.check_lockfile();
let stats: util.Backup_File_Stats = IDE.get_backup_file_stats();
stats.exists.should.equal(false);
});
开发者ID:BelaPlatform,项目名称:Bela,代码行数:8,代码来源:IDE.spec.ts
示例20: beforeEach
beforeEach(() => {
let mockDrive = {
'src': {
'routes.ts' : 'export default [];'
}
};
mockFs(mockDrive);
});
开发者ID:jmc265,项目名称:angular-cli,代码行数:8,代码来源:route-utils.spec.ts
注:本文中的mock-fs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论