From 0b27dd411a8d3b827897ab7c413f9df3bd450523 Mon Sep 17 00:00:00 2001 From: Berislav Date: Tue, 12 Jun 2018 10:24:53 +0200 Subject: [PATCH] Fixtures for denormalization created on before event in tests instead in Meteor.startup --- lib/query/testing/link-cache/fixtures.js | 34 ++++++++++----------- lib/query/testing/link-cache/server.test.js | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) mode change 100644 => 100755 lib/query/testing/link-cache/fixtures.js mode change 100644 => 100755 lib/query/testing/link-cache/server.test.js diff --git a/lib/query/testing/link-cache/fixtures.js b/lib/query/testing/link-cache/fixtures.js old mode 100644 new mode 100755 index 8c1737b..0972799 --- a/lib/query/testing/link-cache/fixtures.js +++ b/lib/query/testing/link-cache/fixtures.js @@ -10,7 +10,7 @@ export let groupIds = []; export let authorIds = []; export let postIds = []; -Meteor.startup(() => { +export default function createFixtures() { for (let i = 0; i < CATEGORIES; i++) { const categoryId = Categories.insert({ name: `Category ${i}` @@ -53,25 +53,25 @@ Meteor.startup(() => { } } }); +} - function createPost(authorId) { - const postId = Posts.insert({ - title: `Post ${postIds.length}`, - createdAt: new Date(), - }); +function createPost(authorId) { + const postId = Posts.insert({ + title: `Post ${postIds.length}`, + createdAt: new Date(), + }); - postIds.push(postId); + postIds.push(postId); - const authorLink = Posts.getLink(postId, 'author'); - authorLink.set(authorId); + const authorLink = Posts.getLink(postId, 'author'); + authorLink.set(authorId); - const randomCategoryId = categoryIds[Math.floor(Math.random()*categoryIds.length)]; + const randomCategoryId = categoryIds[Math.floor(Math.random()*categoryIds.length)]; - const categoriesLink = Posts.getLink(postId, 'categories'); - categoriesLink.add(randomCategoryId, { - createdAt: new Date(), - }); + const categoriesLink = Posts.getLink(postId, 'categories'); + categoriesLink.add(randomCategoryId, { + createdAt: new Date(), + }); - return postId; - } -}); + return postId; +} diff --git a/lib/query/testing/link-cache/server.test.js b/lib/query/testing/link-cache/server.test.js old mode 100644 new mode 100755 index b2ee2c7..d49949a --- a/lib/query/testing/link-cache/server.test.js +++ b/lib/query/testing/link-cache/server.test.js @@ -1,4 +1,4 @@ -import './fixtures'; +import createFixtures from './fixtures'; import { createQuery } from 'meteor/cultofcoders:grapher'; import { Authors, @@ -9,9 +9,9 @@ import { } from './collections'; describe('Query Link Denormalization', function() { - // fixtures run in Meteor.startup() - // wait for them to load first - Meteor._sleepForMs(10000); + before(() => { + createFixtures(); + }); it('Should not cache work with nested options', function() { let query = Posts.createQuery({