diff --git a/packages/modules/packages/diviner/packages/payload/packages/generic/src/spec/Diviner.spec.ts b/packages/modules/packages/diviner/packages/payload/packages/generic/src/spec/Diviner.spec.ts index 305358a5fd..d05f854ad4 100644 --- a/packages/modules/packages/diviner/packages/payload/packages/generic/src/spec/Diviner.spec.ts +++ b/packages/modules/packages/diviner/packages/payload/packages/generic/src/spec/Diviner.spec.ts @@ -79,39 +79,37 @@ describe('GenericPayloadDiviner', () => { describe('single', () => { it.each(['network.xyo.test', 'network.xyo.debug'])('only returns payloads of that schema', async (schema) => { const schemas = [schema] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) - .fields({ schemas }) - .build() + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }).fields({ schemas }).build() const results = await sut.divine([query]) expect(results.length).toBeGreaterThan(0) expect(results.every(result => result.schema === schema)).toBe(true) }) it('only return single payload of that schema', async () => { const schemas = ['network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 1, schemas }) .build() const results = await sut.divine([query]) expect(results.length).toBe(1) - expect(await PayloadBuilder.dataHash(results[0])).toBe(await PayloadBuilder.dataHash(payloadD)) + expect(await PayloadBuilder.dataHash(results[0])).toBe(await PayloadBuilder.dataHash(insertedPayloads[3])) expect(results.every(result => result.schema === 'network.xyo.debug')).toBe(true) }) it('only return single payload of that schema (desc)', async () => { const schemas = ['network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 1, order: 'desc', schemas, }) .build() const results = await sut.divine([query]) expect(results.length).toBe(1) - expect(PayloadBuilder.omitStorageMeta(results[0])).toStrictEqual(payloadD) - expect(await PayloadBuilder.dataHash(results[0])).toBe(await PayloadBuilder.dataHash(payloadD)) + expect(PayloadBuilder.omitStorageMeta(results[0])).toStrictEqual(insertedPayloads[3]) + expect(await PayloadBuilder.dataHash(results[0])).toBe(await PayloadBuilder.dataHash(insertedPayloads[3])) expect(results.every(result => result.schema === 'network.xyo.debug')).toBe(true) }) it('only return single payload of that schema (asc)', async () => { const schemas = ['network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 1, order: 'asc', schemas, }) @@ -126,7 +124,7 @@ describe('GenericPayloadDiviner', () => { describe('multiple', () => { it('only returns payloads of that schema', async () => { const schemas = ['network.xyo.test', 'network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ schemas }) .build() const results = await sut.divine([query]) @@ -137,7 +135,7 @@ describe('GenericPayloadDiviner', () => { describe('paging', () => { it('test paging with multiple calls (asc)', async () => { const schemas = ['network.xyo.test', 'network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, order: 'asc', schemas, }) @@ -151,7 +149,7 @@ describe('GenericPayloadDiviner', () => { expect(resultSequences[1]).toBe(insertedPayloads[1]._sequence) const cursor = resultSequences[1] - const query2 = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query2 = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, cursor, order: 'asc', schemas, }) @@ -163,7 +161,7 @@ describe('GenericPayloadDiviner', () => { expect(resultSequences2[1]).toBe(insertedPayloads[3]._sequence) const cursor2 = resultSequences2[1] - const query3 = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query3 = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, cursor: cursor2, order: 'asc', schemas, }) @@ -173,7 +171,7 @@ describe('GenericPayloadDiviner', () => { }) it('test paging with multiple calls (desc)', async () => { const schemas = ['network.xyo.test', 'network.xyo.debug'] - const query = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, order: 'desc', schemas, }) @@ -185,7 +183,7 @@ describe('GenericPayloadDiviner', () => { expect(resultSequences[1]).toBe(insertedPayloads[2]._sequence) const cursor = resultSequences[1] - const query2 = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query2 = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, cursor, order: 'desc', schemas, }) @@ -197,7 +195,7 @@ describe('GenericPayloadDiviner', () => { expect(resultSequences2[1]).toBe(insertedPayloads[0]._sequence) const cursor2 = resultSequences2[1] - const query3 = new PayloadBuilder>({ schema: PayloadDivinerQuerySchema }) + const query3 = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ limit: 2, cursor: cursor2, order: 'desc', schemas, }) @@ -212,7 +210,7 @@ describe('GenericPayloadDiviner', () => { it('only returns payloads with that property', async () => { type WithUrl = { url?: string } const url = payloadA.url - const query = new PayloadBuilder & WithUrl>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ url }) .build() const results = await sut.divine([query]) @@ -224,7 +222,7 @@ describe('GenericPayloadDiviner', () => { const cases: string[][] = [['bar'], ['baz'], ['bar', 'baz']] it.each(cases)('only returns payloads that have an array containing all the values supplied', async (...foo) => { type WithFoo = { foo?: string[] } - const query = new PayloadBuilder & WithFoo>({ schema: PayloadDivinerQuerySchema }) + const query = new PayloadBuilder({ schema: PayloadDivinerQuerySchema }) .fields({ foo }) .build() const results = await sut.divine([query])