2019-06-20 00:20:09 +02:00
|
|
|
import { assert } from 'chai'
|
2020-01-30 22:08:18 +01:00
|
|
|
import { generateId } from '../../../src/utils/GeneratorHelpers'
|
2019-02-14 12:37:52 +01:00
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
describe('GeneratorHelpers', () => {
|
|
|
|
describe('#generateId()', () => {
|
|
|
|
it('should generate an ID', async () => {
|
2019-02-14 12:37:52 +01:00
|
|
|
const id = generateId()
|
|
|
|
assert(id)
|
|
|
|
})
|
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
it('should generate an ID that is 64 chars long', async () => {
|
2019-02-14 12:37:52 +01:00
|
|
|
const id: string = generateId()
|
|
|
|
assert.equal(id.length, 64)
|
|
|
|
})
|
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
it('should not contain -', async () => {
|
2019-02-14 12:37:52 +01:00
|
|
|
const id: string = generateId()
|
|
|
|
assert.match(id, /^[a-f0-9]+$/i)
|
|
|
|
})
|
|
|
|
|
2019-06-20 00:20:09 +02:00
|
|
|
it('should generate an ID that is 130 chars long', async () => {
|
2019-02-14 12:37:52 +01:00
|
|
|
const id: string = generateId(130)
|
|
|
|
assert.equal(id.length, 130)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|