Skip to content

Commit

Permalink
test: try w/o async mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Mar 17, 2022
1 parent ebc5232 commit e9788e4
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@ const zv = require('../index')

describe('parseZoneFile', function () {

it('parses a blank line', async () => {
it('parses a blank line', function (done) {
const r = zv.parseZoneFile(`\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r, [])
done()
})

it('parses two blank lines', async () => {
it('parses two blank lines', function (done) {
const r = zv.parseZoneFile(`\n\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r, [])
done()
})

it('parses a $TTL line', async () => {
it('parses a $TTL line', function (done) {
const r = zv.parseZoneFile(`$TTL 86400\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r[0], { ttl: 86400 })
done()
})

it('parses a $TTL line with a comment', async () => {
it('parses a $TTL line with a comment', function (done) {
const r = zv.parseZoneFile(`$TTL 86400; yikers\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r[0], { ttl: 86400 })
done()
})

it(`parses a SOA`, async () => {
it(`parses a SOA`, function (done) {
const r = zv.parseZoneFile(`example.com. 86400 IN SOA ns1.example.com. hostmaster.example.com. (
2021102100 ; serial
16384 ; refresh
Expand All @@ -53,9 +57,10 @@ describe('parseZoneFile', function () {
expire : 604800,
minimum: 2560,
})
done()
})

it('parses a NS line', async () => {
it('parses a NS line', function (done) {
const r = zv.parseZoneFile(`cadillac.net. 14400 IN NS ns1.cadillac.net.\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r[0], {
Expand All @@ -65,9 +70,10 @@ describe('parseZoneFile', function () {
type : 'NS',
dname: 'ns1.cadillac.net.',
})
done()
})

it('parses an A line', async () => {
it('parses an A line', function (done) {
const r = zv.parseZoneFile(`cadillac.net. 86400 IN A 66.128.51.173\n`)
// console.dir(r, { depth: null })
assert.deepStrictEqual(r[0], {
Expand All @@ -77,9 +83,10 @@ describe('parseZoneFile', function () {
type : 'A',
address: '66.128.51.173',
})
done()
})

it('parses the cadillac.net zone file', async () => {
it('parses the cadillac.net zone file', function (done) {
const file = './test/fixtures/zones/cadillac.net'
fs.readFile(file, (err, buf) => {
if (err) throw err
Expand All @@ -88,16 +95,18 @@ describe('parseZoneFile', function () {
// console.dir(r, { depth: null })
assert.equal(r.length, 41)
})
done()
})

it('parses the isi.edu zone file', async () => {
it('parses the isi.edu zone file', function (done) {
const file = './test/fixtures/zones/isi.edu'
fs.readFile(file, (err, buf) => {
if (err) throw err

const r = zv.parseZoneFile(buf.toString())
// console.dir(r, { depth: null })
assert.equal(r.length, 11)
done()
})
})
})

0 comments on commit e9788e4

Please sign in to comment.