mirror of
https://github.com/vale981/grapher
synced 2025-03-05 17:41:41 -05:00
Fixtures for denormalization created on before event in tests instead in Meteor.startup
This commit is contained in:
parent
430fdfedbf
commit
0b27dd411a
2 changed files with 21 additions and 21 deletions
34
lib/query/testing/link-cache/fixtures.js
Normal file → Executable file
34
lib/query/testing/link-cache/fixtures.js
Normal file → Executable file
|
@ -10,7 +10,7 @@ export let groupIds = [];
|
||||||
export let authorIds = [];
|
export let authorIds = [];
|
||||||
export let postIds = [];
|
export let postIds = [];
|
||||||
|
|
||||||
Meteor.startup(() => {
|
export default function createFixtures() {
|
||||||
for (let i = 0; i < CATEGORIES; i++) {
|
for (let i = 0; i < CATEGORIES; i++) {
|
||||||
const categoryId = Categories.insert({
|
const categoryId = Categories.insert({
|
||||||
name: `Category ${i}`
|
name: `Category ${i}`
|
||||||
|
@ -53,25 +53,25 @@ Meteor.startup(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function createPost(authorId) {
|
function createPost(authorId) {
|
||||||
const postId = Posts.insert({
|
const postId = Posts.insert({
|
||||||
title: `Post ${postIds.length}`,
|
title: `Post ${postIds.length}`,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
postIds.push(postId);
|
postIds.push(postId);
|
||||||
|
|
||||||
const authorLink = Posts.getLink(postId, 'author');
|
const authorLink = Posts.getLink(postId, 'author');
|
||||||
authorLink.set(authorId);
|
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');
|
const categoriesLink = Posts.getLink(postId, 'categories');
|
||||||
categoriesLink.add(randomCategoryId, {
|
categoriesLink.add(randomCategoryId, {
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return postId;
|
return postId;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
8
lib/query/testing/link-cache/server.test.js
Normal file → Executable file
8
lib/query/testing/link-cache/server.test.js
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
||||||
import './fixtures';
|
import createFixtures from './fixtures';
|
||||||
import { createQuery } from 'meteor/cultofcoders:grapher';
|
import { createQuery } from 'meteor/cultofcoders:grapher';
|
||||||
import {
|
import {
|
||||||
Authors,
|
Authors,
|
||||||
|
@ -9,9 +9,9 @@ import {
|
||||||
} from './collections';
|
} from './collections';
|
||||||
|
|
||||||
describe('Query Link Denormalization', function() {
|
describe('Query Link Denormalization', function() {
|
||||||
// fixtures run in Meteor.startup()
|
before(() => {
|
||||||
// wait for them to load first
|
createFixtures();
|
||||||
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({
|
let query = Posts.createQuery({
|
||||||
|
|
Loading…
Add table
Reference in a new issue