-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7091e8
commit 20bc2ce
Showing
1 changed file
with
32 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,49 @@ | ||
'use strict'; | ||
var path = require('path'); | ||
var temp = require('temp'); | ||
var mocha = require('../'); | ||
var fs = require('fs'); | ||
var assert = require('assert'); | ||
var temp = require('temp'); | ||
var mocha = require('../'); | ||
|
||
var tempFile | ||
const filePrefix = './'; | ||
var tempFile; | ||
var tempFileBaseName; | ||
var filePrefix = './'; | ||
|
||
function removeFile(file) { | ||
try { | ||
fs.unlinkSync(file); | ||
} catch(err) {} | ||
try { | ||
fs.unlinkSync(file); | ||
} catch (err) {} | ||
} | ||
|
||
beforeEach(function(){ | ||
tempFile = temp.path({dir:process.cwd(), suffix: '.js'}); | ||
tempFileBaseName = path.basename(tempFile); | ||
fs.closeSync(fs.openSync(tempFile, 'w')); | ||
beforeEach(function () { | ||
tempFile = temp.path({ | ||
dir: process.cwd(), | ||
suffix: '.js' | ||
}); | ||
|
||
tempFileBaseName = path.basename(tempFile); | ||
|
||
fs.writeFileSync(tempFile, ''); | ||
}); | ||
|
||
afterEach(function(){ | ||
removeFile(tempFile); | ||
afterEach(function () { | ||
removeFile(tempFile); | ||
}); | ||
|
||
it('should fail when trying to require a file that doesn\'t exist', function () { | ||
removeFile(tempFile); | ||
|
||
it('should fail when trying to require a file that doesn\'t exist', function() { | ||
removeFile(tempFile); | ||
assert.throws(function() { | ||
mocha({ require: [filePrefix + tempFileBaseName]}); | ||
}); | ||
}) | ||
assert.throws(function () { | ||
mocha({require: [filePrefix + tempFileBaseName]}); | ||
}); | ||
}); | ||
|
||
it('should be able to import js-files in cwd', function() { | ||
mocha({ require: [filePrefix + tempFileBaseName]}); | ||
it('should be able to import js-files in cwd', function () { | ||
mocha({require: [filePrefix + tempFileBaseName]}); | ||
}); | ||
|
||
it('should fail when not having the ./ file prefix', function(){ | ||
assert.throws(function() { | ||
mocha({require: [tempFileBaseName]}) | ||
}); | ||
it('should fail when not having the ./ file prefix', function () { | ||
assert.throws(function () { | ||
mocha({require: [tempFileBaseName]}); | ||
}); | ||
}); |