Skip to content

Commit

Permalink
fix type errors on test files
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Jan 16, 2025
1 parent 1baa0cd commit c17870c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/functional/collections/GetCollectionFacets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/functional/collections/GetCollectionItems.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/functional/collections/UpdateCollection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions test/functional/datasets/CreateDataset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 7 additions & 5 deletions test/unit/datasets/DatasetResourceValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit c17870c

Please sign in to comment.