Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Aug 19, 2014
1 parent 85d0253 commit 02263ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/exports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

var memo = require('memorizer')
var recast = require('recast')
var assert = require('assert')

var types = recast.types
var n = types.namedTypes
Expand Down Expand Up @@ -43,7 +44,7 @@ Module.prototype.buildExports = function () {

if (n.FunctionDeclaration.check(declaration)) {
var id = declaration.id.name
if (!id) throw new Error('unnamed function declaration')
assert(id, 'unnamed function declaration')
return exports.push([id, id])
}

Expand All @@ -56,11 +57,11 @@ Module.prototype.buildExports = function () {

if (n.ClassDeclaration.check(declaration)) {
var id = declaration.id.name
if (!id) throw new Error('unnamed class')
assert(id, 'unnamed class')
return exports.push([id, id])
}

throw new Error('wtf')
assert(false, 'an error occured. you are probably using a bad version of esprima')
}, this)

if (!exports.length) return // nothing to export
Expand Down
14 changes: 14 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,17 @@ describe('.dependenciesOf', function () {
assert.deepEqual(['y'], deps)
})
})

describe('.inspect()', function () {
it('import-as', function () {
var ast = read('import-as')
var mod = Module(ast)
var json = mod.inspect()
assert.deepEqual([
'type',
'default',
'dependencies',
'renames'
], Object.keys(json))
})
})

0 comments on commit 02263ab

Please sign in to comment.