From b3be6f9f4cc11ff760e55ce4bd6e292c565baa1b Mon Sep 17 00:00:00 2001 From: Nick Angelou Date: Thu, 23 May 2024 10:52:11 +0700 Subject: [PATCH] attempt to fix race condition in tests --- src/__tests__/cipher-text.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/__tests__/cipher-text.test.ts b/src/__tests__/cipher-text.test.ts index 4759083..ed5cc32 100644 --- a/src/__tests__/cipher-text.test.ts +++ b/src/__tests__/cipher-text.test.ts @@ -64,17 +64,17 @@ describe('CipherText', () => { expect(seal.CipherText.constructor.name).toBe('Function') }) test('It should construct an instance', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(() => seal.CipherText()) Constructor() expect(Constructor).toHaveBeenCalledWith() }) test('It should construct an instance with a bfvContext', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(options => seal.CipherText(options)) Constructor({ context: bfvContext }) expect(Constructor).toHaveBeenCalledWith({ context: bfvContext }) }) test('It should construct an instance with a bfvContext, parmsId', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(options => seal.CipherText(options)) const parmsId = bfvContext.firstParmsId Constructor({ context: bfvContext, parmsId }) expect(Constructor).toHaveBeenCalledWith({ @@ -83,7 +83,7 @@ describe('CipherText', () => { }) }) test('It should construct an instance with a bfvContext, parmsId, sizeCapacity', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(options => seal.CipherText(options)) const parmsId = bfvContext.firstParmsId Constructor({ context: bfvContext, parmsId, sizeCapacity: 2 }) expect(Constructor).toHaveBeenCalledWith({ @@ -93,7 +93,7 @@ describe('CipherText', () => { }) }) test('It should fail to construct an instance from invalid parameters', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(options => seal.CipherText(options)) expect(() => Constructor({ context: bfvContext, sizeCapacity: 2 }) ).toThrow() @@ -103,7 +103,7 @@ describe('CipherText', () => { }) }) test('It should fail to construct an instance from bad parameters', () => { - const Constructor = jest.fn(seal.CipherText) + const Constructor = jest.fn(options => seal.CipherText(options)) const parmsId = bfvContext.firstParmsId expect(() => Constructor({ context: bfvContext, parmsId, sizeCapacity: -2 })