Skip to content

Commit

Permalink
Modifs sur Tempo
Browse files Browse the repository at this point in the history
  • Loading branch information
WoCha-FR committed Nov 19, 2022
1 parent b7bb500 commit c1ac9e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ frenchtools/global/edftempo
"nb_bleu":222,
"nb_blanc":43,
"nb_rouge":22,
"tempodebut":"2022-09-01",
"tempofin":"2023-08-31"
"tempodebut":"01/092022",
"tempofin":"31/08/2023"
}
```

Expand Down
9 changes: 5 additions & 4 deletions lib/infofrance.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class InfosFrance {
let response
// Couleurs J et J+1
const date = new Date()
date.setHours(12, 0, 0, 0)
const revelant = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
params = { dateRelevant: revelant }
response = await this.request('searchTempoStore', params)
Expand Down Expand Up @@ -153,12 +154,12 @@ class InfosFrance {
const mois = date.getMonth()
if (mois < 8) {
const past = date.getFullYear() - 1
result.tempodebut = past + '-09-01'
result.tempofin = date.getFullYear() + '-08-31'
result.tempodebut = '01/09/' + past
result.tempofin = '31/08/' + date.getFullYear()
} else {
const next = date.getFullYear() + 1
result.tempodebut = date.getFullYear() + '-09-01'
result.tempofin = next + '-08-31'
result.tempodebut = '01/09/' + date.getFullYear()
result.tempofin = '31/08/' + next
}
// Emit publish Event
eventEmitter.emit('frame', 'global/edftempo', result)
Expand Down
8 changes: 5 additions & 3 deletions tests/infofrance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('EDF Tempo', () => {
})
test('should return valid data', async () => {
const client = new InfoGlobal()
const res = { coulj: 'BLEU', coulj1: 'BLEU', nb_blanc: 3, nb_bleu: 35, nb_rouge: 1, tempodebut: '2023-09-01', tempofin: '2024-08-31' }
const res = { coulj: 'BLEU', coulj1: 'BLEU', nb_blanc: 3, nb_bleu: 35, nb_rouge: 1, tempodebut: '01/09/2023', tempofin: '31/08/2024' }
const spy = jest.spyOn(eventEmitter, 'emit').mockImplementation(() => {})
jest.useFakeTimers({ now: new Date(2024, 4, 5) })
await client.getEDF()
Expand All @@ -109,12 +109,14 @@ describe('EDF Tempo', () => {
.onAny().reply(404)
})
afterAll(() => {
jest.useRealTimers()
mock.reset()
})
afterEach(() => {
jest.useRealTimers()
})
test('should return right data 3', async () => {
const client = new InfoGlobal()
const res = { coulj: 'NO_DATA', coulj1: 'NO_DATA', nb_blanc: 'NO_DATA', nb_bleu: 'NO_DATA', nb_rouge: 'NO_DATA', tempodebut: '2023-09-01', tempofin: '2024-08-31' }
const res = { coulj: 'NO_DATA', coulj1: 'NO_DATA', nb_blanc: 'NO_DATA', nb_bleu: 'NO_DATA', nb_rouge: 'NO_DATA', tempodebut: '01/09/2023', tempofin: '31/08/2024' }
const spy = jest.spyOn(eventEmitter, 'emit').mockImplementation(() => {})
jest.useFakeTimers({ now: new Date(2023, 9, 5) })
await client.getEDF()
Expand Down

0 comments on commit c1ac9e9

Please sign in to comment.