-
Notifications
You must be signed in to change notification settings - Fork 1
/
seeder-tests.js
68 lines (59 loc) · 1.27 KB
/
seeder-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Items = new Mongo.Collection('items');
Children = new Mongo.Collection('children');
Children.attachSchema(new SimpleSchema({
title: {
type: String,
max: 15,
seeder: 'lorem.sentence'
}
}));
Items.attachSchema(new SimpleSchema({
title: {
type: String,
max: 20,
seeder: 'lorem.sentence'
},
color: {
type: String,
seeder: 'internet.color'
},
rating: {
type: Number,
max: 30
},
active: {
type: Boolean,
defaultValue: true
},
createdAt: {
type: Date
},
updatedAt: {
type: [Date]
},
baby: {
type: String,
seeder: Children
}
}));
Tinytest.add('Seeder - Creates Expected Number of Entries', function (test) {
new Seeder({
collection: Items,
total: 5
});
var count = Items.find().count();
test.equal(count, 5);
test.equal(Children.find().count(), 5);
var oneItem = Items.findOne(),
oneChild = Children.findOne(oneItem.baby);
test.equal(oneItem.baby, oneChild._id);
Items.remove({});
Children.remove({});
});
Tinytest.add('Seeder - Throws error if config is wrong', function (test) {
test.throws(function () {
new Seeder({
total: 5
});
}, Meteor.Error);
});