it('can compile a number matcher', () => { let match = compileMatcher(3); let ctx = new Context(); assert.ok(match(3, ctx)); assert.notOk(match(1, ctx)); assert.notOk(match('3', ctx)); });
it('can compile a string matcher', () => { let match = compileMatcher('5'); let ctx = new Context(); assert.ok(match('5', ctx)); assert.notOk(match('hello', ctx)); assert.notOk(match(5, ctx)); });
it('can compile a null matcher', () => { let match = compileMatcher(null); let ctx = new Context(); assert.ok(match(null, ctx)); assert.notOk(match(undefined, ctx)); assert.notOk(match(false, ctx)); });
it('can compile a boolean matcher', () => { let match = compileMatcher(false); let ctx = new Context(); assert.ok(match(false, ctx)); assert.notOk(match(true, ctx)); assert.notOk(match(null, ctx)); });
it("should delete data without a callback", async () => { let result = await bucket.get(key); assert.deepEqual(result, value); await bucket.del(key); result = await bucket.get(key); assert.notOk(result); });
it("getdel()", async () => { await bucket.set(key, value); let result = await bucket.getdel(key); assert.deepEqual(value, result); result = await bucket.get(key); assert.notOk(result); });
it('exposes simple bindings', () => { let context = new Context(); assert.ok(context.bind('foo', 1)); assert.ok(context.bind('foo', 1)); assert.notOk(context.bind('foo', 2)); assert.deepEqual(flattenPrototype(context.expose()), { foo: 1 }); });
it('returns nothing when the store is enough', () => { const query = gql` { people_one(id: "1") { name } } `; const result = { people_one: { name: 'Luke Skywalker', }, }; const store = writeQueryToStore({ result, query, }); assert.notOk(diffQueryAgainstStore({ store, query, }).isMissing); });
function assertNoMatch(matcher: (key: string) => Matcher, node: any) { let context = new Context(); assert.notOk(matcher('binding')(node, context)); let env = flattenPrototype(context.expose()); assert.deepEqual(env, {}); }
it('attempts to establish the number of processors', () => { assert.equal(subject.processorCount, 8); delete global['navigator'].hardwareConcurrency; subject = new UserEnvironment(); assert.notOk(subject.processorCount); });