smartdns/test/test.js

49 lines
3.7 KiB
JavaScript
Raw Permalink Normal View History

2016-11-15 20:39:21 +00:00
"use strict";
require("typings-test");
const should = require("should");
const dnsly = require("../dist/index");
let testDnsly;
describe('dnsly', function () {
it('should create an instance of Dnsly', function () {
testDnsly = new dnsly.Dnsly('google');
should(testDnsly).be.instanceOf(dnsly.Dnsly);
});
it('should, get a dns record for a domain when called quickly', function (done) {
testDnsly.getRecord('google.com', 'A').then(res => {
console.log(res);
done();
}).catch(err => {
console.log(err);
done(err);
});
});
it('should, get a dns record for a domain when called with timeout', function (done) {
setTimeout(() => {
testDnsly.getRecord('google.com', 'A').then(res => {
console.log(res);
done();
}).catch(err => {
console.log(err);
done(err);
});
}, 1000);
});
it('should get a dns record for a domain when called with second instance and timeout', function (done) {
this.timeout(10000);
let testDnsly2 = new dnsly.Dnsly('google');
setTimeout(() => {
testDnsly2.getRecord('google.com', 'MX').then(res => {
console.log(res);
done();
testDnsly2.close();
}).catch(err => {
console.log(err);
done(err);
});
}, 5000);
});
it('should close the instance', function () {
testDnsly.close();
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMsdUNBQXNDO0FBRXRDLElBQUksU0FBc0IsQ0FBQTtBQUUxQixRQUFRLENBQUMsT0FBTyxFQUFFO0lBQ2QsRUFBRSxDQUFDLG9DQUFvQyxFQUFFO1FBQ3JDLFNBQVMsR0FBRyxJQUFJLEtBQUssQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUE7UUFDckMsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2hELENB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