Skip to content

Commit

Permalink
fix hint selector and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
binrysearch committed Jul 8, 2024
1 parent 6de3db4 commit 69e79ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/packages/hint/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function removeHints(hint: Hint) {
for (const hintElement of Array.from(elements)) {
const step = hintElement.getAttribute(dataStepAttribute);

if (!step) continue;
if (step === null) continue;

removeHint(parseInt(step, 10));
}
Expand Down
2 changes: 1 addition & 1 deletion src/packages/hint/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const hintElements = () =>

export const hintElement = (stepId: number) =>
queryElementsByClassName(
`.${hintClassName}[${dataStepAttribute}="${stepId}"]`,
`${hintClassName}[${dataStepAttribute}="${stepId}"]`,
hintsContainer()
)[0];
4 changes: 2 additions & 2 deletions src/packages/hint/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Hint } from "./hint";
import { hideHintClassName } from "./className";
import { dataStepAttribute } from "./dataAttributes";
import { removeClass } from "../../util/className";
import { fetchHintItems } from "./hintItem";
import { hintElement, hintElements } from "./selector";

/**
Expand All @@ -22,7 +21,8 @@ export async function showHints(hint: Hint) {
showHint(parseInt(step, 10));
}
} else {
await fetchHintItems(hint);
// or render hints if there are none
await hint.render();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/packages/hint/showHints.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
context("ShowHints", () => {
it("should render all hints using the data-hint attributes", () => {
cy.visit("./cypress/setup/index.html").then((window) => {
cy.visit("./cypress/setup/index.html").then(async (window) => {
const instance = window.introJs.hint();

instance.showHints();
await instance.showHints();

cy.get(".introjs-hint").should("have.length", 4);
});
Expand Down

0 comments on commit 69e79ae

Please sign in to comment.