diff --git a/package-lock.json b/package-lock.json index 9917f97..61db7f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -214,21 +214,21 @@ } }, "@google-cloud/common": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.19.2.tgz", - "integrity": "sha512-CuURBaMx6vUwLFpHLCYyLJXkg6EKYcrAfhH9Fva8C2B9dJ7flT8j/R+o05OuXwj4VQYC4c8bl/hrwyO+XvAwlg==", + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@google-cloud/common/-/common-0.20.1.tgz", + "integrity": "sha512-LJB7CoNXEXY0mDWtF8E2cl3Y0kuMQ3wjH9Xr+Y7vH5gHgN82dDh1BMUOizRf9oXQFDWUgGERD5SdfBcjUhHmwA==", "requires": { "@types/duplexify": "^3.5.0", "@types/request": "^2.47.0", "arrify": "^1.0.1", "axios": "^0.18.0", - "duplexify": "^3.5.4", + "duplexify": "^3.6.0", "ent": "^2.2.0", "extend": "^3.0.1", - "google-auth-library": "^1.4.0", + "google-auth-library": "^1.6.0", "is": "^3.2.1", "pify": "^3.0.0", - "request": "^2.85.0", + "request": "^2.87.0", "retry-request": "^3.3.1", "split-array-stream": "^2.0.0", "stream-events": "^1.0.4", @@ -1947,14 +1947,14 @@ } }, "@types/node": { - "version": "10.3.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.2.tgz", - "integrity": "sha512-9NfEUDp3tgRhmoxzTpTo+lq+KIVFxZahuRX0LHF/9IzKHaWuoWsIrrJ61zw5cnnlGINX8lqJzXYfQTOICS5Q+A==" + "version": "10.3.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.4.tgz", + "integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==" }, "@types/request": { - "version": "2.47.0", - "resolved": "https://registry.npmjs.org/@types/request/-/request-2.47.0.tgz", - "integrity": "sha512-/KXM5oev+nNCLIgBjkwbk8VqxmzI56woD4VUxn95O+YeQ8hJzcSmIZ1IN3WexiqBb6srzDo2bdMbsXxgXNkz5Q==", + "version": "2.47.1", + "resolved": "https://registry.npmjs.org/@types/request/-/request-2.47.1.tgz", + "integrity": "sha512-TV3XLvDjQbIeVxJ1Z3oCTDk/KuYwwcNKVwz2YaT0F5u86Prgc4syDAp6P96rkTQQ4bIdh+VswQIC9zS6NjY7/g==", "requires": { "@types/caseless": "*", "@types/form-data": "*", diff --git a/src/change.js b/src/change.js index a138778..ef5151b 100644 --- a/src/change.js +++ b/src/change.js @@ -16,8 +16,8 @@ 'use strict'; -var common = require('@google-cloud/common'); -var util = require('util'); +const common = require('@google-cloud/common'); +const util = require('util'); /** * @class @@ -32,7 +32,7 @@ var util = require('util'); * const change = zone.change('change-id'); */ function Change(zone, id) { - var methods = { + const methods = { /** * @typedef {array} ChangeExistsResponse * @property {boolean} 0 Whether the {@link Change} exists. @@ -61,7 +61,7 @@ function Change(zone, id) { * // If the callback is omitted, we'll return a Promise. * //- * change.exists().then(function(data) { - * var exists = data[0]; + * const exists = data[0]; * }); */ exists: true, @@ -106,8 +106,8 @@ function Change(zone, id) { * // If the callback is omitted, we'll return a Promise. * //- * change.get().then(function(data) { - * var change = data[0]; - * var apiResponse = data[1]; + * const change = data[0]; + * const apiResponse = data[1]; * }); */ get: true, @@ -156,8 +156,8 @@ function Change(zone, id) { * // If the callback is omitted, we'll return a Promise. * //- * change.getMetadata().then(function(data) { - * var metadata = data[0]; - * var apiResponse = data[1]; + * const metadata = data[0]; + * const apiResponse = data[1]; * }); */ getMetadata: true, @@ -223,7 +223,7 @@ util.inherits(Change, common.ServiceObject); * }); */ Change.prototype.create = function(config, callback) { - var self = this; + const self = this; this.parent.createChange(config, function(err, change, apiResponse) { if (err) { diff --git a/src/index.js b/src/index.js index df2ae6f..2f41567 100644 --- a/src/index.js +++ b/src/index.js @@ -16,13 +16,13 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var is = require('is'); -var util = require('util'); +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const is = require('is'); +const util = require('util'); -var Zone = require('./zone.js'); +const Zone = require('./zone.js'); /** * @typedef {object} ClientConfig @@ -85,7 +85,7 @@ function DNS(options) { options = common.util.normalizeArguments(this, options); - var config = { + const config = { baseUrl: 'https://www.googleapis.com/dns/v1', scopes: [ 'https://www.googleapis.com/auth/ndev.clouddns.readwrite', @@ -156,7 +156,7 @@ util.inherits(DNS, common.Service); * }); */ DNS.prototype.createZone = function(name, config, callback) { - var self = this; + const self = this; if (!name) { throw new Error('A zone name is required.'); @@ -183,7 +183,7 @@ DNS.prototype.createZone = function(name, config, callback) { return; } - var zone = self.zone(resp.name); + const zone = self.zone(resp.name); zone.metadata = resp; callback(null, zone, resp); @@ -237,7 +237,7 @@ DNS.prototype.createZone = function(name, config, callback) { * }); */ DNS.prototype.getZones = function(query, callback) { - var self = this; + const self = this; if (is.fn(query)) { callback = query; @@ -255,13 +255,13 @@ DNS.prototype.getZones = function(query, callback) { return; } - var zones = arrify(resp.managedZones).map(function(zone) { - var zoneInstance = self.zone(zone.name); + const zones = arrify(resp.managedZones).map(function(zone) { + const zoneInstance = self.zone(zone.name); zoneInstance.metadata = zone; return zoneInstance; }); - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, query, { diff --git a/src/record.js b/src/record.js index b2d7300..b15d689 100644 --- a/src/record.js +++ b/src/record.js @@ -16,10 +16,10 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var extend = require('extend'); -var format = require('string-format-obj'); +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const extend = require('extend'); +const format = require('string-format-obj'); /** * Create a Resource Record object. @@ -89,7 +89,7 @@ function Record(zone, type, metadata) { * @returns {Record} */ Record.fromZoneRecord_ = function(zone, type, bindData) { - var typeToZoneFormat = { + const typeToZoneFormat = { a: '{ip}', aaaa: '{ip}', cname: '{alias}', @@ -101,7 +101,7 @@ Record.fromZoneRecord_ = function(zone, type, bindData) { txt: '{txt}', }; - var metadata = { + const metadata = { data: format(typeToZoneFormat[type.toLowerCase()], bindData), name: bindData.name, ttl: bindData.ttl, @@ -154,8 +154,8 @@ Record.fromZoneRecord_ = function(zone, type, bindData) { * // If the callback is omitted, we'll return a Promise. * //- * record.delete().then(function(data) { - * var change = data[0]; - * var apiResponse = data[1]; + * const change = data[0]; + * const apiResponse = data[1]; * }); */ Record.prototype.delete = function(callback) { @@ -168,7 +168,7 @@ Record.prototype.delete = function(callback) { * @returns {object} */ Record.prototype.toJSON = function() { - var recordObject = extend({}, this.metadata, { + const recordObject = extend({}, this.metadata, { type: this.type.toUpperCase(), }); @@ -186,7 +186,7 @@ Record.prototype.toJSON = function() { * @returns {string} */ Record.prototype.toString = function() { - var json = this.toJSON(); + const json = this.toJSON(); return (json.rrdatas || [{}]) .map(function(data) { diff --git a/src/zone.js b/src/zone.js index 5352582..1f588f1 100644 --- a/src/zone.js +++ b/src/zone.js @@ -16,20 +16,20 @@ 'use strict'; -var arrify = require('arrify'); -var common = require('@google-cloud/common'); -var exec = require('methmeth'); -var extend = require('extend'); -var flatten = require('lodash.flatten'); -var fs = require('fs'); -var groupBy = require('lodash.groupby'); -var is = require('is'); -var prop = require('propprop'); -var util = require('util'); -var zonefile = require('dns-zonefile'); - -var Change = require('./change.js'); -var Record = require('./record.js'); +const arrify = require('arrify'); +const common = require('@google-cloud/common'); +const exec = require('methmeth'); +const extend = require('extend'); +const flatten = require('lodash.flatten'); +const fs = require('fs'); +const groupBy = require('lodash.groupby'); +const is = require('is'); +const prop = require('propprop'); +const util = require('util'); +const zonefile = require('dns-zonefile'); + +const Change = require('./change.js'); +const Record = require('./record.js'); /** * A Zone object is used to interact with your project's managed zone. It will @@ -45,7 +45,7 @@ var Record = require('./record.js'); * const zone = dns.zone('zone-id'); */ function Zone(dns, name) { - var methods = { + const methods = { /** * Create a zone. * @@ -339,13 +339,13 @@ Zone.prototype.change = function(id) { * }); */ Zone.prototype.createChange = function(config, callback) { - var self = this; + const self = this; if (!config || (!config.add && !config.delete)) { throw new Error('Cannot create a change with no additions or deletions.'); } - var body = extend( + const body = extend( { additions: groupByType(arrify(config.add).map(exec('toJSON'))), deletions: groupByType(arrify(config.delete).map(exec('toJSON'))), @@ -358,14 +358,14 @@ Zone.prototype.createChange = function(config, callback) { function groupByType(changes) { changes = groupBy(changes, 'type'); - var changesArray = []; + const changesArray = []; - for (var recordType in changes) { - var recordsByName = groupBy(changes[recordType], 'name'); + for (const recordType in changes) { + const recordsByName = groupBy(changes[recordType], 'name'); - for (var recordName in recordsByName) { - var records = recordsByName[recordName]; - var templateRecord = extend({}, records[0]); + for (const recordName in recordsByName) { + const records = recordsByName[recordName]; + const templateRecord = extend({}, records[0]); if (records.length > 1) { // Combine the `rrdatas` values from all records of the same type. @@ -391,7 +391,7 @@ Zone.prototype.createChange = function(config, callback) { return; } - var change = self.change(resp.id); + const change = self.change(resp.id); change.metadata = resp; callback(null, change, resp); @@ -593,7 +593,7 @@ Zone.prototype.deleteRecords = function(records, callback) { * @returns {Promise} */ Zone.prototype.empty = function(callback) { - var self = this; + const self = this; this.getRecords(function(err, records) { if (err) { @@ -601,7 +601,7 @@ Zone.prototype.empty = function(callback) { return; } - var recordsToDelete = records.filter(function(record) { + const recordsToDelete = records.filter(function(record) { return record.type !== 'NS' && record.type !== 'SOA'; }); @@ -656,7 +656,7 @@ Zone.prototype.export = function(localPath, callback) { return; } - var stringRecords = records.map(exec('toString')).join('\n'); + const stringRecords = records.map(exec('toString')).join('\n'); fs.writeFile(localPath, stringRecords, 'utf-8', function(err) { callback(err || null); @@ -729,7 +729,7 @@ Zone.prototype.export = function(localPath, callback) { * }); */ Zone.prototype.getChanges = function(query, callback) { - var self = this; + const self = this; if (is.fn(query)) { callback = query; @@ -752,13 +752,13 @@ Zone.prototype.getChanges = function(query, callback) { return; } - var changes = (resp.changes || []).map(function(change) { - var changeInstance = self.change(change.id); + const changes = (resp.changes || []).map(function(change) { + const changeInstance = self.change(change.id); changeInstance.metadata = change; return changeInstance; }); - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, query, { pageToken: resp.nextPageToken, @@ -892,7 +892,7 @@ Zone.prototype.getChangesStream = common.paginator.streamify('getChanges'); * }); */ Zone.prototype.getRecords = function(query, callback) { - var self = this; + const self = this; if (is.fn(query)) { callback = query; @@ -900,7 +900,7 @@ Zone.prototype.getRecords = function(query, callback) { } if (is.string(query) || is.array(query)) { - var filterByTypes_ = {}; + const filterByTypes_ = {}; // For faster lookups, store the record types the user wants in an object. arrify(query).forEach(function(type) { @@ -912,7 +912,7 @@ Zone.prototype.getRecords = function(query, callback) { }; } - var requestQuery = extend({}, query); + const requestQuery = extend({}, query); delete requestQuery.filterByTypes_; this.request( @@ -926,7 +926,7 @@ Zone.prototype.getRecords = function(query, callback) { return; } - var records = (resp.rrsets || []).map(function(record) { + let records = (resp.rrsets || []).map(function(record) { return self.record(record.type, record); }); @@ -936,7 +936,7 @@ Zone.prototype.getRecords = function(query, callback) { }); } - var nextQuery = null; + let nextQuery = null; if (resp.nextPageToken) { nextQuery = extend({}, query, { pageToken: resp.nextPageToken, @@ -1023,7 +1023,7 @@ Zone.prototype.getRecordsStream = common.paginator.streamify('getRecords'); * }); */ Zone.prototype.import = function(localPath, callback) { - var self = this; + const self = this; fs.readFile(localPath, 'utf-8', function(err, file) { if (err) { @@ -1031,15 +1031,15 @@ Zone.prototype.import = function(localPath, callback) { return; } - var parsedZonefile = zonefile.parse(file); - var defaultTTL = parsedZonefile.$ttl; + const parsedZonefile = zonefile.parse(file); + const defaultTTL = parsedZonefile.$ttl; delete parsedZonefile.$ttl; - var recordTypes = Object.keys(parsedZonefile); - var recordsToCreate = []; + const recordTypes = Object.keys(parsedZonefile); + const recordsToCreate = []; recordTypes.forEach(function(recordType) { - var recordTypeSet = arrify(parsedZonefile[recordType]); + const recordTypeSet = arrify(parsedZonefile[recordType]); recordTypeSet.forEach(function(record) { record.ttl = record.ttl || defaultTTL; @@ -1171,7 +1171,7 @@ Zone.prototype.record = function(type, metadata) { * }); */ Zone.prototype.replaceRecords = function(recordType, newRecords, callback) { - var self = this; + const self = this; this.getRecords(recordType, function(err, recordsToDelete) { if (err) { @@ -1208,7 +1208,7 @@ Zone.prototype.replaceRecords = function(recordType, newRecords, callback) { * }); */ Zone.prototype.deleteRecordsByType_ = function(recordTypes, callback) { - var self = this; + const self = this; this.getRecords(recordTypes, function(err, records) { if (err) { diff --git a/system-test/dns.js b/system-test/dns.js index 34aa84c..f85b02c 100644 --- a/system-test/dns.js +++ b/system-test/dns.js @@ -16,18 +16,18 @@ 'use strict'; -var assert = require('assert'); -var async = require('async'); -var exec = require('methmeth'); -var format = require('string-format-obj'); -var fs = require('fs'); -var tmp = require('tmp'); -var uuid = require('uuid'); +const assert = require('assert'); +const async = require('async'); +const exec = require('methmeth'); +const format = require('string-format-obj'); +const fs = require('fs'); +const tmp = require('tmp'); +const uuid = require('uuid'); -var DNS = require('../'); +const DNS = require('../'); -var dns = new DNS(); -var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; +const dns = new DNS(); +const DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; // Only run the tests if there is a domain to test with. (DNS_DOMAIN ? describe : describe.skip)('dns', function() { @@ -36,10 +36,10 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; return; } - var ZONE_NAME = 'test-zone-' + uuid.v4().substr(0, 18); - var ZONE = dns.zone(ZONE_NAME); + const ZONE_NAME = 'test-zone-' + uuid.v4().substr(0, 18); + const ZONE = dns.zone(ZONE_NAME); - var records = { + const records = { a: ZONE.record('a', { ttl: 86400, name: DNS_DOMAIN, @@ -154,7 +154,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; }); it('should support all types of records', function(done) { - var recordsToCreate = [ + const recordsToCreate = [ records.a, records.aaaa, records.cname, @@ -172,8 +172,8 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; }); it('should import records from a zone file', function(done) { - var zoneFilename = require.resolve('./data/zonefile.zone'); - var zoneFileTemplate = fs.readFileSync(zoneFilename, 'utf-8'); + const zoneFilename = require.resolve('./data/zonefile.zone'); + let zoneFileTemplate = fs.readFileSync(zoneFilename, 'utf-8'); zoneFileTemplate = format(zoneFileTemplate, { DNS_DOMAIN: DNS_DOMAIN, }); @@ -193,7 +193,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; ZONE.getRecords(['spf', 'txt'], function(err, records) { assert.ifError(err); - var spfRecord = records.filter(function(record) { + const spfRecord = records.filter(function(record) { return record.type === 'SPF'; })[0]; @@ -202,7 +202,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; '"v=spf1" "mx:' + DNS_DOMAIN + '" "-all"' ); - var txtRecord = records.filter(function(record) { + const txtRecord = records.filter(function(record) { return record.type === 'TXT'; })[0]; @@ -230,7 +230,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; }, function(next) { - var recordsToCreate = [records.spf, records.srv]; + const recordsToCreate = [records.spf, records.srv]; ZONE.addRecords(recordsToCreate, next); }, @@ -246,18 +246,18 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; describe('changes', function() { it('should create a change', function(done) { - var record = ZONE.record('srv', { + const record = ZONE.record('srv', { ttl: 3600, name: DNS_DOMAIN, data: '10 0 5222 127.0.0.1.', }); - var change = ZONE.change(); + const change = ZONE.change(); change.create({add: record}, function(err) { assert.ifError(err); - var addition = change.metadata.additions[0]; + const addition = change.metadata.additions[0]; delete addition.kind; assert.deepEqual(addition, record.toJSON()); @@ -277,8 +277,8 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; ZONE.getChanges(function(err, changes) { assert.ifError(err); - var change = changes[0]; - var expectedMetadata = change.metadata; + const change = changes[0]; + const expectedMetadata = change.metadata; change.getMetadata(function(err, metadata) { assert.ifError(err); @@ -304,7 +304,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; }); it('should cursor through records by type', function(done) { - var newRecords = [ + const newRecords = [ ZONE.record('cname', { ttl: 86400, name: '1.' + DNS_DOMAIN, @@ -340,7 +340,7 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; }); it('should replace records', function(done) { - var name = 'test-zone-' + uuid.v4().substr(0, 18); + const name = 'test-zone-' + uuid.v4().substr(0, 18); // Do this in a new zone so no existing records are affected. dns.createZone(name, {dnsName: DNS_DOMAIN}, function(err, zone) { @@ -349,9 +349,9 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; zone.getRecords('ns', function(err, originalRecords) { assert.ifError(err); - var originalData = originalRecords[0].data; + const originalData = originalRecords[0].data; - var newRecord = zone.record('ns', { + const newRecord = zone.record('ns', { ttl: 3600, name: DNS_DOMAIN, data: ['ns1.nameserver.net.', 'ns2.nameserver.net.'], @@ -360,8 +360,8 @@ var DNS_DOMAIN = process.env.GCLOUD_TESTS_DNS_DOMAIN; zone.replaceRecords('ns', newRecord, function(err, change) { assert.ifError(err); - var deleted = change.metadata.deletions[0].rrdatas; - var added = change.metadata.additions[0].rrdatas; + const deleted = change.metadata.deletions[0].rrdatas; + const added = change.metadata.additions[0].rrdatas; assert.deepEqual(deleted, originalData); assert.deepEqual(added, newRecord.data); diff --git a/test/change.js b/test/change.js index 3ba697d..2edf0f6 100644 --- a/test/change.js +++ b/test/change.js @@ -16,15 +16,15 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; - -var promisified = false; -var fakeUtil = extend({}, util, { +const assert = require('assert'); +const extend = require('extend'); +const nodeutil = require('util'); +const proxyquire = require('proxyquire'); +const ServiceObject = require('@google-cloud/common').ServiceObject; +const util = require('@google-cloud/common').util; + +let promisified = false; +const fakeUtil = extend({}, util, { promisifyAll: function(Class) { if (Class.name === 'Change') { promisified = true; @@ -40,15 +40,15 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); describe('Change', function() { - var Change; - var change; + let Change; + let change; - var ZONE = { + const ZONE = { name: 'zone-name', createChange: util.noop, }; - var CHANGE_ID = 'change-id'; + const CHANGE_ID = 'change-id'; before(function() { Change = proxyquire('../src/change.js', { @@ -67,7 +67,7 @@ describe('Change', function() { it('should inherit from ServiceObject', function() { assert(change instanceof ServiceObject); - var calledWith = change.calledWith_[0]; + const calledWith = change.calledWith_[0]; assert.strictEqual(calledWith.parent, ZONE); assert.strictEqual(calledWith.baseUrl, '/changes'); @@ -86,7 +86,7 @@ describe('Change', function() { describe('change', function() { it('should call the parent change method', function(done) { - var config = {}; + const config = {}; change.parent.createChange = function(config_) { assert.strictEqual(config, config_); @@ -97,8 +97,8 @@ describe('Change', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {}; + const error = new Error('Error.'); + const apiResponse = {}; beforeEach(function() { change.parent.createChange = function(config, callback) { @@ -118,11 +118,11 @@ describe('Change', function() { }); describe('success', function() { - var changeInstance = { + const changeInstance = { id: 'id', metadata: {}, }; - var apiResponse = {}; + const apiResponse = {}; beforeEach(function() { change.parent.createChange = function(config, callback) { diff --git a/test/index.js b/test/index.js index 26c9e8d..7724907 100644 --- a/test/index.js +++ b/test/index.js @@ -16,16 +16,16 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var extend = require('extend'); -var nodeutil = require('util'); -var proxyquire = require('proxyquire'); -var Service = require('@google-cloud/common').Service; -var util = require('@google-cloud/common').util; - -var extended = false; -var fakePaginator = { +const arrify = require('arrify'); +const assert = require('assert'); +const extend = require('extend'); +const nodeutil = require('util'); +const proxyquire = require('proxyquire'); +const Service = require('@google-cloud/common').Service; +const util = require('@google-cloud/common').util; + +let extended = false; +const fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'DNS') { return; @@ -48,8 +48,8 @@ function FakeService() { nodeutil.inherits(FakeService, Service); -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +const fakeUtil = extend({}, util, { makeAuthenticatedRequestFactory: util.noop, promisifyAll: function(Class, options) { if (Class.name !== 'DNS') { @@ -60,17 +60,17 @@ var fakeUtil = extend({}, util, { assert.deepEqual(options.exclude, ['zone']); }, }); -var originalFakeUtil = extend(true, {}, fakeUtil); +const originalFakeUtil = extend(true, {}, fakeUtil); function FakeZone() { this.calledWith_ = arguments; } describe('DNS', function() { - var DNS; - var dns; + let DNS; + let dns; - var PROJECT_ID = 'project-id'; + const PROJECT_ID = 'project-id'; before(function() { DNS = proxyquire('../', { @@ -110,8 +110,8 @@ describe('DNS', function() { }); it('should normalize the arguments', function() { - var normalizeArgumentsCalled = false; - var options = {}; + let normalizeArgumentsCalled = false; + const options = {}; fakeUtil.normalizeArguments = function(context, options_) { normalizeArgumentsCalled = true; @@ -126,9 +126,9 @@ describe('DNS', function() { it('should inherit from Service', function() { assert(dns instanceof Service); - var calledWith = dns.calledWith_[0]; + const calledWith = dns.calledWith_[0]; - var baseUrl = 'https://www.googleapis.com/dns/v1'; + const baseUrl = 'https://www.googleapis.com/dns/v1'; assert.strictEqual(calledWith.baseUrl, baseUrl); assert.deepEqual(calledWith.scopes, [ 'https://www.googleapis.com/auth/ndev.clouddns.readwrite', @@ -139,8 +139,8 @@ describe('DNS', function() { }); describe('createZone', function() { - var zoneName = 'zone-name'; - var config = {dnsName: 'dns-name'}; + const zoneName = 'zone-name'; + const config = {dnsName: 'dns-name'}; it('should throw if a zone name is not provided', function() { assert.throws(function() { @@ -159,7 +159,7 @@ describe('DNS', function() { }); it('should use a provided description', function(done) { - var cfg = extend({}, config, {description: 'description'}); + const cfg = extend({}, config, {description: 'description'}); dns.request = function(reqOpts) { assert.strictEqual(reqOpts.json.description, cfg.description); @@ -183,7 +183,7 @@ describe('DNS', function() { assert.strictEqual(reqOpts.method, 'POST'); assert.strictEqual(reqOpts.uri, '/managedZones'); - var expectedBody = extend({}, config, { + const expectedBody = extend({}, config, { name: zoneName, description: '', }); @@ -196,8 +196,8 @@ describe('DNS', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { dns.request = function(reqOpts, callback) { @@ -216,8 +216,8 @@ describe('DNS', function() { }); describe('success', function() { - var apiResponse = {name: zoneName}; - var zone = {}; + const apiResponse = {name: zoneName}; + const zone = {}; beforeEach(function() { dns.request = function(reqOpts, callback) { @@ -260,7 +260,7 @@ describe('DNS', function() { describe('getZones', function() { it('should make the correct request', function(done) { - var query = {a: 'b', c: 'd'}; + const query = {a: 'b', c: 'd'}; dns.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/managedZones'); @@ -282,8 +282,8 @@ describe('DNS', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { dns.request = function(reqOpts, callback) { @@ -304,8 +304,8 @@ describe('DNS', function() { }); describe('success', function() { - var zone = {name: 'zone-1', a: 'b', c: 'd'}; - var apiResponse = {managedZones: [zone]}; + const zone = {name: 'zone-1', a: 'b', c: 'd'}; + const apiResponse = {managedZones: [zone]}; beforeEach(function() { dns.request = function(reqOpts, callback) { @@ -328,12 +328,12 @@ describe('DNS', function() { }); it('should set a nextQuery if necessary', function(done) { - var apiResponseWithNextPageToken = extend({}, apiResponse, { + const apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: 'next-page-token', }); - var query = {a: 'b', c: 'd'}; - var originalQuery = extend({}, query); + const query = {a: 'b', c: 'd'}; + const originalQuery = extend({}, query); dns.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -386,8 +386,8 @@ describe('DNS', function() { }); it('should return a Zone', function() { - var newZoneName = 'new-zone-name'; - var newZone = dns.zone(newZoneName); + const newZoneName = 'new-zone-name'; + const newZone = dns.zone(newZoneName); assert(newZone instanceof FakeZone); assert.strictEqual(newZone.calledWith_[0], dns); diff --git a/test/record.js b/test/record.js index 55b514b..8ef97d0 100644 --- a/test/record.js +++ b/test/record.js @@ -16,13 +16,13 @@ 'use strict'; -var assert = require('assert'); -var extend = require('extend'); -var proxyquire = require('proxyquire'); -var util = require('@google-cloud/common').util; +const assert = require('assert'); +const extend = require('extend'); +const proxyquire = require('proxyquire'); +const util = require('@google-cloud/common').util; -var promisified = false; -var fakeUtil = extend({}, util, { +let promisified = false; +const fakeUtil = extend({}, util, { promisifyAll: function(Class, options) { if (Class.name !== 'Record') { return; @@ -34,14 +34,14 @@ var fakeUtil = extend({}, util, { }); describe('Record', function() { - var Record; - var record; + let Record; + let record; - var ZONE = { + const ZONE = { deleteRecords: util.noop, }; - var TYPE = 'A'; - var METADATA = { + const TYPE = 'A'; + const METADATA = { name: 'name', data: [], ttl: 86400, @@ -77,18 +77,18 @@ describe('Record', function() { }); it('should assign the parsed metadata', function() { - var parsedMetadata = record.toJSON(); + const parsedMetadata = record.toJSON(); delete parsedMetadata.rrdatas; - for (var prop in parsedMetadata) { + for (const prop in parsedMetadata) { assert.strictEqual(record[prop], parsedMetadata[prop]); } }); it('should re-assign rrdatas to data', function() { - var originalRrdatas = []; + const originalRrdatas = []; - var recordThatHadRrdatas = new Record(ZONE, TYPE, { + const recordThatHadRrdatas = new Record(ZONE, TYPE, { rrdatas: originalRrdatas, }); @@ -99,16 +99,16 @@ describe('Record', function() { describe('fromZoneRecord_', function() { describe('a', function() { - var aRecord = { + const aRecord = { ip: '0.0.0.0', name: 'name', ttl: 86400, }; - var expectedData = aRecord.ip; + const expectedData = aRecord.ip; it('should parse an A record', function() { - var record = Record.fromZoneRecord_(ZONE, 'a', aRecord); + const record = Record.fromZoneRecord_(ZONE, 'a', aRecord); assert.strictEqual(record.type, 'A'); assert.deepEqual(record.metadata.data, expectedData); @@ -118,16 +118,16 @@ describe('Record', function() { }); describe('aaaa', function() { - var aaaaRecord = { + const aaaaRecord = { ip: '2607:f8b0:400a:801::1005', name: 'name', ttl: 86400, }; - var expectedData = aaaaRecord.ip; + const expectedData = aaaaRecord.ip; it('should parse an AAAA record', function() { - var record = Record.fromZoneRecord_(ZONE, 'aaaa', aaaaRecord); + const record = Record.fromZoneRecord_(ZONE, 'aaaa', aaaaRecord); assert.strictEqual(record.type, 'AAAA'); assert.strictEqual(record.metadata.data, expectedData); @@ -137,16 +137,16 @@ describe('Record', function() { }); describe('cname', function() { - var cnameRecord = { + const cnameRecord = { alias: 'example.com.', name: 'name', ttl: 86400, }; - var expectedData = cnameRecord.alias; + const expectedData = cnameRecord.alias; it('should parse a CNAME record', function() { - var record = Record.fromZoneRecord_(ZONE, 'cname', cnameRecord); + const record = Record.fromZoneRecord_(ZONE, 'cname', cnameRecord); assert.strictEqual(record.type, 'CNAME'); assert.strictEqual(record.metadata.data, expectedData); @@ -156,17 +156,17 @@ describe('Record', function() { }); describe('mx', function() { - var mxRecord = { + const mxRecord = { preference: 0, host: 'mail', name: 'name', ttl: 86400, }; - var expectedData = mxRecord.preference + ' ' + mxRecord.host; + const expectedData = mxRecord.preference + ' ' + mxRecord.host; it('should parse an MX record', function() { - var record = Record.fromZoneRecord_(ZONE, 'mx', mxRecord); + const record = Record.fromZoneRecord_(ZONE, 'mx', mxRecord); assert.strictEqual(record.type, 'MX'); assert.strictEqual(record.metadata.data, expectedData); @@ -176,16 +176,16 @@ describe('Record', function() { }); describe('ns', function() { - var nsRecord = { + const nsRecord = { host: 'example.com', name: 'name', ttl: 86400, }; - var expectedData = nsRecord.host; + const expectedData = nsRecord.host; it('should parse an NS record', function() { - var record = Record.fromZoneRecord_(ZONE, 'ns', nsRecord); + const record = Record.fromZoneRecord_(ZONE, 'ns', nsRecord); assert.strictEqual(record.type, 'NS'); assert.strictEqual(record.metadata.data, expectedData); @@ -195,7 +195,7 @@ describe('Record', function() { }); describe('soa', function() { - var soaRecord = { + const soaRecord = { mname: 'ns1.nameserver.net.', rname: 'hostmaster.mydomain.com.', serial: 86400, @@ -207,7 +207,7 @@ describe('Record', function() { ttl: 86400, }; - var expectedData = [ + const expectedData = [ soaRecord.mname, soaRecord.rname, soaRecord.serial, @@ -218,7 +218,7 @@ describe('Record', function() { ].join(' '); it('should parse an SOA record', function() { - var record = Record.fromZoneRecord_(ZONE, 'soa', soaRecord); + const record = Record.fromZoneRecord_(ZONE, 'soa', soaRecord); assert.strictEqual(record.type, 'SOA'); assert.strictEqual(record.metadata.data, expectedData); @@ -228,16 +228,16 @@ describe('Record', function() { }); describe('spf', function() { - var spfRecord = { + const spfRecord = { data: '"v=spf1" "mx:example.com"', name: 'name', ttl: 86400, }; - var expectedData = spfRecord.data; + const expectedData = spfRecord.data; it('should parse an SPF record', function() { - var record = Record.fromZoneRecord_(ZONE, 'spf', spfRecord); + const record = Record.fromZoneRecord_(ZONE, 'spf', spfRecord); assert.strictEqual(record.type, 'SPF'); assert.strictEqual(record.metadata.data, expectedData); @@ -247,7 +247,7 @@ describe('Record', function() { }); describe('srv', function() { - var srvRecord = { + const srvRecord = { priority: 10, weight: 0, port: 5222, @@ -256,7 +256,7 @@ describe('Record', function() { ttl: 86400, }; - var expectedData = [ + const expectedData = [ srvRecord.priority, srvRecord.weight, srvRecord.port, @@ -264,7 +264,7 @@ describe('Record', function() { ].join(' '); it('should parse an SRV record', function() { - var record = Record.fromZoneRecord_(ZONE, 'srv', srvRecord); + const record = Record.fromZoneRecord_(ZONE, 'srv', srvRecord); assert.strictEqual(record.type, 'SRV'); assert.strictEqual(record.metadata.data, expectedData); @@ -274,16 +274,16 @@ describe('Record', function() { }); describe('txt', function() { - var txtRecord = { + const txtRecord = { txt: 'txt-record-txt', name: 'name', ttl: 86400, }; - var expectedData = txtRecord.txt; + const expectedData = txtRecord.txt; it('should parse a TXT record', function() { - var record = Record.fromZoneRecord_(ZONE, 'txt', txtRecord); + const record = Record.fromZoneRecord_(ZONE, 'txt', txtRecord); assert.strictEqual(record.type, 'TXT'); assert.strictEqual(record.metadata.data, expectedData); @@ -306,7 +306,7 @@ describe('Record', function() { describe('toJSON', function() { it('should format the data for the API', function() { - var expectedRecord = extend({}, METADATA, { + const expectedRecord = extend({}, METADATA, { type: 'A', rrdatas: METADATA.data, }); @@ -318,7 +318,7 @@ describe('Record', function() { describe('toString', function() { it('should format the data for a zonefile', function() { - var jsonRecord = extend({}, METADATA, { + const jsonRecord = extend({}, METADATA, { type: TYPE, rrdatas: ['example.com.', 'example2.com.'], }); @@ -327,7 +327,7 @@ describe('Record', function() { return jsonRecord; }; - var expectedRecordString = [ + const expectedRecordString = [ [ jsonRecord.name, jsonRecord.ttl, diff --git a/test/zone.js b/test/zone.js index 3892f9b..7d3adf5 100644 --- a/test/zone.js +++ b/test/zone.js @@ -16,20 +16,19 @@ 'use strict'; -var arrify = require('arrify'); -var assert = require('assert'); -var exec = require('methmeth'); -var extend = require('extend'); -var flatten = require('lodash.flatten'); -var nodeutil = require('util'); -var prop = require('propprop'); -var proxyquire = require('proxyquire'); -var ServiceObject = require('@google-cloud/common').ServiceObject; -var util = require('@google-cloud/common').util; -var uuid = require('uuid'); - -var promisified = false; -var fakeUtil = extend({}, util, { +const arrify = require('arrify'); +const assert = require('assert'); +const exec = require('methmeth'); +const extend = require('extend'); +const flatten = require('lodash.flatten'); +const nodeutil = require('util'); +const prop = require('propprop'); +const proxyquire = require('proxyquire'); +const {ServiceObject, util} = require('@google-cloud/common'); +const uuid = require('uuid'); + +let promisified = false; +const fakeUtil = extend({}, util, { promisifyAll: function(Class, options) { if (Class.name !== 'Zone') { return; @@ -40,16 +39,16 @@ var fakeUtil = extend({}, util, { }, }); -var parseOverride; -var fakeDnsZonefile = { +let parseOverride; +const fakeDnsZonefile = { parse: function() { return (parseOverride || util.noop).apply(null, arguments); }, }; -var writeFileOverride; -var readFileOverride; -var fakeFs = { +let writeFileOverride; +let readFileOverride; +const fakeFs = { readFile: function() { return (readFileOverride || util.noop).apply(null, arguments); }, @@ -66,7 +65,7 @@ function FakeRecord() { this.calledWith_ = arguments; } FakeRecord.fromZoneRecord_ = function() { - var record = new FakeRecord(); + const record = new FakeRecord(); record.calledWith_ = arguments; return record; }; @@ -78,8 +77,8 @@ function FakeServiceObject() { nodeutil.inherits(FakeServiceObject, ServiceObject); -var extended = false; -var fakePaginator = { +let extended = false; +const fakePaginator = { extend: function(Class, methods) { if (Class.name !== 'Zone') { return; @@ -96,13 +95,13 @@ var fakePaginator = { }; describe('Zone', function() { - var Zone; - var zone; + let Zone; + let zone; - var DNS = { + const DNS = { createZone: util.noop, }; - var ZONE_NAME = 'zone-name'; + const ZONE_NAME = 'zone-name'; before(function() { Zone = proxyquire('../src/zone.js', { @@ -144,7 +143,7 @@ describe('Zone', function() { }); it('should inherit from ServiceObject', function(done) { - var dnsInstance = extend({}, DNS, { + const dnsInstance = extend({}, DNS, { createZone: { bind: function(context) { assert.strictEqual(context, dnsInstance); @@ -153,10 +152,10 @@ describe('Zone', function() { }, }); - var zone = new Zone(dnsInstance, ZONE_NAME); + const zone = new Zone(dnsInstance, ZONE_NAME); assert(zone instanceof ServiceObject); - var calledWith = zone.calledWith_[0]; + const calledWith = zone.calledWith_[0]; assert.strictEqual(calledWith.parent, dnsInstance); assert.strictEqual(calledWith.baseUrl, '/managedZones'); @@ -172,7 +171,7 @@ describe('Zone', function() { describe('addRecords', function() { it('should create a change with additions', function(done) { - var records = ['a', 'b', 'c']; + const records = ['a', 'b', 'c']; zone.createChange = function(options, callback) { assert.strictEqual(options.add, records); @@ -185,9 +184,9 @@ describe('Zone', function() { describe('change', function() { it('should return a Change object', function() { - var changeId = 'change-id'; + const changeId = 'change-id'; - var change = zone.change(changeId); + const change = zone.change(changeId); assert(change instanceof FakeChange); assert.strictEqual(change.calledWith_[0], zone); @@ -220,9 +219,9 @@ describe('Zone', function() { }); it('should parse and rename add to additions', function(done) { - var recordsToAdd = [generateRecord(), generateRecord()]; + const recordsToAdd = [generateRecord(), generateRecord()]; - var expectedAdditions = recordsToAdd.map(exec('toJSON')); + const expectedAdditions = recordsToAdd.map(exec('toJSON')); zone.request = function(reqOpts) { assert.strictEqual(reqOpts.json.add, undefined); @@ -234,9 +233,9 @@ describe('Zone', function() { }); it('should parse and rename delete to deletions', function(done) { - var recordsToDelete = [generateRecord(), generateRecord()]; + const recordsToDelete = [generateRecord(), generateRecord()]; - var expectedDeletions = recordsToDelete.map(exec('toJSON')); + const expectedDeletions = recordsToDelete.map(exec('toJSON')); zone.request = function(reqOpts) { assert.strictEqual(reqOpts.json.delete, undefined); @@ -248,13 +247,13 @@ describe('Zone', function() { }); it('should group changes by name and type', function(done) { - var recordsToAdd = [ + const recordsToAdd = [ generateRecord({name: 'name.com.', type: 'mx'}), generateRecord({name: 'name.com.', type: 'mx'}), ]; zone.request = function(reqOpts) { - var expectedRRDatas = flatten( + const expectedRRDatas = flatten( recordsToAdd.map(exec('toJSON')).map(prop('rrdatas')) ); @@ -284,8 +283,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -303,7 +302,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = {id: 1, a: 'b', c: 'd'}; + const apiResponse = {id: 1, a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -312,7 +311,7 @@ describe('Zone', function() { }); it('should execute callback with Change & API response', function(done) { - var change = {}; + const change = {}; zone.change = function(id) { assert.strictEqual(id, apiResponse.id); @@ -368,7 +367,7 @@ describe('Zone', function() { describe('deleteRecords', function() { it('should delete records by type if a string is given', function(done) { - var recordsToDelete = 'ns'; + const recordsToDelete = 'ns'; zone.deleteRecordsByType_ = function(types, callback) { assert.deepEqual(types, [recordsToDelete]); @@ -379,7 +378,7 @@ describe('Zone', function() { }); it('should create a change if record objects given', function(done) { - var recordsToDelete = {a: 'b', c: 'd'}; + const recordsToDelete = {a: 'b', c: 'd'}; zone.createChange = function(options, callback) { assert.deepEqual(options.delete, [recordsToDelete]); @@ -400,7 +399,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); beforeEach(function() { zone.getRecords = function(callback) { @@ -417,7 +416,7 @@ describe('Zone', function() { }); describe('success', function() { - var records = [ + const records = [ {type: 'A'}, {type: 'AAAA'}, {type: 'CNAME'}, @@ -431,7 +430,7 @@ describe('Zone', function() { {type: 'TXT'}, ]; - var expectedRecordsToDelete = records.filter(function(record) { + const expectedRecordsToDelete = records.filter(function(record) { return record.type !== 'NS' && record.type !== 'SOA'; }); @@ -461,9 +460,9 @@ describe('Zone', function() { }); describe('export', function() { - var path = './zonefile'; + const path = './zonefile'; - var records = [ + const records = [ { toString: function() { return 'a'; @@ -486,7 +485,7 @@ describe('Zone', function() { }, ]; - var expectedZonefileContents = 'a\na\na\na'; + const expectedZonefileContents = 'a\na\na\na'; beforeEach(function() { zone.getRecords = function(callback) { @@ -496,7 +495,7 @@ describe('Zone', function() { describe('get records', function() { describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); it('should execute callback with error', function(done) { zone.getRecords = function(callback) { @@ -535,7 +534,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); beforeEach(function() { writeFileOverride = function(path, content, encoding, callback) { @@ -579,7 +578,7 @@ describe('Zone', function() { }); it('should accept a sort', function(done) { - var query = {sort: 'desc'}; + const query = {sort: 'desc'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.qs.sortOrder, 'descending'); @@ -592,7 +591,7 @@ describe('Zone', function() { }); it('should make the correct API request', function(done) { - var query = {a: 'b', c: 'd'}; + const query = {a: 'b', c: 'd'}; zone.request = function(reqOpts) { assert.strictEqual(reqOpts.uri, '/changes'); @@ -605,8 +604,8 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -624,7 +623,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + const apiResponse = { changes: [{id: 1}], }; @@ -635,11 +634,11 @@ describe('Zone', function() { }); it('should build a nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + const nextPageToken = 'next-page-token'; + const apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = { + const expectedNextQuery = { pageToken: nextPageToken, }; @@ -657,7 +656,7 @@ describe('Zone', function() { }); it('should execute callback with Changes & API response', function(done) { - var change = {}; + const change = {}; zone.change = function(id) { assert.strictEqual(id, apiResponse.changes[0].id); @@ -680,8 +679,8 @@ describe('Zone', function() { describe('getRecords', function() { describe('error', function() { - var error = new Error('Error.'); - var apiResponse = {a: 'b', c: 'd'}; + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; beforeEach(function() { zone.request = function(reqOpts, callback) { @@ -706,7 +705,7 @@ describe('Zone', function() { }); describe('success', function() { - var apiResponse = { + const apiResponse = { rrsets: [{type: 'NS'}], }; @@ -717,11 +716,11 @@ describe('Zone', function() { }); it('should execute callback with nextQuery if necessary', function(done) { - var nextPageToken = 'next-page-token'; - var apiResponseWithNextPageToken = extend({}, apiResponse, { + const nextPageToken = 'next-page-token'; + const apiResponseWithNextPageToken = extend({}, apiResponse, { nextPageToken: nextPageToken, }); - var expectedNextQuery = {pageToken: nextPageToken}; + const expectedNextQuery = {pageToken: nextPageToken}; zone.request = function(reqOpts, callback) { callback(null, apiResponseWithNextPageToken); @@ -737,7 +736,7 @@ describe('Zone', function() { }); it('should execute callback with Records & API response', function(done) { - var record = {}; + const record = {}; zone.record = function(type, recordObject) { assert.strictEqual(type, apiResponse.rrsets[0].type); @@ -762,7 +761,7 @@ describe('Zone', function() { describe('filtering', function() { it('should accept a string type', function(done) { - var types = ['MX', 'CNAME']; + const types = ['MX', 'CNAME']; zone.getRecords(types, function(err, records) { assert.ifError(err); @@ -774,7 +773,7 @@ describe('Zone', function() { }); it('should accept an array of types', function(done) { - var type = 'MX'; + const type = 'MX'; zone.getRecords(type, function(err, records) { assert.ifError(err); @@ -798,7 +797,7 @@ describe('Zone', function() { }); describe('import', function() { - var path = './zonefile'; + const path = './zonefile'; it('should read from the file', function(done) { readFileOverride = function(path_, encoding) { @@ -811,7 +810,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); beforeEach(function() { readFileOverride = function(path, encoding, callback) { @@ -828,8 +827,8 @@ describe('Zone', function() { }); describe('success', function() { - var recordType = 'ns'; - var parsedZonefile = {}; + const recordType = 'ns'; + let parsedZonefile = {}; beforeEach(function() { parsedZonefile = { @@ -849,11 +848,11 @@ describe('Zone', function() { zone.addRecords = function(recordsToCreate, callback) { assert.strictEqual(recordsToCreate.length, 1); - var recordToCreate = recordsToCreate[0]; + const recordToCreate = recordsToCreate[0]; assert(recordToCreate instanceof FakeRecord); - var args = recordToCreate.calledWith_; + const args = recordToCreate.calledWith_; assert.strictEqual(args[0], zone); assert.strictEqual(args[1], recordType); assert.strictEqual(args[2], parsedZonefile[recordType]); @@ -865,17 +864,17 @@ describe('Zone', function() { }); it('should use the default ttl', function(done) { - var defaultTTL = '90'; + const defaultTTL = '90'; parsedZonefile.$ttl = defaultTTL; parsedZonefile[recordType] = {}; parsedZonefile.mx = {ttl: '180'}; zone.addRecords = function(recordsToCreate) { - var record1 = recordsToCreate[0].calledWith_[2]; + const record1 = recordsToCreate[0].calledWith_[2]; assert.strictEqual(record1.ttl, defaultTTL); - var record2 = recordsToCreate[1].calledWith_[2]; + const record2 = recordsToCreate[1].calledWith_[2]; assert.strictEqual(record2.ttl, '180'); done(); @@ -888,14 +887,14 @@ describe('Zone', function() { describe('record', function() { it('should return a Record object', function() { - var type = 'a'; - var metadata = {a: 'b', c: 'd'}; + const type = 'a'; + const metadata = {a: 'b', c: 'd'}; - var record = zone.record(type, metadata); + const record = zone.record(type, metadata); assert(record instanceof FakeRecord); - var args = record.calledWith_; + const args = record.calledWith_; assert.strictEqual(args[0], zone); assert.strictEqual(args[1], type); assert.strictEqual(args[2], metadata); @@ -904,7 +903,7 @@ describe('Zone', function() { describe('replaceRecords', function() { it('should get records', function(done) { - var recordType = 'ns'; + const recordType = 'ns'; zone.getRecords = function(recordType_) { assert.strictEqual(recordType_, recordType); @@ -915,7 +914,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); beforeEach(function() { zone.getRecords = function(recordType, callback) { @@ -932,13 +931,13 @@ describe('Zone', function() { }); describe('success', function() { - var recordsToCreate = [ + const recordsToCreate = [ {a: 'b', c: 'd'}, {a: 'b', c: 'd'}, {a: 'b', c: 'd'}, ]; - var recordsToDelete = [ + const recordsToDelete = [ {a: 'b', c: 'd'}, {a: 'b', c: 'd'}, {a: 'b', c: 'd'}, @@ -965,7 +964,7 @@ describe('Zone', function() { describe('deleteRecordsByType_', function() { it('should get records', function(done) { - var recordType = 'ns'; + const recordType = 'ns'; zone.getRecords = function(recordType_) { assert.strictEqual(recordType_, recordType); @@ -976,7 +975,7 @@ describe('Zone', function() { }); describe('error', function() { - var error = new Error('Error.'); + const error = new Error('Error.'); beforeEach(function() { zone.getRecords = function(recordType, callback) { @@ -993,7 +992,7 @@ describe('Zone', function() { }); describe('success', function() { - var recordsToDelete = [ + const recordsToDelete = [ {a: 'b', c: 'd'}, {a: 'b', c: 'd'}, {a: 'b', c: 'd'},