-
Notifications
You must be signed in to change notification settings - Fork 1
/
Pub.spec.js
132 lines (84 loc) · 3.72 KB
/
Pub.spec.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* @package omeka
* @subpackage neatline-Waypoints
* @copyright 2012 Rector and Board of Visitors, University of Virginia
* @license http://www.apache.org/licenses/LICENSE-2.0.html
*/
describe('Neatline | Publications', function() {
var vent, model1, model2, row1, row2, fixtures = {
records: readFixtures('NeatlineEvents.json')
};
beforeEach(function() {
WP.loadNeatline();
WP.respondWaypoints200(fixtures.records);
model1 = WP.getWidgetModelByTitle('title1');
model2 = WP.getWidgetModelByTitle('title2');
row1 = WP.getWidgetRowByTitle('title1');
row2 = WP.getWidgetRowByTitle('title2');
vent = spyOn(Neatline.vent, 'trigger').and.callThrough();
});
describe('highlight', function() {
it('should publish `highlight` on record hover', function() {
// ----------------------------------------------------------------------
// When the cursor enters a waypoint, the `highlight` event should be
// published with the corresponding model.
// ----------------------------------------------------------------------
row1.trigger('mouseenter')
expect(vent).toHaveBeenCalledWith('highlight', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
});
});
describe('unhighlight', function() {
it('should publish `unhighlight` on record hover', function() {
// ----------------------------------------------------------------------
// When the cursor leaves a waypoint, the `unhighlight` event should be
// published with the corresponding model.
// ----------------------------------------------------------------------
row1.trigger('mouseleave')
expect(vent).toHaveBeenCalledWith('unhighlight', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
});
});
describe('select/unselect', function() {
it('should publish `select` on record click', function() {
// ----------------------------------------------------------------------
// When a waypoint is clicked, the `select` event should be published
// with the corresponding model.
// ----------------------------------------------------------------------
row1.trigger('click')
expect(vent).toHaveBeenCalledWith('select', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
});
it('should unselect currently-selected model', function() {
// ----------------------------------------------------------------------
// If another model is currently selected, it should be unselected.
// ----------------------------------------------------------------------
row1.trigger('click');
row2.trigger('click');
expect(vent).toHaveBeenCalledWith('unselect', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
});
it('should unselect (not re-select) on click-off', function() {
// ----------------------------------------------------------------------
// When a waypoint is clicked off (clicked again when it is already
// selected) the listing should just be unselected, as opposed to being
// immediately re-selected as the new selection.
// ----------------------------------------------------------------------
row1.trigger('click');
vent.calls.reset();
row1.trigger('click');
// Should unselect.
expect(vent).toHaveBeenCalledWith('unselect', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
// Should not re-select.
expect(vent).not.toHaveBeenCalledWith('select', {
model: model1, source: Neatline.Waypoints.__controller.slug
});
});
});
});