mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 21:15:47 +00:00
chore: rename test files (#2181)
This commit is contained in:
37
packages/xrpl/test/ExponentialBackoff.test.ts
Normal file
37
packages/xrpl/test/ExponentialBackoff.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { assert } from 'chai'
|
||||
import ExponentialBackoff from 'xrpl-local/client/ExponentialBackoff'
|
||||
|
||||
describe('ExponentialBackoff', function () {
|
||||
it('duration() return value starts with the min value', function () {
|
||||
// default: 100ms
|
||||
assert.equal(new ExponentialBackoff().duration(), 100)
|
||||
assert.equal(new ExponentialBackoff({ min: 100 }).duration(), 100)
|
||||
assert.equal(new ExponentialBackoff({ min: 123 }).duration(), 123)
|
||||
})
|
||||
|
||||
it('duration() return value increases when called multiple times', function () {
|
||||
const backoff = new ExponentialBackoff({ min: 100, max: 1000 })
|
||||
assert.strictEqual(backoff.duration(), 100)
|
||||
assert.strictEqual(backoff.duration(), 200)
|
||||
assert.strictEqual(backoff.duration(), 400)
|
||||
assert.strictEqual(backoff.duration(), 800)
|
||||
})
|
||||
|
||||
it('duration() never returns greater than the max value', function () {
|
||||
const backoff = new ExponentialBackoff({ min: 300, max: 1000 })
|
||||
assert.strictEqual(backoff.duration(), 300)
|
||||
assert.strictEqual(backoff.duration(), 600)
|
||||
assert.strictEqual(backoff.duration(), 1000)
|
||||
assert.strictEqual(backoff.duration(), 1000)
|
||||
})
|
||||
|
||||
it('reset() will reset the duration() value', function () {
|
||||
const backoff = new ExponentialBackoff({ min: 100, max: 1000 })
|
||||
assert.strictEqual(backoff.duration(), 100)
|
||||
assert.strictEqual(backoff.duration(), 200)
|
||||
assert.strictEqual(backoff.duration(), 400)
|
||||
backoff.reset()
|
||||
assert.strictEqual(backoff.duration(), 100)
|
||||
assert.strictEqual(backoff.duration(), 200)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user