Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe("Holograph", function() {
mock({
'holograph': mock.directory({
mode: '0700',
uid: 1,
gid: 1,
items: {
'index.html': "Hello, world!"
}
})
});
describe("Setup", function() {
it("errs when the build destination cannot be removed", function(done) {
h.holograph({ destination: "./holograph" }, function(err) {
expect(err).to.be.an('error');
expect(err.message).to.have.string('EACCES');
done();
});
function mockFs() {
mock({
[testDir]: {
[showFolder]: mock.directory({
birthtime: pastDate,
items: {
[showFile1]: f(pastDate),
[showFile2]: f(pastDate),
[showFile3]: f(pastDate),
[showFile4]: f(pastDate)
}
}),
[movieFolder]: mock.directory({
birthtime: nearestDate,
items: {
[movieFile]: f(nearestDate)
}
})
}
});
}
beforeEach(() => {
mockFs({
'/data': {
'protected.keystore': protoctedKeystoreData,
'unprotected.keystore': unprotectedKeystoreData,
},
'/inaccessible': mockFs.directory({
mode: '0000',
})
});
});
beforeEach(() => {
var fsTree = {};
fsTree[os.tmpdir()] = mockFs.directory();
mockFs(fsTree);
});
it ('complains when provided with an a path to a file that can\'t be overwritten', () => {
mockfs({ '/sys': mockfs.directory({
mode: 400,
items: {
'file.json': mockfs.file({
mode: 400,
content: '',
}),
},
})});
const out = new FileSystem('/sys');
const path = isWinOS() ? '\\\\?\\C:\\sys\\file.json' : '/sys/file.json';
return expect(out.store('file.json', JSON.stringify(originalJSON)))
.to.be.eventually.rejectedWith(`EACCES, permission denied \'${path}\'`);
});
});
it ('complains when provided with an a path to a file that can\'t be overwritten', () => {
mockfs({ '/sys': mockfs.directory({
mode: 400,
items: {
'file.json': mockfs.file({
mode: 400,
content: '',
}),
},
})});
let out = new FileSystem('/sys');
return expect(out.store('file.json', JSON.stringify(originalJSON)))
.to.be.eventually.rejectedWith('EACCES, permission denied \'/sys/file.json\'');
});
});