• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mock-fs.file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: it

  it('should flatten files and be incremental', () => {
    let testDir = {
      'input': {
        'dir1': {
          'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
          'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
          'subdir-1': {
            'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
          },
          'empty-dir': {}
        },
      },
      'output': {}
    };
    mockfs(testDir);

    let differ = new TreeDiffer('testLabel', 'input');
    let flattenedTree = flatten('input');
    flattenedTree.rebuild(differ.diffTree());

    expect(fs.readdirSync('output')).toEqual(['file-1.1.txt', 'file-1.txt', 'file-2.txt']);
    // fails  due to a mock-fs bug related to reading symlinks?
    // expect(read('output/file-1.1.txt')).toBe('file-1.1.txt content');


    // delete a file
    rm('input/dir1/file-1.txt');
    // add a new one
    write('input/dir1/file-3.txt', 'file-3.txt content');

    flattenedTree.rebuild(differ.diffTree());

    expect(fs.readdirSync('output')).toEqual(['file-1.1.txt', 'file-2.txt', 'file-3.txt']);
  });
开发者ID:KarthiTrichy20,项目名称:angular,代码行数:34,代码来源:broccoli-flatten.spec.ts


示例2: it

    it('should return empty diff if nothing has changed', () => {
      let testDir = {
        'dir1': {
          'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
          'file-2.txt': mockfs.file({content: 'file-2.txt content', mtime: new Date(1000)}),
          'subdir-1': {
            'file-1.1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})
          },
        }
      };
      mockfs(testDir);

      let differ = new TreeDiffer('testLabel', 'dir1');

      let diffResult = differ.diffTree();

      expect(diffResult.addedPaths).not.toEqual([]);
      expect(diffResult.changedPaths).toEqual([]);
      expect(diffResult.removedPaths).toEqual([]);

      diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual([]);
      expect(diffResult.changedPaths).toEqual([]);
      expect(diffResult.removedPaths).toEqual([]);
    });
开发者ID:AsherBarak,项目名称:angular,代码行数:26,代码来源:tree-differ.spec.ts


示例3: it

  it('should throw if duplicates are found during rebuild', () => {
    let testDir = {
      'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})},
      'tree2': {},
      'tree3': {}
    };
    mockfs(testDir);

    let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']);
    let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {});
    expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).not.toThrow();


    testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)});
    mockfs(testDir);
    expect(() => treeMerger.rebuild(treeDiffer.diffTrees()))
        .toThrowError("`overwrite` option is required for handling duplicates.");
  });
开发者ID:B-Thapa,项目名称:angular,代码行数:18,代码来源:broccoli-merge-trees.spec.ts


示例4: c

function c() {
	mock({
		foo: mock.file({
			content: 'file content here',
			ctime: new Date(1),
			mtime: new Date(1)
		 })
	});
}
开发者ID:ClearboxSystems,项目名称:DefinitelyTyped,代码行数:9,代码来源:mock-fs-tests.ts


示例5: it

  it('should throw an exception if duplicates are found', () => {
    let testDir = {
      'input': {
        'dir1': {
          'file-1.txt': mockfs.file({content: 'file-1.txt content', mtime: new Date(1000)}),
          'subdir-1':
              {'file-1.txt': mockfs.file({content: 'file-1.1.txt content', mtime: new Date(1000)})},
          'empty-dir': {}
        },
      },
      'output': {}
    };
    mockfs(testDir);

    let differ = new TreeDiffer('testLabel', 'input');
    let flattenedTree = flatten('input');
    expect(() => flattenedTree.rebuild(differ.diffTree()))
        .toThrowError("Duplicate file 'file-1.txt' found in path 'dir1/subdir-1/file-1.txt'");
  });
开发者ID:AsherBarak,项目名称:angular,代码行数:19,代码来源:broccoli-flatten.spec.ts


示例6: test

  test('should not throw if the custom expiry has not been reached yet', async () => {
    mockFs({
      [CACHE_PATH]: mockFs.file({
        content: JSON.stringify('Some test data'),
        mtime: subHours(new Date(), 36), // 36 hours ago
      }),
    });

    const cache = getCache<string>(CACHE_KEY, 48 * 60);
    await expect(cache.read()).resolves.toEqual('Some test data');
  });
开发者ID:nusmodifications,项目名称:nusmods,代码行数:11,代码来源:io.test.ts


示例7: it

  it('should throw if duplicates are used by default', () => {
    let testDir: any = {
      'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})},
      'tree2': {'foo.js': mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)})},
      'tree3': {'foo.js': mockfs.file({content: 'tree3/foo.js content', mtime: new Date(1000)})}
    };
    mockfs(testDir);
    let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']);
    let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {});
    expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).toThrow();

    delete testDir.tree2['foo.js'];
    delete testDir.tree3['foo.js'];
    mockfs(testDir);
    expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).not.toThrow();

    testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)});
    mockfs(testDir);
    expect(() => treeMerger.rebuild(treeDiffer.diffTrees())).toThrow();
  });
开发者ID:Mariem-07,项目名称:angular,代码行数:20,代码来源:broccoli-merge-trees.spec.ts


示例8: it

  it('should throw if duplicates are found during rebuild', () => {
    let testDir: any = {
      'tree1': {'foo.js': mockfs.file({content: 'tree1/foo.js content', mtime: new Date(1000)})},
      'tree2': {},
      'tree3': {}
    };
    mockfs(testDir);

    let treeDiffer = MakeTreeDiffers(['tree1', 'tree2', 'tree3']);
    let treeMerger = mergeTrees(['tree1', 'tree2', 'tree3'], 'dest', {});
    expect(() => treeMerger.rebuild(diffTrees(treeDiffer))).not.toThrow();


    testDir.tree2['foo.js'] = mockfs.file({content: 'tree2/foo.js content', mtime: new Date(1000)});
    mockfs(testDir);
    expect(() => treeMerger.rebuild(diffTrees(treeDiffer)))
        .toThrowError(
            'Duplicate path found while merging trees. Path: "foo.js".\n' +
            'Either remove the duplicate or enable the "overwrite" option for this merge.');
  });
开发者ID:KarthiTrichy20,项目名称:angular,代码行数:20,代码来源:broccoli-merge-trees.spec.ts


示例9: beforeEach

        beforeEach(()=>{
            mock({
                '/data': {
                    'foo.json': mock.file({
                        content: `{
    "this":"is mock file",
    "that":"is my cat"
}`,
                        mtime,
                    }),
                    'bar.yaml': mock.file({
                        content: `cat:
  name: 三毛猫
  hp: 300
  attack: 50
`,
                        mtime: new Date(mtime.getTime()-7200000),
                    }),
                },
            });
        });
开发者ID:uhyo,项目名称:my-load-data,代码行数:21,代码来源:loader.spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mock-fs.fs函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mock-fs.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap