23f6c5ac544190203fea1068a0b3110efd00c763
[e-mobility-charging-stations-simulator.git] / tests / utils / ConfigurationUtils.test.ts
1 /* eslint-disable @typescript-eslint/no-unsafe-member-access */
2 import { expect } from 'expect'
3 import { describe, it } from 'node:test'
4
5 import { FileType } from '../../src/types/index.js'
6 import { handleFileException, logPrefix } from '../../src/utils/ConfigurationUtils.js'
7
8 await describe('ConfigurationUtils test suite', async () => {
9 await it('Verify logPrefix()', () => {
10 expect(logPrefix()).toContain(' Simulator configuration |')
11 })
12
13 await it('Verify handleFileException()', t => {
14 t.mock.method(console, 'error')
15 const error = new Error()
16 error.code = 'ENOENT'
17 expect(() => {
18 handleFileException('path/to/module.js', FileType.Authorization, error, 'log prefix |')
19 }).toThrow(error)
20 expect(console.error.mock.calls.length).toBe(1)
21 })
22 })