Dropped storage keys should not cause upload
This commit is contained in:
parent
67209d8881
commit
a0b05f41e3
6 changed files with 127 additions and 83 deletions
|
@ -3,19 +3,36 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
import { v4 as generateUuid } from 'uuid';
|
||||
import * as sinon from 'sinon';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
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);
|
||||
let warn: sinon.SinonStub;
|
||||
let logger: Pick<LoggerType, 'warn'>;
|
||||
|
||||
beforeEach(() => {
|
||||
warn = sinon.stub();
|
||||
logger = { warn };
|
||||
});
|
||||
|
||||
it("throws if passed a string that's not a UUID", () => {
|
||||
assert.throws(
|
||||
() => normalizeUuid('not-UUID-at-all', 'context 3'),
|
||||
it('converts uuid to lower case', () => {
|
||||
const uuid = generateUuid();
|
||||
assert.strictEqual(normalizeUuid(uuid, 'context 1', logger), uuid);
|
||||
assert.strictEqual(
|
||||
normalizeUuid(uuid.toUpperCase(), 'context 2', logger),
|
||||
uuid
|
||||
);
|
||||
|
||||
sinon.assert.notCalled(warn);
|
||||
});
|
||||
|
||||
it("warns if passed a string that's not a UUID", () => {
|
||||
normalizeUuid('not-UUID-at-all', 'context 3', logger);
|
||||
sinon.assert.calledOnce(warn);
|
||||
sinon.assert.calledWith(
|
||||
warn,
|
||||
'Normalizing invalid uuid: not-UUID-at-all to not-uuid-at-all in ' +
|
||||
'context "context 3"'
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue