Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { DateTime } from 'luxon'
import { Season } from 'enum/ecogesture.enum'
import { FluidType } from 'enum/fluid.enum'
import { formatNumberValues, getFluidType, getSeason } from './utils'
describe('utilis utilis test', () => {
describe('getFluidType test', () => {
it('should the electrity fluid type', () => {
const result = getFluidType('eLectRicity')
expect(result).toBe(FluidType.ELECTRICITY)
})
it('should the water fluid type', () => {
const result = getFluidType('WatER')
expect(result).toBe(FluidType.WATER)
})
it('should the gas fluid type', () => {
const result = getFluidType('gas')
expect(result).toBe(FluidType.GAS)
})
})
describe('formatNumberValues test', () => {
it('should return --,-- if there is not value', () => {
const result = formatNumberValues(null)
expect(result).toBe('--,--')
})
it('should return a value at english number format two digits decimal', () => {
const result = formatNumberValues(2000.555)
expect(result).toEqual('2 000,56')
})
it('should return a float value', () => {
const result = formatNumberValues(2000.55, '', true)
expect(result).toEqual(2000)
})
})
describe('getSeason test', () => {
it('should return summer', () => {
const now = DateTime.local().setZone('utc', {
keepLocalTime: true,
})
jest
.spyOn(DateTime, 'local')
.mockReturnValueOnce(now.set({ day: 12, month: 6, year: 2021 }))
const result = getSeason()
expect(result).toBe(Season.SUMMER)
})
it('should return winter', () => {
const now = DateTime.local().setZone('utc', {
keepLocalTime: true,
})
jest
.spyOn(DateTime, 'local')
.mockReturnValueOnce(now.set({ day: 1, month: 12, year: 2021 }))
const result = getSeason()
expect(result).toBe(Season.WINTER)
})
it('should return none', () => {
const now = DateTime.local().setZone('utc', {
keepLocalTime: true,
})
jest
.spyOn(DateTime, 'local')
.mockReturnValueOnce(now.set({ day: 1, month: 10, year: 2021 }))
const result = getSeason()
expect(result).toBe(Season.NONE)
})
})
})