signal-desktop/ts/test-both/util/normalizeUuid_test.ts

23 lines
705 B
TypeScript
Raw Normal View History

2021-06-22 14:46:42 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { v4 as generateUuid } from 'uuid';
import { normalizeUuid } from '../../util/normalizeUuid';
describe('normalizeUuid', () => {
it('converts uuid to lower case', () => {
const uuid = generateUuid();
assert.strictEqual(normalizeUuid(uuid, 'context 1'), uuid);
assert.strictEqual(normalizeUuid(uuid.toUpperCase(), 'context 2'), uuid);
});
2021-06-22 23:08:55 +00:00
it("throws if passed a string that's not a UUID", () => {
assert.throws(
() => normalizeUuid('not-uuid-at-all', 'context 3'),
'Normalizing invalid uuid: not-uuid-at-all in context "context 3"'
);
});
2021-06-22 14:46:42 +00:00
});