More protobufjs migration
This commit is contained in:
parent
cf06e6638e
commit
ddbbe3a6b1
70 changed files with 3967 additions and 3369 deletions
|
@ -2,7 +2,12 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { dropNull } from '../../util/dropNull';
|
||||
import { dropNull, shallowDropNull } from '../../util/dropNull';
|
||||
|
||||
type Test = {
|
||||
a: number | null;
|
||||
b: number | undefined;
|
||||
};
|
||||
|
||||
describe('dropNull', () => {
|
||||
it('swaps null with undefined', () => {
|
||||
|
@ -16,4 +21,42 @@ describe('dropNull', () => {
|
|||
it('non-null values undefined be', () => {
|
||||
assert.strictEqual(dropNull('test'), 'test');
|
||||
});
|
||||
|
||||
describe('shallowDropNull', () => {
|
||||
it('return undefined with given null', () => {
|
||||
assert.strictEqual(shallowDropNull<Test>(null), undefined);
|
||||
});
|
||||
|
||||
it('return undefined with given undefined', () => {
|
||||
assert.strictEqual(shallowDropNull<Test>(undefined), undefined);
|
||||
});
|
||||
|
||||
it('swaps null with undefined', () => {
|
||||
const result:
|
||||
| {
|
||||
a: number | undefined;
|
||||
b: number | undefined;
|
||||
}
|
||||
| undefined = shallowDropNull<Test>({
|
||||
a: null,
|
||||
b: 1,
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, { a: undefined, b: 1 });
|
||||
});
|
||||
|
||||
it('leaves undefined be', () => {
|
||||
const result:
|
||||
| {
|
||||
a: number | undefined;
|
||||
b: number | undefined;
|
||||
}
|
||||
| undefined = shallowDropNull<Test>({
|
||||
a: 1,
|
||||
b: undefined,
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(result, { a: 1, b: undefined });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue