Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed May 31, 2012
1 parent 676439e commit a0cde55
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var MC = require('../emcee.js')
var tap = require('tap')
var fs = require('fs')

MC.model('file', function (f, cb) {
fs.readFile(f, cb)
})

MC.model('utf8', function (f, cb) {
fs.readFile(f, 'utf8', cb)
})

MC.model('sync', function (cb) {
cb(null, 2 + 2)
})

tap.test('read the file', function (t) {
var m = new MC()
m.load('file', __filename)
m.end(function (er, models) {
t.ifError(er)
if (er) return t.end()
t.ok(models.file)
t.equal(models.file.toString(),
fs.readFileSync(__filename, 'utf8'))
t.end()
})
})

tap.test('model fail', function (t) {
var m = new MC()
m.load('file', __dirname)
m.end(function (er, models) {
t.ok(er)
t.equal(models.file, undefined)
t.end()
})
})

tap.test('multiple', function (t) {
var m = new MC()
m.load('file', __filename)
m.load('utf8', __filename)
m.load('sync')
m.end(function (er, models) {
t.ifError(er)
if (er) return t.end()
t.equal(models.sync, 4)
t.equal(models.file.toString(), models.utf8)
t.end()
})
})

0 comments on commit a0cde55

Please sign in to comment.