Fixtures for denormalization created on before event in tests instead in Meteor.startup

This commit is contained in:
Berislav 2018-06-12 10:24:53 +02:00
parent 430fdfedbf
commit 0b27dd411a
2 changed files with 21 additions and 21 deletions

4
lib/query/testing/link-cache/fixtures.js Normal file → Executable file
View file

@ -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,6 +53,7 @@ Meteor.startup(() => {
}
}
});
}
function createPost(authorId) {
const postId = Posts.insert({
@ -74,4 +75,3 @@ Meteor.startup(() => {
return postId;
}
});

8
lib/query/testing/link-cache/server.test.js Normal file → Executable file
View file

@ -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({