Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil committed Feb 1, 2024
1 parent c7ae916 commit 5a8ff07
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
29 changes: 28 additions & 1 deletion lib/platform-bible-utils/src/document-combiner-engine.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
/* eslint-disable max-classes-per-file */
import DocumentCombinerEngine, { JsonDocumentLike } from './document-combiner-engine';
import DocumentCombinerWithoutValidation from './document-combiner-without-validation';

// #region Combiner implementations

/** Combine all provided documents without any checking */
class DocumentCombinerWithoutValidation extends DocumentCombinerEngine {
// Lint doesn't understand that making something public that was protected isn't useless
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(startingDocument: JsonDocumentLike, copyDocuments: boolean) {
super(startingDocument, copyDocuments);
}

// We have the implement this abstract function but don't want it to do anything
// eslint-disable-next-line class-methods-use-this
protected validateStartingDocument(): void {}

// We have the implement this abstract function but don't want it to do anything
// eslint-disable-next-line class-methods-use-this
protected validateContribution(): void {}

// We have the implement this abstract function but don't want it to do anything
// eslint-disable-next-line class-methods-use-this
protected validateOutput(): void {}
}

/** Throw a validation error on any operation, including construction */
class AlwaysThrowingCombiner extends DocumentCombinerEngine {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(startingDocument: JsonDocumentLike) {
Expand All @@ -24,6 +47,7 @@ class AlwaysThrowingCombiner extends DocumentCombinerEngine {
}
}

/** Throw a validation error on any operation after construction is complete */
class ThrowingCombiner extends DocumentCombinerEngine {
throwEnabled: boolean = false;

Expand All @@ -45,6 +69,7 @@ class ThrowingCombiner extends DocumentCombinerEngine {
}
}

/** Throw a validation error only when checking the output */
class OutputThrowingCombiner extends DocumentCombinerEngine {
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(startingDocument: JsonDocumentLike) {
Expand All @@ -63,6 +88,8 @@ class OutputThrowingCombiner extends DocumentCombinerEngine {
}
}

// #endregion

test('Simple combining works', () => {
const hasA = { a: 1 };
const hasB = { b: 2 };
Expand Down

This file was deleted.

0 comments on commit 5a8ff07

Please sign in to comment.