Skip to content

Commit

Permalink
added test for transform and switch, firing remove listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim de Beer committed Sep 30, 2016
1 parent 0896032 commit cfca4fa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
4 changes: 1 addition & 3 deletions lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
}
Expand Down
35 changes: 18 additions & 17 deletions test/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand All @@ -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()
})

0 comments on commit cfca4fa

Please sign in to comment.