Skip to content

Commit

Permalink
SonarQube #2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrogoNevets committed Jan 22, 2025
1 parent 0889a97 commit dab7244
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/server/common/controller/generic-page-controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from 'aws-embedded-metrics'
import { config } from '~/src/config/config.js'
import { createLogger } from '../../helpers/logging/logger.js'
import { NotImplementedError } from '../../helpers/not-implemented-error.js'

/**
* @import {Page} from '../../model/page/page-model.js'
Expand Down Expand Up @@ -95,11 +96,11 @@ export default class GenericPageController {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
handleGet(_req, _h) {
throw new Error('Method not implemented')
throw new NotImplementedError()
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
handlePost(_req, _h) {
throw new Error('Method not implemented')
throw new NotImplementedError()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { config } from '~/src/config/config.js'
import { Page } from '../../model/page/page-model.js'
import GenericPageController from './index.js'
import { NotImplementedError } from '../../helpers/not-implemented-error.js'

class TestPage extends Page {
reportMetrics = {
Expand Down Expand Up @@ -37,6 +38,12 @@ describe('#GenricPageController', () => {
controller = new TestGenericController(page)
})

it('should throw not implemented error', () => {
const defaultController = new GenericPageController(new Page())
expect(() => defaultController.handleGet()).toThrow(NotImplementedError)
expect(() => defaultController.handlePost()).toThrow(NotImplementedError)
})

it('should output error on getHandler', () => {
jest.spyOn(controller, 'handleGet').mockImplementation(() => {
throw new Error('test error')
Expand Down

0 comments on commit dab7244

Please sign in to comment.