-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathfield-input-tests.js
48 lines (37 loc) · 1.49 KB
/
field-input-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
Tinytest.addAsync('EasySearch Components - Unit - FieldInput', function (test, done) {
let index = new EasySearch.Index({
collection: new Mongo.Collection(null),
engine: new EasySearch.Minimongo(),
fields: ['test'],
allowedFields: ['test', 'name', 'score']
});
let component = TestHelpers.createComponent(EasySearch.FieldInputComponent, {
field: 'name',
indexes: [index]
});
let componentTwo = TestHelpers.createComponent(EasySearch.FieldInputComponent, {
field: 'score',
indexes: [index]
});
component.onCreated();
test.equal(EasySearch.InputComponent.defaultAttributes, { type: 'text', value: '' });
test.equal(component.inputAttributes(), { type: 'text', value: '' });
test.equal(component.options, { timeout: 50, field: 'name', charLimit: 0, matchAll: 1, autoSearch: 1 });
test.equal(_.first(component.dicts).get('searchDefinition'), { name: '' });
test.isFalse(_.first(component.dicts).get('searching'));
component.debouncedSearch('Peter');
component.debouncedSearch('Hans');
test.equal(_.first(component.dicts).get('searchDefinition'), { name: '' });
componentTwo.onCreated();
componentTwo.debouncedSearch('200');
Meteor.setTimeout(function () {
test.equal(_.first(component.dicts).get('searchDefinition'), { name: 'Hans', score: '200' });
done();
}, 300);
test.throws(function () {
let component = TestHelpers.createComponent(EasySearch.FieldInputComponent, {
indexes: [index]
});
component.onCreated();
});
});