Skip to content

Commit 20bc2ce

Browse files
committed
cleanup #102
1 parent a7091e8 commit 20bc2ce

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

test/require-test.js

+32-25
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
1+
'use strict';
12
var path = require('path');
2-
var temp = require('temp');
3-
var mocha = require('../');
43
var fs = require('fs');
54
var assert = require('assert');
5+
var temp = require('temp');
6+
var mocha = require('../');
67

7-
var tempFile
8-
const filePrefix = './';
8+
var tempFile;
9+
var tempFileBaseName;
10+
var filePrefix = './';
911

1012
function removeFile(file) {
11-
try {
12-
fs.unlinkSync(file);
13-
} catch(err) {}
13+
try {
14+
fs.unlinkSync(file);
15+
} catch (err) {}
1416
}
1517

16-
beforeEach(function(){
17-
tempFile = temp.path({dir:process.cwd(), suffix: '.js'});
18-
tempFileBaseName = path.basename(tempFile);
19-
fs.closeSync(fs.openSync(tempFile, 'w'));
18+
beforeEach(function () {
19+
tempFile = temp.path({
20+
dir: process.cwd(),
21+
suffix: '.js'
22+
});
23+
24+
tempFileBaseName = path.basename(tempFile);
25+
26+
fs.writeFileSync(tempFile, '');
2027
});
2128

22-
afterEach(function(){
23-
removeFile(tempFile);
29+
afterEach(function () {
30+
removeFile(tempFile);
2431
});
2532

33+
it('should fail when trying to require a file that doesn\'t exist', function () {
34+
removeFile(tempFile);
2635

27-
it('should fail when trying to require a file that doesn\'t exist', function() {
28-
removeFile(tempFile);
29-
assert.throws(function() {
30-
mocha({ require: [filePrefix + tempFileBaseName]});
31-
});
32-
})
36+
assert.throws(function () {
37+
mocha({require: [filePrefix + tempFileBaseName]});
38+
});
39+
});
3340

34-
it('should be able to import js-files in cwd', function() {
35-
mocha({ require: [filePrefix + tempFileBaseName]});
41+
it('should be able to import js-files in cwd', function () {
42+
mocha({require: [filePrefix + tempFileBaseName]});
3643
});
3744

38-
it('should fail when not having the ./ file prefix', function(){
39-
assert.throws(function() {
40-
mocha({require: [tempFileBaseName]})
41-
});
45+
it('should fail when not having the ./ file prefix', function () {
46+
assert.throws(function () {
47+
mocha({require: [tempFileBaseName]});
48+
});
4249
});

0 commit comments

Comments
 (0)