|
| 1 | +'use strict'; |
1 | 2 | var path = require('path');
|
2 |
| -var temp = require('temp'); |
3 |
| -var mocha = require('../'); |
4 | 3 | var fs = require('fs');
|
5 | 4 | var assert = require('assert');
|
| 5 | +var temp = require('temp'); |
| 6 | +var mocha = require('../'); |
6 | 7 |
|
7 |
| -var tempFile |
8 |
| -const filePrefix = './'; |
| 8 | +var tempFile; |
| 9 | +var tempFileBaseName; |
| 10 | +var filePrefix = './'; |
9 | 11 |
|
10 | 12 | function removeFile(file) {
|
11 |
| - try { |
12 |
| - fs.unlinkSync(file); |
13 |
| - } catch(err) {} |
| 13 | + try { |
| 14 | + fs.unlinkSync(file); |
| 15 | + } catch (err) {} |
14 | 16 | }
|
15 | 17 |
|
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, ''); |
20 | 27 | });
|
21 | 28 |
|
22 |
| -afterEach(function(){ |
23 |
| - removeFile(tempFile); |
| 29 | +afterEach(function () { |
| 30 | + removeFile(tempFile); |
24 | 31 | });
|
25 | 32 |
|
| 33 | +it('should fail when trying to require a file that doesn\'t exist', function () { |
| 34 | + removeFile(tempFile); |
26 | 35 |
|
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 | +}); |
33 | 40 |
|
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]}); |
36 | 43 | });
|
37 | 44 |
|
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 | + }); |
42 | 49 | });
|
0 commit comments