-
Notifications
You must be signed in to change notification settings - Fork 1
/
Open.spec.js
119 lines (79 loc) · 3.5 KB
/
Open.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
/**
* @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('Editor | Open Form', function() {
var rows, fixtures = {
regular: readFixtures('EditorForm.regular.json'),
empty: readFixtures('EditorForm.empty.json')
};
beforeEach(function() {
WP.loadEditor();
});
describe('when waypoints exist', function() {
beforeEach(function() {
WP.showForm(fixtures.regular);
rows = WP.getEditorRows();
});
it('should display waypoints', function() {
// ----------------------------------------------------------------------
// When the "Waypoints" tab is activated, the "Edit Waypoint Order" list
// should be populated with records.
// ----------------------------------------------------------------------
expect($(rows[0])).toHaveText('title1');
expect($(rows[1])).toHaveText('title2');
expect($(rows[2])).toHaveText('title3');
expect(rows.length).toEqual(3);
});
it('should enable the "Save" button', function() {
// ----------------------------------------------------------------------
// If the "Save" button was previously disabled in response to an empty
// collection of waypoints, it should be re-enabled if records have been
// added to the widget since the last form open.
// ----------------------------------------------------------------------
WP.showForm(fixtures.empty);
WP.showForm(fixtures.regular);
expect(WP.v.editor.__ui.save).not.toHaveClass('disabled');
});
it('should enable sorting', function() {
// ----------------------------------------------------------------------
// The records under "Edit Waypoint Order" should be sortable.
// ----------------------------------------------------------------------
expect(
WP.v.editor.__ui.list.sortable('option', 'disabled')
).toBeFalsy();
});
});
describe('when waypoints do not exist', function() {
beforeEach(function() {
WP.showForm(fixtures.empty);
rows = WP.getEditorRows();
});
it('should display a placeholder row', function() {
// ----------------------------------------------------------------------
// A placeholder message saying that no waypoints have been added should
// be displayed under "Edit Waypoint Order."
// ----------------------------------------------------------------------
// Placeholder text.
var empty = Neatline.g.waypoints.strings.order.placeholders.empty;
expect($(rows[0])).toHaveText(empty);
// No waypoints listed.
expect(rows.length).toEqual(1);
});
it('should disable the "Save" button', function() {
// ----------------------------------------------------------------------
// The "Save" button should be disabled.
// ----------------------------------------------------------------------
expect(WP.v.editor.__ui.save).toHaveClass('disabled');
});
it('should not make waypoints sortable', function() {
// ----------------------------------------------------------------------
// The row with the placeholder message should not be sortable.
// ----------------------------------------------------------------------
var cantSort = WP.v.editor.__ui.list.sortable('option', 'disabled');
expect(cantSort).toBeTruthy();
});
});
});