@hello.nrfcloud.com/proto-map
Version:
Documents the communication protocol between devices, the hello.nrfcloud.com/map backend and web application
25 lines (23 loc) • 740 B
text/typescript
import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { correctOffset } from './correctOffset.js'
import { isUnixTimeInSeconds } from './isUnixTimeInSeconds.js'
void describe('correctOffset()', () => {
void it('should correct timestamps in the future of up to 60 seconds', () => {
assert.equal(
isUnixTimeInSeconds(correctOffset(Date.now() / 1000 + 1)),
true,
'should correct 1 second in the future',
)
assert.equal(
isUnixTimeInSeconds(correctOffset(Date.now() / 1000 + 60)),
true,
'should correct 60 seconds in the future',
)
assert.equal(
isUnixTimeInSeconds(correctOffset(Date.now() / 1000 + 61)),
false,
'should not correct 61 seconds in the future',
)
})
})