From 8e6b91eb56b074e3c525f51f089b2599eac2e509 Mon Sep 17 00:00:00 2001 From: Theodor Diaconu Date: Fri, 30 Mar 2018 07:41:08 +0300 Subject: [PATCH] increase time to wait for queries --- lib/query/testing/link-cache/server.test.js | 139 ++++++++++---------- 1 file changed, 72 insertions(+), 67 deletions(-) diff --git a/lib/query/testing/link-cache/server.test.js b/lib/query/testing/link-cache/server.test.js index b081cdb..b2ee2c7 100644 --- a/lib/query/testing/link-cache/server.test.js +++ b/lib/query/testing/link-cache/server.test.js @@ -1,23 +1,29 @@ import './fixtures'; -import {createQuery} from 'meteor/cultofcoders:grapher'; -import {Authors, AuthorProfiles, Groups, Posts, Categories} from './collections'; +import { createQuery } from 'meteor/cultofcoders:grapher'; +import { + Authors, + AuthorProfiles, + Groups, + Posts, + Categories, +} from './collections'; -describe('Query Link Denormalization', function () { +describe('Query Link Denormalization', function() { // fixtures run in Meteor.startup() // wait for them to load first - Meteor._sleepForMs(5000); + Meteor._sleepForMs(10000); - it('Should not cache work with nested options', function () { + it('Should not cache work with nested options', function() { let query = Posts.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, author: { - $options: {limit: 1}, + $options: { limit: 1 }, name: 1, - } + }, }); let insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -25,16 +31,16 @@ describe('Query Link Denormalization', function () { assert.isTrue(insideFind); }); - it('Should work properly - One Direct', function () { + it('Should work properly - One Direct', function() { let query = Posts.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, author: { name: 1, - } + }, }); let insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -52,11 +58,11 @@ describe('Query Link Denormalization', function () { author: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -66,16 +72,16 @@ describe('Query Link Denormalization', function () { unstubFind(Authors); }); - it('Should work properly - One Inversed', function () { + it('Should work properly - One Inversed', function() { let query = Authors.createQuery({ - $options: {limit: 2}, + $options: { limit: 2 }, posts: { title: 1, - } + }, }); let insideFind = false; - stubFind(Posts, function () { + stubFind(Posts, function() { insideFind = true; }); @@ -91,15 +97,15 @@ describe('Query Link Denormalization', function () { // now that we specify an additional field, it should bypass the cache query = Authors.createQuery({ - $options: {limit: 2}, + $options: { limit: 2 }, posts: { title: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Posts, function () { + stubFind(Posts, function() { insideFind = true; }); @@ -109,18 +115,18 @@ describe('Query Link Denormalization', function () { unstubFind(Posts); }); - it('Should work properly - One Meta Direct', function () { + it('Should work properly - One Meta Direct', function() { // console.log(Authors.find().fetch()); let query = Authors.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, profile: { name: 1, - } + }, }); let insideFind = false; - stubFind(AuthorProfiles, function () { + stubFind(AuthorProfiles, function() { insideFind = true; }); @@ -134,15 +140,15 @@ describe('Query Link Denormalization', function () { // now that we specify an additional field, it should bypass the cache query = Authors.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, profile: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(AuthorProfiles, function () { + stubFind(AuthorProfiles, function() { insideFind = true; }); @@ -152,17 +158,16 @@ describe('Query Link Denormalization', function () { unstubFind(AuthorProfiles); }); - - it('Should work properly - One Meta Inversed', function () { + it('Should work properly - One Meta Inversed', function() { let query = AuthorProfiles.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, author: { name: 1, - } + }, }); let insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -176,15 +181,15 @@ describe('Query Link Denormalization', function () { // now that we specify an additional field, it should bypass the cache query = AuthorProfiles.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, author: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -194,16 +199,16 @@ describe('Query Link Denormalization', function () { unstubFind(Authors); }); - it('Should work properly - Many Direct', function () { + it('Should work properly - Many Direct', function() { let query = Authors.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, groups: { name: 1, - } + }, }); let insideFind = false; - stubFind(Groups, function () { + stubFind(Groups, function() { insideFind = true; }); @@ -218,15 +223,15 @@ describe('Query Link Denormalization', function () { unstubFind(Groups); query = Authors.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, groups: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Groups, function () { + stubFind(Groups, function() { insideFind = true; }); @@ -236,16 +241,16 @@ describe('Query Link Denormalization', function () { unstubFind(Groups); }); - it('Should work properly - Many Inversed', function () { + it('Should work properly - Many Inversed', function() { let query = Groups.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, authors: { name: 1, - } + }, }); let insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -260,15 +265,15 @@ describe('Query Link Denormalization', function () { unstubFind(Authors); query = Groups.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, authors: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Authors, function () { + stubFind(Authors, function() { insideFind = true; }); @@ -278,18 +283,18 @@ describe('Query Link Denormalization', function () { unstubFind(Authors); }); - it('Should work properly - Many Meta Direct', function () { + it('Should work properly - Many Meta Direct', function() { // console.log(Posts.find({}, {limit: 2}).fetch()); let query = Posts.createQuery({ - $options: {limit: 5}, + $options: { limit: 5 }, categories: { name: 1, - } + }, }); let insideFind = false; - stubFind(Categories, function () { + stubFind(Categories, function() { insideFind = true; }); @@ -308,11 +313,11 @@ describe('Query Link Denormalization', function () { categories: { name: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Categories, function () { + stubFind(Categories, function() { insideFind = true; }); @@ -322,16 +327,16 @@ describe('Query Link Denormalization', function () { unstubFind(Categories); }); - it('Should work properly - Many Meta Inversed', function () { + it('Should work properly - Many Meta Inversed', function() { let query = Categories.createQuery({ - $options: {limit: 2}, + $options: { limit: 2 }, posts: { title: 1, - } + }, }); let insideFind = false; - stubFind(Posts, function () { + stubFind(Posts, function() { insideFind = true; }); @@ -347,15 +352,15 @@ describe('Query Link Denormalization', function () { // now that we specify an additional field, it should bypass the cache query = Categories.createQuery({ - $options: {limit: 2}, + $options: { limit: 2 }, posts: { title: 1, createdAt: 1, - } + }, }); insideFind = false; - stubFind(Posts, function () { + stubFind(Posts, function() { insideFind = true; }); @@ -372,12 +377,12 @@ function stubFind(collection, callback) { collection.oldAggregate = collection.aggregate.bind(collection); } - collection.find = function () { + collection.find = function() { callback(); return this.oldFind.apply(collection, arguments); }.bind(collection); - collection.aggregate = function () { + collection.aggregate = function() { callback(); return this.oldAggregate.apply(collection, arguments); }.bind(collection); @@ -389,4 +394,4 @@ function unstubFind(collection) { delete collection.oldFind; delete collection.oldAggregate; -} \ No newline at end of file +}