mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
chore: migrate blocksuite test (#9222)
This commit is contained in:
28
blocksuite/tests-legacy/utils/ignore.ts
Normal file
28
blocksuite/tests-legacy/utils/ignore.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { BlockSnapshot } from '@store/index.js';
|
||||
|
||||
export function ignoreFields(target: unknown, keys: string[]): unknown {
|
||||
if (Array.isArray(target)) {
|
||||
return target.map((item: unknown) => ignoreFields(item, keys));
|
||||
} else if (typeof target === 'object' && target !== null) {
|
||||
return Object.keys(target).reduce(
|
||||
(acc: Record<string, unknown>, key: string) => {
|
||||
if (keys.includes(key)) {
|
||||
acc[key] = '*';
|
||||
} else {
|
||||
acc[key] = ignoreFields(
|
||||
(target as Record<string, unknown>)[key],
|
||||
keys
|
||||
);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
export function ignoreSnapshotId(snapshot: BlockSnapshot) {
|
||||
const ignored = ignoreFields(snapshot, ['id']);
|
||||
return JSON.stringify(ignored, null, 2);
|
||||
}
|
||||
Reference in New Issue
Block a user