Skip to content

Commit b1d45fa

Browse files
committed
Create separate test helpers file
1 parent 4ee258c commit b1d45fa

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

test/complex_schemas.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
var fs = require('fs')
2-
, join = require('path').join
3-
, test = require('tape')
1+
var test = require('tape')
2+
, getSchema = require('./helpers').getSchema
43
, convert = require('../')
54
;
65

@@ -35,7 +34,3 @@ test('converting complex schema in place', function(assert) {
3534
assert.deepEqual(result, expected, 'converted');
3635
});
3736

38-
function getSchema(file) {
39-
var path = join(__dirname, 'schemas', file);
40-
return JSON.parse(fs.readFileSync(path));
41-
}

test/helpers.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var fs = require('fs')
2+
, join = require('path').join
3+
;
4+
5+
module.exports = {
6+
getSchema: getSchema
7+
};
8+
9+
function getSchema(file) {
10+
var path = join(__dirname, 'schemas', file);
11+
return JSON.parse(fs.readFileSync(path));
12+
}

test/invalid_types.test.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var test = require('tape')
2-
, join = require('path').join
3-
, fs = require('fs')
2+
, getSchema = require('./helpers').getSchema
43
, convert = require('../')
54
;
65

@@ -28,8 +27,3 @@ test('invalid types', function(assert) {
2827
msg = 'invalid type inside complex schema';
2928
assert.throws(function() { convert(schema); }, /InvalidTypeError.*invalidtype/, msg);
3029
});
31-
32-
function getSchema(file) {
33-
var path = join(__dirname, 'schemas', file);
34-
return JSON.parse(fs.readFileSync(path));
35-
}

0 commit comments

Comments
 (0)