Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
this.fs = memfs;
// define /tmp/ dir
vol.fromJSON({ ".stub": "" }, "/tmp/");
}
it('should escape `', () => {
vol.fromJSON({ '/a': 'Hello, `${foo}`!' });
const fn = () => core.applyTemplate('/a', { foo: 'Bar' });
expect(fn).not.toThrowError();
const result = fn();
expect(result).toBe('Hello, `Bar`!');
});
it("returns null on non-urls", async function() {
vol.fromJSON({
"./relative/path.file": "wrong",
});
expect(await instance("relative/path.file", defaultContext())).toBeNull();
});
it('save() should update file', () => {
vol.fromJSON(json);
yaml(filename)
.set('foo', 1)
.save();
expect(vol.toJSON()).toMatchSnapshot();
});
it('should load the default role file if one exists', async () => {
vol.fromJSON({
[Filepathes.namespaceDefaultRolePath]: 'foobar',
});
await namespaceCreateCommand.handler({ name: 'ns3' } as any);
expect((prompt as any as jest.Mock).mock.calls[0][0].map((q: any) => q.default)[2]).toBe('foobar');
});
it('should return list of sections', () => {
vol.fromJSON(json);
const file = ini(filename);
expect(file.get()).toEqual(['foo']);
});
export function mockFs(_layout: FsLayout) {
(process.env.MEMFS_DONT_WARN as any) = true;
layout = _layout;
vol.fromJSON(flattenLayout(_layout));
}
beforeEach(() => {
vol.fromJSON({
[posix.join(Filepathes.kubectlInstallPath, 'v1.12.1', 'kubectl')]: 'kubectl',
[posix.join(Filepathes.kubectlInstallPath, 'v1.12.2', 'kubectl')]: 'kubectl',
[posix.join(Filepathes.kubectlInstallPath, 'v1.10.0', 'kubectl')]: 'kubectl',
[posix.join(Filepathes.kubectlInstallPath, 'v1.8.4', 'kubectl')]: 'kubectl',
});
vol.mkdirpSync('/usr/local/bin/');
vol.symlinkSync(posix.join(Filepathes.kubectlInstallPath, 'v1.10.0', 'kubectl'), '/usr/local/bin/kubectl');
});
it.each(data)("%s", async function(message, testFs, input, cwd, provider) {
const EXPECTED_FILES = expectedOutput(testFs, provider, cwd);
vol.fromJSON(testFs);
const fileList = await gatherSources(input, cwd, resolver);
expect(fileList.sort((a, b) => a.url.localeCompare(b.url))).toEqual(
EXPECTED_FILES.sort((a, b) => a.url.localeCompare(b.url)),
);
});
beforeEach(() => {
vol.fromJSON(
{
'./README.md': 'hello',
'./.nxignore': stripIndents`
apps/demo/tmp.txt
tmp/
`,
'./.gitignore': stripIndents`
*.js
node_modules/
`,
'./apps/demo/src/index.ts': 'console.log("hello");',
'./apps/demo/tmp.txt': '...',
'./apps/demo/tmp.js': 'console.log("tmp")',
'./workspace.json': '{}'
},
'/root'