forked from simme/ampersand-modal-view
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
50 lines (43 loc) · 1.09 KB
/
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
var test = require('tape');
var View = require('ampersand-view');
var select = require('dom-select');
var ModalView;
test("should require module", function (t) {
ModalView = require('./');
t.ok(ModalView);
t.end();
});
test("should open simple modal in body", function (t) {
// body
var BodyView = View.extend({
autoRender: true,
template: [
'<div class="body-view-test">',
'body',
'</div>',
].join(''),
});
var bodyView = new BodyView();
// footer
var FooterView = View.extend({
autoRender: true,
template: [
'<div class="footer-view-test">',
'footer',
'</div>',
].join(''),
});
var footerView = new FooterView();
var modal = new ModalView({
title: "Test Modal",
description: "this is only a test",
bodyView: bodyView,
footerView: footerView,
});
t.ok(!modal.el);
modal.openIn('body');
t.equal(modal.el, select('body > .modal'));
t.equal(bodyView.el, select('[data-hook="body"] > .body-view-test'))
t.equal(footerView.el, select('[data-hook="footer"] > .footer-view-test'))
t.end();
});