How to use the mock-fs.symlink function in mock-fs

To help you get started, we’ve selected a few mock-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / angular / tools / broccoli / tree-differ.spec.ts View on Github external
it('should handle changes via symbolic links', () => {
      let testDir = {
        'orig_path': {
          '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)})
          }
        },
        'symlinks': {
          'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
          'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
          'subdir-1':
              {'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
        }
      };
      mockfs(testDir);

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

      let diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual([
        'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
      ]);

      // change two files
      testDir['orig_path']['file-1.txt'] =
github angular / angular / tools / broccoli / tree-differ.spec.ts View on Github external
it('should handle changes via symbolic links', () => {
      let testDir = {
        'orig_path': {
          '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)})
          }
        },
        'symlinks': {
          'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
          'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
          'subdir-1':
              {'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
        }
      };
      mockfs(testDir);

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

      let diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual([
        'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
      ]);

      // change two files
      testDir['orig_path']['file-1.txt'] =
          mockfs.file({content: 'new content', mtime: new Date(1000)});
      testDir['orig_path']['subdir-1']['file-1.1.txt'] =
github angular / angular / tools / broccoli / tree-differ.spec.ts View on Github external
it('should handle changes via symbolic links', () => {
      let testDir = {
        'orig_path': {
          '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)})
          }
        },
        'symlinks': {
          'file-1.txt': mockfs.symlink({path: '../orig_path/file-1.txt'}),
          'file-2.txt': mockfs.symlink({path: '../orig_path/file-2.txt'}),
          'subdir-1':
              {'file-1.1.txt': mockfs.symlink({path: '../../orig_path/subdir-1/file-1.1.txt'})}
        }
      };
      mockfs(testDir);

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

      let diffResult = differ.diffTree();

      expect(diffResult.addedPaths).toEqual([
        'file-1.txt', 'file-2.txt', 'subdir-1' + path.sep + 'file-1.1.txt'
      ]);

      // change two files
github adogor / npm-autolink / test / linkModules.js View on Github external
it('if the module was already linked, the link should be replaced', () => {
    utils.init(modules).with({
      '/moduleTmp': {
        'package.json': {
          'name': 'module3',
          'version': '0.5.0'
        }
      },
      '/var/module1': {
        'package.json': {
          dependencies: {
            'module3': '0.3.0'
          }
        },
        'node_modules': {
          'module3': mockFs.symlink({
            path: '/moduleTmp'
          })
        }
      }
    }).withCwd('/var/module1').apply();
    expect(fs.readJsonSync('/var/module1/node_modules/module3/package.json')).to.have.property('version', '0.5.0');
    return autoLink.linkModules('module3').then(() => {
      expect(fs.readdirSync('/var/module1/node_modules')).to.have.all.members(['module3']);
      expect(fs.readJsonSync('/var/module1/node_modules/module3/package.json')).to.have.property('version', '0.3.0');
    });
  });
github adogor / npm-autolink / test / removeLinks.js View on Github external
},
      '/moduleTmp2': {
        'package.json': {
          name: '@test/module2',
          version: '0.2.0'
        }
      },
      '/var/module1': {
        'package.json': {
          dependencies: {
            'module3': '0.3.0',
            '@test/module2': '*'
          }
        },
        'node_modules': {
          'module3': mockFs.symlink({
            path: '/moduleTmp'
          }),
          '@test': {
            'module2': mockFs.symlink({
              path: '/moduleTmp2'
            }),
          }
        }
      }
    }).withCwd('/var/module1').apply();
  })
github nicksrandall / inquirer-directory / test / spec / index.spec.js View on Github external
before(function () {
    mock({
      '.git': {},
      'folder1': {
        'folder1-1': {}
      },
      'zfolder2': {},
      'some.png': new Buffer([8, 6, 7, 5, 3, 0, 9]),
      'a-symlink': mock.symlink({
        path: 'folder1'
      })
    });
  });
github ramhejazi / draxt / test / interfaces / Node.js View on Github external
beforeEach(function() {
			mockFs({
				'/fake_dir': {
					'example_file.md': 'example content.',
					'another_example_file.md': 'example content.',
					'another_dir': {
						'a.js': '...',
						'b.js': '...',
						'c.php': '...',
						'k.php': '...',
						'd.html': '...',
						'g.md':  mockFs.symlink({
							path: '/fake_dir/example_file.md'
						}),
						'README.md': '...',
						'document.txt': '...',
						'.dir': {},
						'foo.rb': '...'
					},
				}
			});
		});
github ramhejazi / draxt / test / drakht.js View on Github external
beforeEach(function() {
		mockFs({
			'/fake_dir': {
				'example_file.md': 'example content.',
				'another_example_file.md': 'example content.',
				'another_dir': {
					'a.js': '...',
					'b.md': mockFs.symlink({
						path: '/fake_dir/another_example_file.md'
					})
				},
			}
		}, { createCwd: false });
	});
github adogor / npm-autolink / test / removeLinks.js View on Github external
version: '0.2.0'
        }
      },
      '/var/module1': {
        'package.json': {
          dependencies: {
            'module3': '0.3.0',
            '@test/module2': '*'
          }
        },
        'node_modules': {
          'module3': mockFs.symlink({
            path: '/moduleTmp'
          }),
          '@test': {
            'module2': mockFs.symlink({
              path: '/moduleTmp2'
            }),
          }
        }
      }
    }).withCwd('/var/module1').apply();
  })

mock-fs

A configurable mock file system. You know, for testing.

MIT
Latest version published 21 days ago

Package Health Score

83 / 100
Full package analysis