Skip to content

Commit

Permalink
readers: remove superfluous done
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 14, 2024
1 parent 9ced3cb commit 8ce689a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 62 deletions.
9 changes: 3 additions & 6 deletions test/readers/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ beforeEach(function (done) {
})

describe('binary', function () {
it('module is required', function (done) {
it('module is required', function () {
assert.ok(this.bin)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.bin.load === 'function')
done()
})

it('loads the test binary file', function (done) {
it('loads the test binary file', function () {
const testBin = path.join('test', 'config', 'test.binary')
const result = this.bin.load(testBin)
assert.ok(Buffer.isBuffer(result))
assert.equal(result.length, 120)
assert.deepEqual(result, fs.readFileSync(testBin))
done()
})
})
15 changes: 5 additions & 10 deletions test/readers/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,27 @@ beforeEach(function (done) {
})

describe('flat', function () {
it('module is required', function (done) {
it('module is required', function () {
assert.ok(this.flat)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.flat.load === 'function')
done()
})

it('loads the test flat file, as list', function (done) {
it('loads the test flat file, as list', function () {
const result = this.flat.load('test/config/test.flat', 'list', null, regex)
assert.deepEqual(result, ['line1', 'line2', 'line3', 'line5'])
done()
})

it('loads the test flat file, unspecified type', function (done) {
it('loads the test flat file, unspecified type', function () {
const result = this.flat.load('test/config/test.flat', null, null, regex)
assert.deepEqual(result, 'line1')
done()
})

it('returns hostname for empty "me"', function (done) {
it('returns hostname for empty "me"', function () {
const result = this.flat.load('test/config/me', null, null, regex)
console.log(result)
assert.ok(result)
done()
})
})
9 changes: 3 additions & 6 deletions test/readers/hjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ beforeEach(function (done) {
})

describe('hjson', function () {
it('module is required', function (done) {
it('module is required', function () {
assert.ok(this.hjson)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.hjson.load === 'function')
done()
})

it('loads the test HJSON file', function (done) {
it('loads the test HJSON file', function () {
const result = this.hjson.load(path.join('test', 'config', 'test.hjson'))
// console.log(result)
assert.equal(result.matt, 'waz here and also made comments')
assert.ok(result.differentArray.length)
assert.ok(result.object['has a property one'])
assert.ok(result.object['has a property two'])
done()
})
})
42 changes: 14 additions & 28 deletions test/readers/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ beforeEach(function (done) {
})

describe('ini', function () {
it('requires', function (done) {
it('requires', function () {
assert.ok(this.ini)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.ini.load === 'function')
done()
})

it('loads the test ini file', function (done) {
it('loads the test ini file', function () {
const result = this.ini.load('test/config/test.ini', {}, regex)
// console.log(result);
assert.deepEqual(result.main, {
Expand All @@ -30,29 +28,26 @@ describe('ini', function () {
str_true: 'true',
str_false: 'false',
})
done()
})

describe('test.ini', function () {
it('no opts', function (done) {
it('no opts', function () {
const r = this.ini.load('test/config/test.ini', {}, regex)
assert.strictEqual(r.main.bool_true, 'true')
assert.strictEqual(r.main.bool_false, 'false')
assert.strictEqual(r.main.str_true, 'true')
assert.strictEqual(r.main.str_false, 'false')
done()
})

it('opts', function (done) {
it('opts', function () {
const r = this.ini.load('test/config/test.ini', this.opts, regex).main
assert.strictEqual(r.bool_true, true)
assert.strictEqual(r.bool_false, false)
assert.strictEqual(r.str_true, 'true')
assert.strictEqual(r.str_false, 'false')
done()
})

it('sect1, opts', function (done) {
it('sect1, opts', function () {
const r = this.ini.load(
'test/config/test.ini',
{
Expand All @@ -64,10 +59,9 @@ describe('ini', function () {
assert.strictEqual(r.sect1.bool_false, false)
assert.strictEqual(r.sect1.str_true, 'true')
assert.strictEqual(r.sect1.str_false, 'false')
done()
})

it('sect1, opts, w/defaults', function (done) {
it('sect1, opts, w/defaults', function () {
const r = this.ini.load(
'test/config/test.ini',
{
Expand All @@ -86,10 +80,9 @@ describe('ini', function () {
assert.strictEqual(r.sect1.str_false, 'false')
assert.strictEqual(r.sect1.bool_true_default, true)
assert.strictEqual(r.sect1.bool_false_default, false)
done()
})

it('wildcard boolean', function (done) {
it('wildcard boolean', function () {
const r = this.ini.load(
'test/config/test.ini',
{
Expand All @@ -102,24 +95,21 @@ describe('ini', function () {
assert.strictEqual(r.main.is_bool, undefined)
assert.strictEqual(r['foo.com'].is_bool, true)
assert.strictEqual(r['bar.com'].is_bool, false)
done()
})
})

describe('non-exist.ini (empty)', function () {
it('is template', function (done) {
it('is template', function () {
assert.deepEqual(this.ini.empty(), { main: {} })
done()
})

it('boolean', function (done) {
it('boolean', function () {
assert.deepEqual(this.ini.empty({ booleans: ['reject'] }), {
main: { reject: false },
})
done()
})

it('boolean true default', function (done) {
it('boolean true default', function () {
assert.deepEqual(this.ini.empty({ booleans: ['+reject'] }), {
main: { reject: true },
})
Expand All @@ -129,10 +119,9 @@ describe('ini', function () {
assert.deepEqual(this.ini.empty({ booleans: ['main.+reject'] }), {
main: { reject: true },
})
done()
})

it('boolean false default', function (done) {
it('boolean false default', function () {
assert.deepEqual(this.ini.empty({ booleans: ['-reject'] }), {
main: { reject: false },
})
Expand All @@ -142,10 +131,9 @@ describe('ini', function () {
assert.deepEqual(this.ini.empty({ booleans: ['main.-reject'] }), {
main: { reject: false },
})
done()
})

it('boolean false default, section', function (done) {
it('boolean false default, section', function () {
assert.deepEqual(this.ini.empty({ booleans: ['-reject.boolf'] }), {
main: {},
reject: { boolf: false },
Expand All @@ -154,15 +142,13 @@ describe('ini', function () {
main: {},
reject: { boolt: true },
})
done()
})
})

describe('goobers.ini', function () {
it('goobers.ini has invalid entry', function (done) {
it('goobers.ini has invalid entry', function () {
const result = this.ini.load('test/config/goobers.ini', {}, regex)
assert.deepEqual(result, { main: {} })
done()
})
})
})
9 changes: 3 additions & 6 deletions test/readers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ beforeEach(function (done) {
})

describe('json', function () {
it('module is required', function (done) {
it('module is required', function () {
assert.ok(this.json)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.json.load === 'function')
done()
})

it('loads the test JSON file', function (done) {
it('loads the test JSON file', function () {
const result = this.json.load('test/config/test.json')
// console.log(result);
assert.equal(result.matt, 'waz here')
assert.ok(result.array.length)
assert.ok(result.objecty['has a property'])
done()
})
})
9 changes: 3 additions & 6 deletions test/readers/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@ beforeEach(function (done) {
})

describe('yaml', function () {
it('module is required', function (done) {
it('module is required', function () {
assert.ok(this.yaml)
done()
})

it('has a load function', function (done) {
it('has a load function', function () {
assert.ok(typeof this.yaml.load === 'function')
done()
})

it('loads the test yaml file', function (done) {
it('loads the test yaml file', function () {
const result = this.yaml.load('test/config/test.yaml')
assert.strictEqual(result.main.bool_true, true)
assert.equal(result.matt, 'waz here')
assert.ok(result.array.length)
assert.ok(result.objecty['has a property'])
done()
})
})

0 comments on commit 8ce689a

Please sign in to comment.