How to use the memfs.vol.toJSON function in memfs

To help you get started, we’ve selected a few memfs 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 sapegin / mrm-core / src / formats / __tests__ / json.spec.js View on Github external
it('should keep comments', () => {
		vol.fromJSON({ '/test.json': '{\n// pizza\n"bar": 42\n/* pasta */ }' });
		json(filename)
			.set('bar', 43)
			.save();
		expect(vol.toJSON()[filename]).toMatchSnapshot();
	});
github smartive / kuby / test / commands / kubectl / kubectl.utils.kubectl.spec.ts View on Github external
it('should create the installation dir if it does not exist', async () => {
      await Helpers.getLocalVersions();
      expect(Object.keys(vol.toJSON())).toContain(Filepathes.kubectlInstallPath);
    });
github sapegin / mrm-core / src / formats / __tests__ / json.spec.js View on Github external
it('should delete a file', () => {
		vol.fromJSON(fsJson);
		const file = json(filename);
		file.delete();
		expect(vol.toJSON()).toEqual({});
	});
});
github sapegin / mrm-core / src / __tests__ / core.spec.js View on Github external
it('should update a file', () => {
		const contents = 'test';
		vol.fromJSON({ '/a': contents });

		core.updateFile('/a', 'pizza', contents, true);

		expect(vol.toJSON()).toMatchSnapshot();
	});
github sapegin / mrm-core / src / formats / __tests__ / lines.spec.js View on Github external
it('should keep new line at the end of file', () => {
		vol.fromJSON({ '/new.lines': 'one\ntwo\n' });
		lines('/new.lines')
			.add(['foo', 'bar'])
			.save();
		expect(vol.toJSON()['/new.lines']).toMatch(/\n$/);
	});
github smartive / kuby / test / commands / kubectl / kubectl.utils.kubectl.spec.ts View on Github external
it('should download the remove versions and write them to the disk', async () => {
      const result = await Helpers.getRemoteVersions();
      expect(get).toHaveBeenCalled();
      expect(result).toEqual(['1.1.1', '2.2.2', '3.3.3']);
      expect((vol.toJSON() as any)[Filepathes.kubectlVersionsPath]).toEqual(`["1.1.1","2.2.2","3.3.3"]${EOL}`);
    });
  });
github sapegin / mrm-core / src / __tests__ / fs.spec.js View on Github external
it('should update a file', () => {
		vol.fromJSON({ '/a': 'test' });

		updateFile('/a', 'pizza', true);

		expect(vol.toJSON()).toMatchSnapshot();
	});
github sapegin / mrm-core / src / files / __tests__ / packageJson.spec.js View on Github external
it('should create package.json file', () => {
		packageJson().save();
		expect(vol.toJSON()).toMatchSnapshot();
	});
github sapegin / mrm-core / src / formats / __tests__ / lines.spec.js View on Github external
it('should delete a file', () => {
		vol.fromJSON(json);
		const file = lines(filename);
		file.delete();
		expect(vol.toJSON()).toEqual({});
	});
});
github smartive / kuby / test / commands / prepare / prepare.spec.ts View on Github external
{
        './source/foo.yml': '',
        './source/bar.yaml': '',
        './source/blub/whatever.yml': '',
        './source/blub/iaml.yaml': '',
      },
      process.cwd(),
    );
    await prepareCommand.handler({
      sourceFolder: './source',
      destinationFolder: './destination',
    } as any);
    expect(Object.keys(vol.toJSON())).toContain(posix.join(process.cwd(), 'destination', 'bar.yaml'));
    expect(Object.keys(vol.toJSON())).toContain(posix.join(process.cwd(), 'destination', 'foo.yml'));
    expect(Object.keys(vol.toJSON())).toContain(posix.join(process.cwd(), 'destination', 'blub-whatever.yml'));
    expect(Object.keys(vol.toJSON())).toContain(posix.join(process.cwd(), 'destination', 'blub-iaml.yaml'));
  });
});