From cfca4fa6baa18118daee551e88634341d64f7a9a Mon Sep 17 00:00:00 2001 From: Jim de Beer Date: Fri, 30 Sep 2016 12:39:23 +0200 Subject: [PATCH] added test for transform and switch, firing remove listeners --- lib/transform.js | 4 +--- test/transform.js | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/transform.js b/lib/transform.js index e7e7a88..3f32327 100644 --- a/lib/transform.js +++ b/lib/transform.js @@ -17,9 +17,7 @@ exports.properties = { var val = s && target.$ ? target.compute(s) : target.compute() if (!val || typeof val !== 'string') { val = '' } const node = getParent(type, stamp, subs, tree, pid) - if (node) { setTransform(val, store, node) } else { - console.log('lullllz') - } + if (node) { setTransform(val, store, node) } } } } diff --git a/test/transform.js b/test/transform.js index abf4030..1e55e61 100644 --- a/test/transform.js +++ b/test/transform.js @@ -4,7 +4,7 @@ const test = require('tape') const s = require('vigour-state/s') const render = require('brisky-core/render') -test('transform - static', function (t) { +test('transform - static', (t) => { const elem = render({ style: { transform: { @@ -17,7 +17,7 @@ test('transform - static', function (t) { t.end() }) -test('transform - state', function (t) { +test('transform - state', (t) => { const state = s({ x: -5, y: 5, @@ -37,29 +37,30 @@ test('transform - state', function (t) { t.end() }) -test('transform - state - remove', function (t) { +test('transform - state - remove', (t) => { const state = s({ - field: { - x: -5, - y: 5, - rot: 5 - } + a: { + y: 5 + }, + b: {}, + field: '$root.a' }) const elem = render({ field: { - $: 'field', - style: { - transform: { - y: { $: 'y' }, - x: { $: 'x' }, - rotate: { $: 'rot' }, - scale: 0.1 + $: 'field.$switch', + properties: { + a: { + style: { + transform: { + y: { $: 'y' } + } + } } } } }, state) - t.equals(elem.childNodes[0].style.transform, 'translate3d(-5px, 5px, 0px) scale(0.1) rotate(5deg)', 'intial') - state.field.remove() + t.equals(elem.childNodes[0].childNodes[0].style.transform, 'translate3d(0, 5px, 0px)', 'intial') + state.set({ field: '$root.b' }) t.ok(true, 'should not crash on remove') t.end() })