From 37c577fb1df2b84f5470a364193b6f0ac5d66ebe Mon Sep 17 00:00:00 2001 From: 0xmuralik Date: Mon, 30 Jan 2023 16:00:13 +0530 Subject: [PATCH] fix sdk tests --- src/sdk.test.ts | 74 +++++++++---------- .../examples/website_registration_example.yml | 2 +- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/sdk.test.ts b/src/sdk.test.ts index 48bc5ad..6f0d01e 100644 --- a/src/sdk.test.ts +++ b/src/sdk.test.ts @@ -33,48 +33,48 @@ describe('Querying', () => { expect(registry.chainID).toBe(chainId); }); - // test('Get status.', async () => { - // const status = await registry.getStatus(); - // expect(status).toBeDefined(); - // expect(status.version).toBeDefined(); - // }); + test('Get status.', async () => { + const status = await registry.getStatus(); + expect(status).toBeDefined(); + expect(status.version).toBeDefined(); + }); - // test('List records.', async () => { - // const records = await registry.queryRecords({}, true); - // expect(records.length).toBeGreaterThanOrEqual(1); - // }); + test('List records.', async () => { + const records = await registry.queryRecords({}, true); + expect(records.length).toBeGreaterThanOrEqual(1); + }); - // test('Query records by reference.', async () => { - // const { repo_registration_record_cid } = watcher.record; - // const records = await registry.queryRecords({ repo_registration_record_cid }, true); - // expect(records.length).toBeGreaterThanOrEqual(1); + test('Query records by reference.', async () => { + const { ref } = watcher.record.repo_reference; + const records = await registry.queryRecords({ "repo_reference---ref---": ref}, true); + expect(records.length).toBeGreaterThanOrEqual(1); - // const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0]; - // expect(repo_registration_record_cid).toBe(record_repo_registration_record_cid); - // }); + const { attributes: { repo_reference: {ref: record_repo_registration_record_cid} } } = records[0]; + expect(ref).toBe(record_repo_registration_record_cid); + }); - // test('Query records by attributes.', async () => { - // const { version, name } = watcher.record; - // const records = await registry.queryRecords({ version, name }, true); - // expect(records.length).toBe(1); + test('Query records by attributes.', async () => { + const { version, name } = watcher.record; + const records = await registry.queryRecords({ "version---": version, "name---": name }, true); + expect(records.length).toBe(1); - // [ watcher ] = records; - // const { attributes: { version: recordVersion, name: recordName } } = watcher; - // expect(recordVersion).toBe(version); - // expect(recordName).toBe(name); - // }); + [ watcher ] = records; + const { attributes: { version: recordVersion, name: recordName } } = watcher; + expect(recordVersion).toBe(version); + expect(recordName).toBe(name); + }); - // test('Query records by id.', async () => { - // const records = await registry.getRecordsByIds([watcher.id]); - // expect(records.length).toBe(1); - // expect(records[0].id).toBe(watcher.id); - // }); + test('Query records by id.', async () => { + const records = await registry.getRecordsByIds([watcher.id]); + expect(records.length).toBe(1); + expect(records[0].id).toBe(watcher.id); + }); - // test('Query records passing refs true.', async () => { - // const [record] = await registry.getRecordsByIds([watcher.id], true); - // expect(record.id).toBe(watcher.id); - // // temp fix - // expect(record.attributes.repo_registration_record_cid).toBeDefined(); - // expect(record.attributes.repo_registration_record_cid).toHaveLength(46); - // }); + test('Query records passing refs true.', async () => { + const [record] = await registry.getRecordsByIds([watcher.id], true); + expect(record.id).toBe(watcher.id); + // temp fix + expect(record.attributes.repo_reference.ref).toBeDefined(); + expect(record.attributes.repo_reference.ref).toHaveLength(46); + }); }); diff --git a/src/testing/examples/website_registration_example.yml b/src/testing/examples/website_registration_example.yml index 178b036..60b9001 100644 --- a/src/testing/examples/website_registration_example.yml +++ b/src/testing/examples/website_registration_example.yml @@ -7,4 +7,4 @@ record: ref: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9 tls_cert_ref: ref: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR - version: 1.0.23 + version: 1.0.28