Skip to content

Commit

Permalink
add convenience includesContent audits
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Sep 28, 2024
1 parent ff427a1 commit f14f3b8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test-packages/support/audit-assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,42 @@ export class ExpectModule {
});
}

doesNotIncludeContent(src: string, message?: string) {
if (!this.module) {
this.emitMissingModule();
return;
}
if (this.module.type === 'unparseable') {
this.emitUnparsableModule(message);
return;
}

this.expectAudit.assert.pushResult({
result: !this.module.content.includes(src),
actual: this.module.content,
expected: true,
message: message ?? `Expected ${this.inputName} to not contain ${src}`,
});
}

includesContent(src: string, message?: string) {
if (!this.module) {
this.emitMissingModule();
return;
}
if (this.module.type === 'unparseable') {
this.emitUnparsableModule(message);
return;
}

this.expectAudit.assert.pushResult({
result: this.module.content.includes(src),
actual: this.module.content,
expected: true,
message: message ?? `Expected ${this.inputName} to contain ${src}`,
});
}

private emitUnparsableModule(message?: string) {
this.expectAudit.assert.pushResult({
result: false,
Expand Down Expand Up @@ -327,6 +363,8 @@ class EmptyExpectModule implements PublicAPI<ExpectModule> {
codeEquals() {}
codeContains() {}
withContents() {}
doesNotIncludeContent() {}
includesContent() {}

resolves(): PublicAPI<ExpectResolution> {
return new EmptyExpectResolution() as PublicAPI<ExpectResolution>;
Expand Down

0 comments on commit f14f3b8

Please sign in to comment.