mirror of
https://github.com/pezkuwichain/pezkuwi-api.git
synced 2026-10-21 19:26:25 +00:00
Rebrand: polkadot → pezkuwi, substrate → bizinikiwi, kusama → dicle
This commit is contained in:
commit
d5f038faea
1383 files changed
+1088018
No files matched your search
@@ -0,0 +1,54 @@
|
||||
// Copyright 2017-2025 @pezkuwi/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@pezkuwi/dev-test/globals.d.ts" />
|
||||
|
||||
import { augmentObject } from './augmentObject.js';
|
||||
|
||||
describe('augmentObject', (): void => {
|
||||
let spy: ReturnType<typeof jest.spyOn>;
|
||||
|
||||
beforeEach((): void => {
|
||||
spy = jest.spyOn(console, 'warn');
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
spy.mockRestore();
|
||||
});
|
||||
|
||||
it('logs added/removed sections and methods', (): void => {
|
||||
augmentObject(
|
||||
'test',
|
||||
{ bar: { b: 1 }, foo: { d: 1, f: 1 }, new: { z: 1 } },
|
||||
{ bar: { a: 1, c: 1 }, baz: { a: 1 }, foo: { c: 1, f: 1 } }
|
||||
);
|
||||
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.stringMatching(/API\/AUGMENT/),
|
||||
'api.test: Found 1 added and 1 removed modules:\n\t added: new\n\tremoved: baz'
|
||||
);
|
||||
expect(spy).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.stringMatching(/API\/AUGMENT/),
|
||||
'api.test: Found 2 added and 3 removed calls:\n\t added: bar.b, foo.d\n\tremoved: bar.a, bar.c, foo.c'
|
||||
);
|
||||
});
|
||||
|
||||
it('copies sections to the dest', (): void => {
|
||||
const src = { bar: { b: 1 }, foo: { a: 1 } };
|
||||
|
||||
expect(augmentObject('test', src, {})).toEqual(src);
|
||||
});
|
||||
|
||||
it('adds fields to existing sections', (): void => {
|
||||
const src = { bar: { b: 1 }, foo: { a: 1 } };
|
||||
const dst = { baz: { c: 1 }, foo: { b: 2 } };
|
||||
|
||||
expect(augmentObject('test', src, dst)).toEqual({
|
||||
bar: { b: 1 },
|
||||
baz: { c: 1 },
|
||||
foo: { a: 1, b: 2 }
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user