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 allow passing through options", { skipIfBrowser: true }, () => {
const dom = new JSDOM(``, { runScripts: "outside-only" });
const script = new vm.Script("while(true) {}");
assert.throws(() => dom.runVMScript(script, { timeout: 50 }), /Script execution timed out(?: after 50ms|\.)/);
});
});
it("should support enum literals", () => {
const tt = createCheckers(sample, {
foo: t.enumlit("Direction", "Left"),
bar: t.enumlit("DirectionStr", "Right"),
});
tt.foo.check(17);
tt.bar.check("RIGHT");
assert.throws(() => tt.foo.check("Left"), /value is not Direction.Left/);
assert.throws(() => tt.foo.check(0), /value is not Direction.Left/);
assert.throws(() => tt.bar.check("LEFT"), /value is not DirectionStr.Right/);
assert.throws(() => tt.bar.check("Right"), /value is not DirectionStr.Right/);
assert.throws(() => createCheckers(sample, {foo: t.enumlit("Direction", "bad")}),
/Unknown value Direction.bad used in enumlit/);
assert.throws(() => createCheckers(sample, {foo: t.enumlit("MyType", "bad")}),
/Type MyType used in enumlit is not an enum type/);
assert.throws(() => createCheckers(sample, {foo: t.enumlit("Bad", "bad")}),
/Unknown type Bad/);
});
it('should check if logging dir exists', function(){
var manager = new Manager();
var newConfiguration = JSON.parse(JSON.stringify(configuration));
newConfiguration.processes[1].logRoot = 'bla';
assert.throws(function() { manager.deploy(newConfiguration); }, Error, /folder does not exist/);
});
it('should throw a TypeError if undefined is passed', function() {
assert.throws(
cint.intoString.bind(cint, undefined), 'undefined')
})
})
it('should throw exception for modifying created modules', () => {
const dep1 = () => ({ a: 1 });
const dep2 = ({ dep1 }) => noop(dep1);
const modules = deppie({ dep1, dep2 });
assert.throws(() => { modules.dep1 = {}; },
'modifying dependency'
);
});
});
it("Invalid SGF throws an error", function() {
assert.throws(function() {
node.innerSGF = "AW[fk]C[Cool!];W[hn]C";
}, SGFSyntaxError);
assert.throws(function() {
node.innerSGF = "AW[fk]C[Cool!];W[hn]C[)(])(;W[hm];)";
}, SGFSyntaxError);
assert.throws(function() {
node.innerSGF = "AW[fk]C[Cool!];W[hn]C[)(](;W[hm]";
}, SGFSyntaxError);
});
});
it("handles computation ending with `of`", () => {
const comp = wrapped1(3).chain((_n) => IO.of(4));
testIO(comp, [[wrapped1(3), 3]], 4);
assert.throws(() => {
testIO(comp, [[wrapped1(3), 3]], 5);
});
});
it("handles computation with map and chain", () => {
it('assign', function () {
var assign = require('../lib/common/utils').assign;
assert.deepEqual(assign({ a: 1 }, null, { b: 2 }), { a: 1, b: 2 });
assert.throws(function () {
assign({}, 123);
});
});
it('fail for strings', function() {
assert.throws(() => convert('data', { arr: { $size: 'abc' } }), '$size only supports positive integer')
})
it('fail for decimals', function() {
specify("Testing a node against a non node type throws an error", () => {
const doc = load("test");
assert.throws(doc.compareDocumentPosition.bind(this, {}));
});
});