fleetmap-reports 1.0.518 → 1.0.519
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.test.js +40 -6
- package/src/util/utils.js +1 -1
package/package.json
CHANGED
package/src/index.test.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
1
2
|
const { getReports } = require('./tests')
|
|
2
3
|
const assert = require('assert')
|
|
4
|
+
const utils = require('./util/utils')
|
|
3
5
|
|
|
4
6
|
async function getSpeedingReport (report, userData) {
|
|
5
7
|
const data = await report.speedingReport(
|
|
@@ -15,7 +17,24 @@ async function getSpeedingReport (report, userData) {
|
|
|
15
17
|
|
|
16
18
|
// eslint-disable-next-line no-undef
|
|
17
19
|
describe('Test_Reports', function () {
|
|
18
|
-
|
|
20
|
+
it('converts to pdf', async () => {
|
|
21
|
+
const report = await getReports()
|
|
22
|
+
const userData = await report.getUserData()
|
|
23
|
+
userData.roadSpeedLimits = false
|
|
24
|
+
userData.customSpeed = false
|
|
25
|
+
userData.useVehicleSpeedLimit = true
|
|
26
|
+
const data = await report.speedingReport(
|
|
27
|
+
new Date(Date.UTC(2022, 9, 22, 0, 0, 0, 0)),
|
|
28
|
+
new Date(Date.UTC(2022, 9, 22, 23, 59, 59, 0)),
|
|
29
|
+
userData)
|
|
30
|
+
console.log(await report.speedingReportToPDF(userData, data))
|
|
31
|
+
}, 20000)
|
|
32
|
+
|
|
33
|
+
it('converts madrid time', async () => {
|
|
34
|
+
assert.equal(false, utils.isClientSide())
|
|
35
|
+
console.log(utils.convertToLocaleString(new Date(), 'es-CL', 'Europe/Madrid'))
|
|
36
|
+
})
|
|
37
|
+
|
|
19
38
|
// eslint-disable-next-line no-undef
|
|
20
39
|
it('works with road speed limits', async () => {
|
|
21
40
|
const report = await getReports()
|
|
@@ -351,18 +370,33 @@ describe('Test_Reports', function () {
|
|
|
351
370
|
it('Refueling Report', async () => {
|
|
352
371
|
const report = await getReports()
|
|
353
372
|
const userData = await report.getUserData()
|
|
354
|
-
|
|
373
|
+
|
|
355
374
|
const data = await report.refuelingReport(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
375
|
+
new Date(Date.UTC(2022, 1, 2, 0, 0, 0, 0)),
|
|
376
|
+
new Date(Date.UTC(2022, 1, 2, 23, 59, 59, 0)),
|
|
377
|
+
userData)
|
|
359
378
|
|
|
360
379
|
assert.equal(data.length, 1)
|
|
361
380
|
console.log(data[0])
|
|
362
|
-
const device = data[0].devices.find(d => d.device.id ===
|
|
381
|
+
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
363
382
|
assert.equal(device.refuelings.length, 2)
|
|
364
383
|
}, 30000)
|
|
365
384
|
// eslint-disable-next-line no-undef
|
|
385
|
+
it('Refueling2 Report', async () => {
|
|
386
|
+
const report = await getReports()
|
|
387
|
+
const userData = await report.getUserData()
|
|
388
|
+
|
|
389
|
+
const data = await report.refuelingReport(new Date(2022, 1, 21, 0, 0, 0, 0),
|
|
390
|
+
new Date(2022, 1, 25, 23, 59, 59, 0),
|
|
391
|
+
userData)
|
|
392
|
+
|
|
393
|
+
assert.equal(data.length, 1)
|
|
394
|
+
console.log(data[0])
|
|
395
|
+
const device = data[0].devices.find(d => d.device.id === 16245)
|
|
396
|
+
console.log(device.refuelings)
|
|
397
|
+
assert.equal(device.refuelings.length, 4)
|
|
398
|
+
}, 30000)
|
|
399
|
+
// eslint-disable-next-line no-undef
|
|
366
400
|
it('FuelConsumption Report', async () => {
|
|
367
401
|
const report = await getReports()
|
|
368
402
|
const userData = await report.getUserData()
|
package/src/util/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const messages = require('../../lang')
|
|
|
5
5
|
const distance = require('@turf/distance')
|
|
6
6
|
|
|
7
7
|
exports.getTranslations = (userData) => {
|
|
8
|
-
const lang =
|
|
8
|
+
const lang = this.getLanguage(userData)
|
|
9
9
|
if (!messages[lang]) {
|
|
10
10
|
console.warn('no lang found for', userData.user, userData.user.attributes.lang, navigator && navigator.language)
|
|
11
11
|
}
|