-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Misnamed Tags & More useful validity tests
- Loading branch information
1 parent
1e4b57d
commit 9c96361
Showing
10 changed files
with
78 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import parseTag from '../parseTag'; | ||
import {parseTag} from '../testUtils'; | ||
|
||
import { Install } from '../../src'; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { InvalidityReason, Verifiable } from "../src"; | ||
|
||
const parser = new DOMParser(); | ||
|
||
export function parseTag(literals: TemplateStringsArray, ...expressions: string[]) { | ||
let str = ''; | ||
literals.forEach((string, i) => { | ||
str += string + (expressions[i] ?? ''); | ||
}); | ||
const doc = parser.parseFromString(str, 'text/xml'); | ||
return doc.documentElement; | ||
} | ||
|
||
/** Ensures the provided Verifiable object is valid. Alternatively, if specified, ensures the provided Verifiable object is invalid and has the specified reason for invalidity. | ||
* | ||
* Will check that isValid() and reasonForInvalidity() agree, and that the reasonForInvalidity() matches the expected reason. If a mismatch occurs, | ||
* | ||
* @param v | ||
* @param expectedReason | ||
*/ | ||
export function testValidity(v: Verifiable<boolean>, expectedReason?: InvalidityReason) { | ||
const reason = v.reasonForInvalidity(); | ||
const validity = v.isValid(); | ||
|
||
expect(reason).toBe(validity ? null : reason); // Always fail if isValid() and reasonForInvalidity() disagree | ||
expect(reason?.reason).toBe(expectedReason); | ||
expect(validity).toBe(!expectedReason); | ||
} |