Skip to content

Commit f9f99e8

Browse files
committed
clean up ipf tests
1 parent 0f3d36f commit f9f99e8

File tree

1 file changed

+0
-95
lines changed

1 file changed

+0
-95
lines changed

tests/fields/IPF.test.ts

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -382,101 +382,6 @@ function getTestName(value: any): string {
382382

383383
describe('IPF', () => {
384384
let testPlugin: TestPlugin;
385-
let ipfBase: InputFieldBase;
386-
let ipf: InputField;
387-
388-
let ipfBase1: InputFieldBase;
389-
let ipfBase2: InputFieldBase;
390-
let ipf1: InputField;
391-
let ipf2: InputField;
392-
393-
function setup(testCase: IPFTestCase): void {
394-
testPlugin = new TestPlugin();
395-
396-
ipfBase = testPlugin.api.createInputFieldBase(TEST_FILE_PATH, {
397-
declaration: testCase.declaration,
398-
renderChildType: RenderChildType.BLOCK,
399-
scope: undefined,
400-
});
401-
}
402-
403-
function loadIPF(): void {
404-
ipfBase.mount(document.body);
405-
ipf = ipfBase.inputField as InputField;
406-
}
407-
408-
function setupTwoIPFs(testCase: IPFTestCase): void {
409-
testPlugin = new TestPlugin();
410-
411-
ipfBase1 = testPlugin.api.createInputFieldBase(TEST_FILE_PATH, {
412-
declaration: testCase.declaration,
413-
renderChildType: RenderChildType.BLOCK,
414-
scope: undefined,
415-
});
416-
417-
ipfBase2 = testPlugin.api.createInputFieldBase(TEST_FILE_PATH, {
418-
declaration: testCase.declaration,
419-
renderChildType: RenderChildType.BLOCK,
420-
scope: undefined,
421-
});
422-
}
423-
424-
function loadIPF1(): void {
425-
ipfBase1.mount(document.body);
426-
ipf1 = ipfBase1.inputField as InputField;
427-
}
428-
429-
function loadIPF2(): void {
430-
ipfBase2.mount(document.body);
431-
ipf2 = ipfBase2.inputField as InputField;
432-
}
433-
434-
function createInitialCache(initialMetadata: Metadata): void {
435-
// setting the initial metadata only works if the cache is already initialized, which happens when someone subscribes to the file
436-
const subscription = testPlugin.metadataManager.subscribe(
437-
getUUID(),
438-
new Signal<unknown>(undefined),
439-
{
440-
storageType: BindTargetStorageType.FRONTMATTER,
441-
storagePath: TEST_FILE_PATH,
442-
storageProp: parsePropPath(['something_unused']),
443-
listenToChildren: false,
444-
},
445-
() => {},
446-
);
447-
448-
setCacheExternally(initialMetadata);
449-
450-
subscription.unsubscribe();
451-
452-
// make sure the metadata is set correctly
453-
expect<Metadata | undefined>(getCacheMetadata()).toEqual(initialMetadata);
454-
}
455-
456-
function setCacheExternally(metadata: Metadata): void {
457-
const source = testPlugin.metadataManager.getSource(BindTargetStorageType.FRONTMATTER);
458-
if (!source) {
459-
throw new Error('source not found');
460-
}
461-
testPlugin.metadataManager.onExternalUpdate(source, TEST_FILE_PATH, metadata);
462-
}
463-
464-
function getCacheMetadata(): Metadata | undefined {
465-
const source = testPlugin.metadataManager.getSource(BindTargetStorageType.FRONTMATTER);
466-
if (!source) {
467-
throw new Error('source not found');
468-
}
469-
const cacheItem = source.getCacheItemForStoragePath(TEST_FILE_PATH);
470-
if (!cacheItem) {
471-
throw new Error('cache item not found');
472-
}
473-
474-
return source.readEntireCacheItem(cacheItem);
475-
}
476-
477-
function updateMetadataManager(): void {
478-
testPlugin.metadataManager.cycle();
479-
}
480385

481386
function runTestCase(TEST_CONFIG: IPFTest, TEST_CASE: IPFTestCase): void {
482387
// NOTE: all signal spys have a -1 to account for the initial signal set on mount

0 commit comments

Comments
 (0)