Skip to content

Commit

Permalink
Configure Jest ESLint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wcalderipe committed Feb 16, 2024
1 parent d81770b commit 1f274bf
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 11 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"plugins": ["@nx", "jest"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down Expand Up @@ -48,7 +48,13 @@
"env": {
"jest": true
},
"rules": {}
"rules": {
"jest/consistent-test-it": "error",
"jest/no-disabled-tests": "error",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/valid-expect": "error"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe(AuthorizationRequestService.name, () => {
})

it('throws AuthorizationRequestAlreadyProcessingException when status is PROCESSING', async () => {
expect(
await expect(
service.evaluate({
...authzRequest,
status: AuthorizationRequestStatus.PROCESSING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ describe(ClusterService.name, () => {
authzApplicationClientMock.evaluation.mockResolvedValue(evaluationResponse)
})

it('throws when organization cluster is not found', () => {
it('throws when organization cluster is not found', async () => {
jest.spyOn(service, 'getByOrgId').mockResolvedValue(null)

expect(service.evaluation(input)).rejects.toThrow(ClusterNotFoundException)
await expect(service.evaluation(input)).rejects.toThrow(ClusterNotFoundException)
})

it('responds with the first response from the cluster', async () => {
Expand Down Expand Up @@ -161,7 +161,7 @@ describe(ClusterService.name, () => {
authzApplicationClientMock.evaluation.mockResolvedValueOnce(permit)
authzApplicationClientMock.evaluation.mockResolvedValueOnce(forbid)

expect(service.evaluation(input)).rejects.toThrow(ConsensusAgreementNotReachException)
await expect(service.evaluation(input)).rejects.toThrow(ConsensusAgreementNotReachException)
})

it('throws when node attestation is invalid', async () => {
Expand All @@ -179,7 +179,7 @@ describe(ClusterService.name, () => {
}
})

expect(service.evaluation(input)).rejects.toThrow(InvalidAttestationSignatureException)
await expect(service.evaluation(input)).rejects.toThrow(InvalidAttestationSignatureException)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe(AuthorizationRequestProcessingConsumer.name, () => {
const error = new Error('unknown error')
jest.spyOn(service, 'process').mockRejectedValue(error)

expect(consumer.process(job)).rejects.toThrow(error)
await expect(consumer.process(job)).rejects.toThrow(error)
})

it('stops retrying on known unrecoverable errors', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ describe(PriceService.name, () => {
})
})

it('throws PriceException when given asset id does not exist on coin gecko index', () => {
expect(() =>
it('throws PriceException when given asset id does not exist on coin gecko index', async () => {
await expect(() =>
service.getPrices({
from: [getAssetId('eip155:00000/erc20:0x0000000000000000000000000000000000000000')],
to: [FIAT_ID_USD]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe(CoinGeckoClient.name, () => {
boom: 'something went wrong'
})

expect(() => {
await expect(() => {
return client.getSimplePrice({
url: CoinGeckoClient.V3_URL,
data: {
Expand Down
169 changes: 169 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"eslint": "~8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jest": "^27.8.0",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-playwright": "^0.22.2",
"eslint-plugin-react": "7.32.2",
Expand Down

0 comments on commit 1f274bf

Please sign in to comment.