-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterestCollection.test.js
51 lines (44 loc) · 1.84 KB
/
InterestCollection.test.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
import { Interests } from '/imports/api/interest/InterestCollection';
import { Meteor } from 'meteor/meteor';
import { expect } from 'chai';
import { removeAllEntities } from '/imports/api/base/BaseUtilities';
/* eslint prefer-arrow-callback: "off", no-unused-expressions: "off" */
/* eslint-env mocha */
if (Meteor.isServer) {
describe('InterestCollection', function testSuite() {
const name = 'Software Engineering';
const description = 'Tools and techniques for team-based development of high quality software systems';
const defineObject = { name, description };
before(function setup() {
removeAllEntities();
});
after(function teardown() {
removeAllEntities();
});
it('#define, #isDefined, #removeIt, #dumpOne, #restoreOne', function test() {
let docID = Interests.define(defineObject);
expect(Interests.isDefined(docID)).to.be.true;
// Check that fields are available
const doc = Interests.findDoc(docID);
expect(doc.name).to.equal(name);
expect(doc.description).to.equal(description);
// Check that multiple definitions with the same name fail
expect(function foo() { Interests.define(defineObject); }).to.throw(Error);
// Check that we can dump and restore a Interest.
const dumpObject = Interests.dumpOne(docID);
Interests.removeIt(docID);
expect(Interests.isDefined(docID)).to.be.false;
docID = Interests.restoreOne(dumpObject);
expect(Interests.isDefined(docID)).to.be.true;
Interests.removeIt(docID);
});
it('#findID, #findIDs', function test() {
const docID = Interests.define(defineObject);
expect(Interests.isDefined(docID)).to.be.true;
const docID2 = Interests.findID(name);
expect(docID).to.equal(docID2);
Interests.findIDs([name, name]);
Interests.removeIt(docID);
});
});
}