forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvg_test.js
79 lines (61 loc) · 2.38 KB
/
svg_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
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
import EmberView from "ember-views/views/view";
import run from "ember-metal/run_loop";
import compile from "ember-template-compiler/system/compile";
import { equalInnerHTML } from "htmlbars-test-helpers";
var view;
function appendView(view) {
run(function() { view.appendTo('#qunit-fixture'); });
}
if (Ember.FEATURES.isEnabled('ember-htmlbars-attribute-syntax')) {
// jscs:disable validateIndentation
QUnit.module("ember-htmlbars: svg attribute", {
teardown: function() {
if (view) {
run(view, view.destroy);
}
}
});
test("unquoted viewBox property is output", function() {
var viewBoxString = '0 0 100 100';
view = EmberView.create({
context: { viewBoxString: viewBoxString },
template: compile("<svg viewBox={{viewBoxString}}></svg>")
});
appendView(view);
equalInnerHTML(view.element, '<svg viewBox="'+viewBoxString+'"></svg>', "attribute is output");
Ember.run(view, view.set, 'context.viewBoxString', null);
equal(view.element.getAttribute('svg'), null, "attribute is removed");
});
test("quoted viewBox property is output", function() {
var viewBoxString = '0 0 100 100';
view = EmberView.create({
context: { viewBoxString: viewBoxString },
template: compile("<svg viewBox='{{viewBoxString}}'></svg>")
});
appendView(view);
equalInnerHTML(view.element, '<svg viewBox="'+viewBoxString+'"></svg>', "attribute is output");
});
test("quoted viewBox property is concat", function() {
var viewBoxString = '100 100';
view = EmberView.create({
context: { viewBoxString: viewBoxString },
template: compile("<svg viewBox='0 0 {{viewBoxString}}'></svg>")
});
appendView(view);
equalInnerHTML(view.element, '<svg viewBox="0 0 '+viewBoxString+'"></svg>', "attribute is output");
var newViewBoxString = '200 200';
Ember.run(view, view.set, 'context.viewBoxString', newViewBoxString);
equalInnerHTML(view.element, '<svg viewBox="0 0 '+newViewBoxString+'"></svg>', "attribute is output");
});
test("class is output", function() {
view = EmberView.create({
context: { color: 'blue' },
template: compile("<svg class='{{color}} tall'></svg>")
});
appendView(view);
equalInnerHTML(view.element, '<svg class="blue tall"></svg>', "attribute is output");
Ember.run(view, view.set, 'context.color', 'red');
equalInnerHTML(view.element, '<svg class="red tall"></svg>', "attribute is output");
});
// jscs:enable validateIndentation
}