Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
it('should create the installation dir if it does not exist', async () => {
await Helpers.getLocalVersions();
expect(Object.keys(vol.toJSON())).toContain(Filepathes.kubectlInstallPath);
});
it('should delete a file', () => {
vol.fromJSON(fsJson);
const file = json(filename);
file.delete();
expect(vol.toJSON()).toEqual({});
});
});
it('should update a file', () => {
const contents = 'test';
vol.fromJSON({ '/a': contents });
core.updateFile('/a', 'pizza', contents, true);
expect(vol.toJSON()).toMatchSnapshot();
});
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$/);
});
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}`);
});
});
it('should update a file', () => {
vol.fromJSON({ '/a': 'test' });
updateFile('/a', 'pizza', true);
expect(vol.toJSON()).toMatchSnapshot();
});
it('should create package.json file', () => {
packageJson().save();
expect(vol.toJSON()).toMatchSnapshot();
});
it('should delete a file', () => {
vol.fromJSON(json);
const file = lines(filename);
file.delete();
expect(vol.toJSON()).toEqual({});
});
});
{
'./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'));
});
});