Tests for registry-cli #32

Closed
0xmuralik wants to merge 23 commits from murali/tests into main
Showing only changes of commit 85411f3b06 - Show all commits

View File

@ -1,45 +1,56 @@
import {cliTest,createBond,createRecord} from './helper'; import {cliTest,createAuthority,createBond,createRecord} from './helper';
const args= "name "; const args= "name ";
const name="laconic-name"; const name=`laconic-${Date.now()}`;
const crn=`crn://${name}/app/test`; const crn=`crn://${name}/app/test`;
var recordId: string; var recordId: string;
var bondId: string;
describe("test names",() => { describe("test names",() => {
beforeAll(async () => { beforeAll(async () => {
// get bond id // get bond id
const bondId = createBond("aphoton","10000000") bondId = createBond("aphoton","10000000")
// get record id // get record id
recordId=createRecord("./test/examples/watcher.yml",bondId) recordId=createRecord("./test/examples/watcher.yml",bondId)
// reserve authority // reserve authority
cliTest("authority reserve "+name); createAuthority(name)
// set authority bond // set authority bond
cliTest(args+"bond set "+name+" "+bondId); const resp=cliTest("authority bond set "+name+" "+bondId);
expect(resp).toBeDefined();
expect(resp.success).toBeTruthy();
}); });
it("set name",async ()=>{ it("set name",async ()=>{
const resp=cliTest(args+"set "+crn+" "+recordId); const resp=cliTest(args+"set "+crn+" "+recordId);
expect(resp).toBeDefined; expect(resp).toBeDefined();
expect(resp.success).toBeTruthy();
}); });
it("lookup name",async ()=>{ it("lookup name",async ()=>{
const resp=cliTest(args+"lookup "+ crn); const resp=cliTest(args+"lookup "+ crn);
expect(resp).toBeDefined; expect(resp).toBeDefined();
expect(resp[0].latest.id).toEqual(recordId)
}); });
it("resolve name",async ()=>{ it("resolve name",async ()=>{
const resp=cliTest(args+"resolve "+crn); const resp=cliTest(args+"resolve "+crn);
expect(resp).toBeDefined; expect(resp).toBeDefined();
expect(resp[0].id).toEqual(recordId)
}); });
it("delelte name",async ()=>{ it("delete name",async ()=>{
const resp=cliTest(args+"delete "+crn); const resp=cliTest(args+"delete "+crn);
expect(resp).toBeDefined; expect(resp).toBeDefined();
expect(resp.success).toBeTruthy();
const resolve=cliTest(args+"resolve "+crn);
expect(resolve).toBeDefined();
expect(resolve[0]).toBeNull();
}); });
}); });