Skip to content

Commit

Permalink
add minimum failure test case
Browse files Browse the repository at this point in the history
  • Loading branch information
weilu committed May 11, 2015
1 parent 053d907 commit cd38bb4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function() {
return "bar"
}
4 changes: 4 additions & 0 deletions test/baz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = function() {
return "baz"
}

10 changes: 10 additions & 0 deletions test/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var result
var useX = true

if(useX) {
result = require('./bar')
} else {
result = require('./baz')
}

module.exports = result
15 changes: 15 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ test('uglifyify: sanity check', function(t) {
}))
})

test.only('uglifyify: optional require', function(t) {
var src = path.join(__dirname, 'foo.js')
var orig = fs.readFileSync(src, 'utf8')

browserify({ entries: [src], debug: false })
.transform(uglifyify)
.bundle()
.pipe(bl(function(err, data) {
if (err) return t.ifError(err)
data = String(data)
t.true(data.match(/{"\.\/bar":\d}/))
t.end()
}))
})

test('uglifyify: ignores json', function(t) {
var src = path.join(__dirname, 'fixture.js')
var json = path.join(__dirname, 'fixture.json')
Expand Down

0 comments on commit cd38bb4

Please sign in to comment.