Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #90

Merged
merged 1 commit into from
Feb 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@ var Nanocomponent = require('../')
var test = require('tape')
var html = require('nanohtml')

test('cache', (t) => {
t.test('should validate input types', (t) => {
t.plan(1)
var comp = new Nanocomponent()
t.throws(comp.render.bind(comp), /createElement should be implemented/)
})

t.test('should render elements', (t) => {
t.plan(2)

function MyComp () {
if (!(this instanceof MyComp)) return new MyComp()
Nanocomponent.call(this)
}
MyComp.prototype = Object.create(Nanocomponent.prototype)

MyComp.prototype.createElement = function (name) {
return html`<div>${name}</div>`
}

MyComp.prototype.update = function (name) {
return false
}

var myComp = new MyComp()

var el1 = myComp.render('mittens')
t.equal(String(el1), '<div>mittens</div>', 'init render success')

var el3 = myComp.render('scruffles')
t.equal(String(el3), '<div>scruffles</div>', 're-render success')
})
test('should validate input types', (t) => {
t.plan(1)
var comp = new Nanocomponent()
t.throws(comp.render.bind(comp), /createElement should be implemented/)
})

test('should render elements', (t) => {
t.plan(2)

function MyComp () {
if (!(this instanceof MyComp)) return new MyComp()
Nanocomponent.call(this)
}
MyComp.prototype = Object.create(Nanocomponent.prototype)

MyComp.prototype.createElement = function (name) {
return html`<div>${name}</div>`
}

MyComp.prototype.update = function (name) {
return false
}

var myComp = new MyComp()

var el1 = myComp.render('mittens')
t.equal(String(el1), '<div>mittens</div>', 'init render success')

var el3 = myComp.render('scruffles')
t.equal(String(el3), '<div>scruffles</div>', 're-render success')
})