Commit d8bd4c36 authored by S Anand's avatar S Anand

TST: update template vdom test cases

parent 87cc1f6b
Pipeline #71690 passed with stage
in 2 minutes and 6 seconds
......@@ -251,12 +251,13 @@
</script>
<div class="morphdom-target vdom" style="background-color:#afa"></div>
<div class="morphdom-target vdom" style="background-color:#afa"></div>
<script type="text/html" class="animated-template" data-target=".morphdom-target" data-engine="vdom">
<script type="text/html" class="animated-template" data-engine="vdom" data-target=".morphdom-target">
<svg class="vdom-result" width="100" height="10"><circle cx="<%= x %>" cy="5" r="5" fill="black"></circle></svg>
</script>
<script>
var $tmpl = $('.animated-template').template({ x: 0 })
var circles = $('.vdom-result circle').get()
var svgs = $('.vdom-result circle').get()
tape('$().template() with type=text/vdom animates nodes', function(t) {
t.deepEqual(circles.map(function (c) { return c.getBBox().x }), [-5, -5, -5])
// In the next cycle, start animation.
......@@ -266,6 +267,10 @@
// Default position is -5 (cx - r = 0 - 5 = -5)
setTimeout(function () {
var x = _.max(circles.map(function (c) { return c.getBBox().x }))
// vdom ensures that the same SVGs are still in the document, and have parents.
// using jQuery would have removed these nodes from the document.
t.ok(_.every(svgs.map(function (v) { return v.parentNode })), 'DOM preserved')
// We're mid-way through the animation. Ensure that the position is mid-way
t.ok(x > -5, 'x > -5')
t.ok(x < 95, 'x < 95')
t.end()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment