-
Notifications
You must be signed in to change notification settings - Fork 6
/
view-test.js
50 lines (43 loc) · 1.4 KB
/
view-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
module("View");
CKAN.UI.initialize()
test("DatasetSummaryView", function () {
var pkg = new CKAN.Model.Dataset(datasets[1]);
var view = new CKAN.View.DatasetSummaryView({
model: pkg
});
view.render();
var tmpl = $(view.el);
var title = tmpl.find('.title a').text();
equals(title, 'A Novel By Tolstoy');
});
test("DatasetFullView", function () {
var pkg = new CKAN.Model.Dataset(datasets[0]);
var $view = $('<div />').appendTo($('.fixture'));
var view = new CKAN.View.DatasetFullView({
el: $view,
model: pkg
});
view.render();
var tmpl = $(view.el);
$('.action-add-resource').click();
var out = tmpl.find('form.resource');
equals(out.length, 1, 'Did not find resource form');
tmpl.find('form input[name=Resource--url]').val('http://xyz.org');
tmpl.find('form.resource').submit();
equals(pkg.get('resources').length, 1);
var out = $view.find('.resources table tr:last td:first').text();
ok(out.indexOf('Download (no description)')!=-1, 'Did not find required string');
});
test("DatasetSearchView", function () {
var coll = new CKAN.Model.SearchCollection([]);
var searchView = new CKAN.View.DatasetSearchView({
el: $('#search-page'),
collection: coll
});
var pkg = new CKAN.Model.Dataset(datasets[1]);
coll.add(pkg);
searchView.addOne(pkg);
searchView.render();
var title = $('.datasets li .title a').text();
equals(title, 'A Novel By Tolstoy');
});