Skip to content

Commit

Permalink
added tests for state true
Browse files Browse the repository at this point in the history
  • Loading branch information
youzi committed May 27, 2016
1 parent 66d3cc8 commit 84cb9d5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 16 deletions.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@
"babel-preset-es2015": "^6.6.0",
"babelify": "^7.3.0"
},
"devDependencies": {
"vigour-state": "^3.0.0",
"coveralls": "^2.11.9",
"istanbul": "^0.4.3",
"nodemon": "^1.9.1",
"pre-commit": "^1.1.3",
"standard": "^7.0.1",
"tap-difflet": "0.4.0",
"tape": "^4.4.0",
"vigour-doc": "^1.1.5",
"watchify-server": "^1.0.2"
},
"browserify": {
"transform": [
[
Expand All @@ -49,16 +61,5 @@
"contributors": [
"Jim de Beer <jim@vigour.io>",
"Youri Daamen <youri@vigour.io>"
],
"devDependencies": {
"coveralls": "^2.11.9",
"istanbul": "^0.4.3",
"nodemon": "^1.9.1",
"pre-commit": "^1.1.3",
"standard": "^7.0.1",
"tap-difflet": "0.4.0",
"tape": "^4.4.0",
"vigour-doc": "^1.1.5",
"watchify-server": "^1.0.2"
}
]
}
45 changes: 41 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
require('brisky-core').prototype.inject(require('../'))

const test = require('tape')
const s = require('vigour-state/s')
const render = require('brisky-core/render')

test('static styles', function (t) {
var elem
t.plan(2)

elem = render({
var elem = render({
style: {
padding: '100px'
}
Expand All @@ -27,4 +25,43 @@ test('static styles', function (t) {
(elem.style.padding === '100px') &&
(elem.style.margin === '50px'),
'add multiple styles')

t.end()
})

test('state styles', function (t) {
var elem = render({
style: {
display: {
$: 'thing'
}
}
}, {
thing: 'none'
})

t.equals(elem.style.display, 'none', 'add display property using state')

const state = s({
thing: 'none'
})

elem = render({
$: 'thing',
style: {
display: {
$: true
}
}
}, state)

t.equals(elem.style.display, 'none', 'add display property using state true')

state.set({
thing: 'block'
})

t.equals(elem.style.display, 'block', 'add display property using state true, update')

t.end()
})

0 comments on commit 84cb9d5

Please sign in to comment.