Skip to content

Commit

Permalink
Merge pull request #15 from trade-tariff/FPO-132-backfill-test-coverage
Browse files Browse the repository at this point in the history
FPO-132: Fixes test setup
  • Loading branch information
willfish authored Mar 27, 2024
2 parents d50f700 + b79240f commit 63229b4
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AWS_REGION=eu-west-2
ENCRYPTION_KEY=Ur2w/rJWwRiLS4LEorod0t8PCgi7mZL9AdfCHwXviRo=
export AWS_REGION=eu-west-2
export ENCRYPTION_KEY=Ur2w/rJWwRiLS4LEorod0t8PCgi7mZL9AdfCHwXviRo=
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ module.exports = {
],
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
ignorePatterns: [
'dist/',
'node_modules/'
]
}
65 changes: 65 additions & 0 deletions spec/controllers/apiKeysControllerSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//import { type Request, type Response } from 'express'
//import { type CustomerApiKeyRepository } from '../repositories/customerApiKeyRepository'
//// const allowedKeys = ['description', 'enabled']

//export class ApiKeyController {
// // async update (req: Request, res: Response): Promise<void> {
// // const fpoId = req.params.fpoId
// // const id = req.params.id
// // const body = req.body
// //
// // if (typeof body !== 'object') {
// // res.status(400).json({ message: 'Invalid request' })
// // }
// // const apiKey = await repository.updateKey(fpoId, id, body)

// // if (apiKey === null) {
// // res.status(404).json({ message: 'Did not succeed' })
// // } else {
// // res.status(200).json(apiKey.toJson())
// // }
// // }
// private readonly repository: CustomerApiKeyRepository

// constructor (repository: CustomerApiKeyRepository) {
// this.repository = repository
// }

// async show (req: Request, res: Response): Promise<void> {
// const fpoId = req.params.fpoId
// const id = req.params.id
// const apiKey = await this.repository.getKey(fpoId, id)

// if (apiKey === null) {
// res.status(404).json({ message: 'API key not found' })
// } else {
// res.json(await apiKey.toDecryptedJson())
// }
// }

// async index (req: Request, res: Response): Promise<void> {
// const fpoId = req.params.fpoId
// const apiKeys = await this.repository.listKeys(fpoId)

// res.json(apiKeys.map(apiKey => apiKey.toJson()))
// }

// async create (req: Request, res: Response): Promise<void> {
// const fpoId = req.params.fpoId
// const apiKey = await this.repository.createKey(fpoId)

// res.status(201).json(apiKey.toJson())
// }
//}
//
import jasmine from 'jasmine'

import { ApiKeyController } from '../../src/controllers/apiKeysController'

describe('ApiKeyController', () => {
it('should be defined', () => {
expect(ApiKeyController).toBeDefined()
})
})


3 changes: 3 additions & 0 deletions spec/helpers/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import dotenv from 'dotenv'

dotenv.config({ path: '.env.test' })
2 changes: 1 addition & 1 deletion spec/models/customerApiKeySpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('CustomerApiKey Model', () => {
Description: '',
FpoId: '',
CreatedAt: apiKey.CreatedAt,
UpdatedAt: apiKey.UpdatedAt,
UpdatedAt: apiKey.UpdatedAt
})
})
})
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
},
"include": [
"src/**/*.ts",
"test/**/*.ts",
"spec/**/*.ts",
".eslintrc.js"
],
"exclude": [
"node_modules",
"dist"
]
}

0 comments on commit 63229b4

Please sign in to comment.