From 85411f3b066088236804916ba07592ed96f4299e Mon Sep 17 00:00:00 2001 From: 0xmuralik Date: Fri, 31 Mar 2023 23:53:15 +0530 Subject: [PATCH] name tests --- test/name.test.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/test/name.test.ts b/test/name.test.ts index 5718ae2..f4e3449 100644 --- a/test/name.test.ts +++ b/test/name.test.ts @@ -1,45 +1,56 @@ -import {cliTest,createBond,createRecord} from './helper'; +import {cliTest,createAuthority,createBond,createRecord} from './helper'; const args= "name "; -const name="laconic-name"; +const name=`laconic-${Date.now()}`; const crn=`crn://${name}/app/test`; var recordId: string; +var bondId: string; describe("test names",() => { beforeAll(async () => { // get bond id - const bondId = createBond("aphoton","10000000") + bondId = createBond("aphoton","10000000") // get record id recordId=createRecord("./test/examples/watcher.yml",bondId) // reserve authority - cliTest("authority reserve "+name); + createAuthority(name) // 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 ()=>{ const resp=cliTest(args+"set "+crn+" "+recordId); - expect(resp).toBeDefined; + expect(resp).toBeDefined(); + expect(resp.success).toBeTruthy(); }); it("lookup name",async ()=>{ const resp=cliTest(args+"lookup "+ crn); - expect(resp).toBeDefined; + expect(resp).toBeDefined(); + expect(resp[0].latest.id).toEqual(recordId) }); it("resolve name",async ()=>{ 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); - expect(resp).toBeDefined; + expect(resp).toBeDefined(); + expect(resp.success).toBeTruthy(); + + const resolve=cliTest(args+"resolve "+crn); + expect(resolve).toBeDefined(); + expect(resolve[0]).toBeNull(); }); }); \ No newline at end of file