From c17870c75060f54128d079c904a08444a2eb3cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Saracca?= Date: Thu, 16 Jan 2025 15:39:55 -0300 Subject: [PATCH] fix type errors on test files --- .../collections/GetCollectionFacets.test.ts | 2 +- .../collections/GetCollectionItems.test.ts | 2 +- .../collections/GetCollectionUserPermissions.test.ts | 2 +- test/functional/collections/UpdateCollection.test.ts | 2 +- test/functional/datasets/CreateDataset.test.ts | 6 +++--- .../GetCollectionMetadataBlocks.test.ts | 2 +- test/unit/datasets/DatasetResourceValidator.test.ts | 12 +++++++----- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/test/functional/collections/GetCollectionFacets.test.ts b/test/functional/collections/GetCollectionFacets.test.ts index 3c1a2c3b..a4b2a970 100644 --- a/test/functional/collections/GetCollectionFacets.test.ts +++ b/test/functional/collections/GetCollectionFacets.test.ts @@ -32,7 +32,7 @@ describe('execute', () => { await getCollectionFacets.execute(TestConstants.TEST_DUMMY_COLLECTION_ID) throw new Error('Use case should throw an error') } catch (error) { - readError = error + readError = error as ReadError } finally { expect(readError).toBeInstanceOf(ReadError) expect(readError?.message).toEqual( diff --git a/test/functional/collections/GetCollectionItems.test.ts b/test/functional/collections/GetCollectionItems.test.ts index 1bcbbdcf..15e2814f 100644 --- a/test/functional/collections/GetCollectionItems.test.ts +++ b/test/functional/collections/GetCollectionItems.test.ts @@ -80,7 +80,7 @@ describe('execute', () => { await getCollectionItems.execute(TestConstants.TEST_DUMMY_COLLECTION_ALIAS) throw new Error('Use case should throw an error') } catch (error) { - readError = error + readError = error as ReadError } finally { expect(readError).toBeInstanceOf(ReadError) expect(readError?.message).toEqual( diff --git a/test/functional/collections/GetCollectionUserPermissions.test.ts b/test/functional/collections/GetCollectionUserPermissions.test.ts index 68d365cc..17493856 100644 --- a/test/functional/collections/GetCollectionUserPermissions.test.ts +++ b/test/functional/collections/GetCollectionUserPermissions.test.ts @@ -51,7 +51,7 @@ describe('execute', () => { await getCollectionUserPermissions.execute(TestConstants.TEST_DUMMY_COLLECTION_ID) throw new Error('Use case should throw an error') } catch (error) { - readError = error + readError = error as ReadError } finally { expect(readError).toBeInstanceOf(ReadError) expect(readError?.message).toEqual( diff --git a/test/functional/collections/UpdateCollection.test.ts b/test/functional/collections/UpdateCollection.test.ts index e14450f2..ac5f47e9 100644 --- a/test/functional/collections/UpdateCollection.test.ts +++ b/test/functional/collections/UpdateCollection.test.ts @@ -43,7 +43,7 @@ describe('execute', () => { await updateCollection.execute(TestConstants.TEST_DUMMY_COLLECTION_ID, testNewCollection) throw new Error('Use case should throw an error') } catch (error) { - writeError = error + writeError = error as WriteError } finally { expect(writeError).toBeInstanceOf(WriteError) expect(writeError?.message).toEqual( diff --git a/test/functional/datasets/CreateDataset.test.ts b/test/functional/datasets/CreateDataset.test.ts index b1af9f9a..f90eff00 100644 --- a/test/functional/datasets/CreateDataset.test.ts +++ b/test/functional/datasets/CreateDataset.test.ts @@ -99,7 +99,7 @@ describe('execute', () => { await createDataset.execute(testNewDataset) throw new Error('Use case should throw an error') } catch (error) { - fieldValidationError = error + fieldValidationError = error as FieldValidationError } finally { expect(fieldValidationError).toBeInstanceOf(FieldValidationError) expect(fieldValidationError?.citationBlockName).toEqual('citation') @@ -149,7 +149,7 @@ describe('execute', () => { await createDataset.execute(testNewDataset) throw new Error('Use case should throw an error') } catch (error) { - fieldValidationError = error + fieldValidationError = error as FieldValidationError } finally { expect(fieldValidationError).toBeInstanceOf(FieldValidationError) expect(fieldValidationError?.citationBlockName).toEqual('citation') @@ -201,7 +201,7 @@ describe('execute', () => { await createDataset.execute(testNewDataset) throw new Error('Use case should throw an error') } catch (error) { - fieldValidationError = error + fieldValidationError = error as FieldValidationError } finally { expect(fieldValidationError).toBeInstanceOf(FieldValidationError) expect(fieldValidationError?.citationBlockName).toEqual('citation') diff --git a/test/functional/metadataBlocks/GetCollectionMetadataBlocks.test.ts b/test/functional/metadataBlocks/GetCollectionMetadataBlocks.test.ts index 0d9b14ec..32ed08e4 100644 --- a/test/functional/metadataBlocks/GetCollectionMetadataBlocks.test.ts +++ b/test/functional/metadataBlocks/GetCollectionMetadataBlocks.test.ts @@ -31,7 +31,7 @@ describe('execute', () => { await getCollectionMetadataBlocks.execute('notFoundCollectionAlias') throw new Error('Use case should throw an error') } catch (error) { - readError = error + readError = error as ReadError } finally { expect(readError).toBeInstanceOf(ReadError) expect(readError?.message).toEqual( diff --git a/test/unit/datasets/DatasetResourceValidator.test.ts b/test/unit/datasets/DatasetResourceValidator.test.ts index 7dbd78b5..72113a69 100644 --- a/test/unit/datasets/DatasetResourceValidator.test.ts +++ b/test/unit/datasets/DatasetResourceValidator.test.ts @@ -35,11 +35,13 @@ describe('validate', () => { throw new Error('Validation should fail') } catch (error) { expect(error).toBeInstanceOf(FieldValidationError) - expect(error.citationBlockName).toEqual('citation') - expect(error.metadataFieldName).toEqual(expectedMetadataFieldName) - expect(error.parentMetadataFieldName).toEqual(expectedParentMetadataFieldName) - expect(error.fieldPosition).toEqual(expectedPosition) - expect(error.message).toEqual(expectedErrorMessage) + expect((error as FieldValidationError)?.citationBlockName).toEqual('citation') + expect((error as FieldValidationError)?.metadataFieldName).toEqual(expectedMetadataFieldName) + expect((error as FieldValidationError)?.parentMetadataFieldName).toEqual( + expectedParentMetadataFieldName + ) + expect((error as FieldValidationError)?.fieldPosition).toEqual(expectedPosition) + expect((error as FieldValidationError)?.message).toEqual(expectedErrorMessage) } }