Skip to content

Commit

Permalink
Add generic to ElementAssertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianSama committed Jun 20, 2024
1 parent 5a276d8 commit c2da004
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/dom/src/lib/ElementAssertion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Assertion, AssertionError } from "@assertive-ts/core";

export class ElementAssertion extends Assertion<Element> {
export class ElementAssertion<T extends Element> extends Assertion<T> {

public constructor(actual: Element) {
public constructor(actual: T) {
super(actual);
}

Expand Down
5 changes: 1 addition & 4 deletions packages/dom/test/unit/lib/ElementAssertion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ describe("[Unit] ElementAssertion.test.ts", () => {
});
});
context("when the element is not in the document", () => {
it("returns the assertion instance", () => {
it("Throws an assertion error", () => {
const detachedElement = document.createElement("div");

const test = new ElementAssertion(detachedElement);

expect(test.not.toBeInTheDocument())
.toBeEqual(test);

expect(() => test.toBeInTheDocument())
.toThrowError(AssertionError)
.toHaveMessage("Expected the element to be in the document");
Expand Down

0 comments on commit c2da004

Please sign in to comment.