cloudflare/test/test.ts

89 lines
3.3 KiB
TypeScript
Raw Normal View History

2016-05-24 21:36:06 +00:00
import "typings-test";
2016-05-15 17:51:48 +00:00
import cflare = require("../dist/index");
2016-05-16 01:29:29 +00:00
let should = require("should");
2016-06-20 20:56:09 +00:00
import {Qenv} from "qenv";
let testQenv = new Qenv(process.cwd(),process.cwd() + "/.nogit");
2016-06-21 17:04:43 +00:00
console.log(testQenv.missingEnvVars);
2016-05-15 17:51:48 +00:00
let testCflareAccount = new cflare.CflareAccount();
testCflareAccount.auth({
2016-06-20 20:56:09 +00:00
email: process.env.CF_EMAIL,
key: process.env.CF_KEY
2016-05-15 17:51:48 +00:00
});
2016-05-16 01:29:29 +00:00
describe("cflare",function(){
describe(".CflareAccount",function(){
describe(".listZones()",function(){
2016-06-21 17:04:43 +00:00
it("should display an entire account",function(done){
2016-05-16 01:29:29 +00:00
this.timeout(10000);
testCflareAccount.listZones()
.then((responseArg)=>{
console.log(responseArg);
done();
})
});
});
describe(".getZoneId(domainName)",function(){
it("should get an Cloudflare Id for a domain string",function(done){
2016-05-24 21:36:06 +00:00
this.timeout(10000)
2016-06-20 20:56:09 +00:00
testCflareAccount.getZoneId("bleu.de")
2016-05-16 01:29:29 +00:00
.then((responseArg)=>{
console.log(responseArg);
done();
});
});
});
describe(".listRecords(domainName)",function(){
it("should list all records for a specific Domain Name",function(done){
2016-05-24 21:36:06 +00:00
this.timeout(10000);
2016-06-20 20:56:09 +00:00
testCflareAccount.listRecords("bleu.de")
2016-05-16 01:29:29 +00:00
.then((responseArg) => {
console.log(responseArg);
done();
});
});
})
2016-05-24 21:36:06 +00:00
describe(".createRecord",function(){
this.timeout(10000);
2016-05-25 04:26:48 +00:00
it("should create a valid record for a level 2 domain",function(done){
2016-05-24 21:36:06 +00:00
testCflareAccount.createRecord("bleu.de","A","127.0.0.1")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
2016-05-25 04:26:48 +00:00
it("should create a valid record for a subdomain",function(done){
testCflareAccount.createRecord("subdomain.bleu.de","A","127.0.0.1")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
2016-05-24 21:36:06 +00:00
});
2016-06-21 17:04:43 +00:00
describe(".getRecord",function(){
it("should get a record from Cloudflare",function(done){
testCflareAccount.getRecord("bleu.de","A")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
});
2016-05-24 21:36:06 +00:00
describe(".removeRecord",function(){
2016-06-21 17:04:43 +00:00
it("should remove a record from Cloudflare",function(done){
testCflareAccount.removeRecord("bleu.de","A")
2016-05-24 21:36:06 +00:00
.then(function(responseArg){
console.log(responseArg);
done();
2016-05-25 04:26:48 +00:00
});
2016-06-21 17:04:43 +00:00
});
it("should remove a subdomain record from Cloudflare",function(done){
testCflareAccount.removeRecord("subdomain.bleu.de","A")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
2016-05-24 21:36:06 +00:00
});
2016-05-16 01:29:29 +00:00
})
});