@cowwoc/requirements
Version:
A fluent API for enforcing design contracts with automatic message generation.
63 lines • 2.07 kB
JavaScript
import { Type, assertThatType } from "../../internal.mjs";
/**
* The result of calculating the difference between two strings.
*/
class DiffResult {
actualLines;
diffLines;
expectedLines;
equalLines;
/**
* @param actualLines - the lines of the actual string
* @param diffLines - the difference between the actual and expected values (empty list if omitted)
* @param expectedLines - the lines of the expected string
* @param equalLines - indicates if the actual and expected values are equal for each line
* @throws TypeError if any of the arguments are `undefined` or `null`
*/
constructor(actualLines, diffLines, expectedLines, equalLines) {
assertThatType(actualLines, "actualLines", Type.ARRAY);
assertThatType(diffLines, "diffLines", Type.ARRAY);
assertThatType(expectedLines, "expectedLines", Type.ARRAY);
assertThatType(equalLines, "equalLines", Type.ARRAY);
this.actualLines = actualLines;
this.diffLines = diffLines;
this.expectedLines = expectedLines;
this.equalLines = equalLines;
}
/**
* @returns the lines of the actual string
*/
getActualLines() {
return this.actualLines;
}
/**
* @returns the difference between "Actual" and "Expected". If the list is empty, no lines should be
* displayed.
*/
getDiffLines() {
return this.diffLines;
}
/**
* Returns the lines of the expected string.
*
* @returns the lines of the expected string
*/
getExpectedLines() {
return this.expectedLines;
}
/**
* @returns a list that indicates whether the actual and expected values are equal on each line
*/
getEqualLines() {
return this.equalLines;
}
toString() {
return `\
actual : ${this.actualLines.toString()}
diff : ${this.diffLines.toString()}
expected: ${this.expectedLines.toString()}
equal : ${this.equalLines.toString()}`;
}
}
export { DiffResult };
//# sourceMappingURL=DiffResult.mjs.map