Skip to content

Commit

Permalink
Fix flush behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmacarthur committed Oct 24, 2024
1 parent 0bde365 commit dce6fb6
Show file tree
Hide file tree
Showing 8 changed files with 891 additions and 937 deletions.
1,436 changes: 667 additions & 769 deletions packages/typeit-react/package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/typeit-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typeit-react",
"version": "2.7.3",
"version": "2.7.4",
"description": "React component for the most versatile JavaScript animated typing utility on the planet.",
"homepage": "https://typeitjs.com",
"main": "dist/index.umd.js",
Expand Down Expand Up @@ -40,18 +40,18 @@
"dependencies": {
"react": ">=18.3.1",
"react-dom": ">=18.3.1",
"typeit": "^8.8.5"
"typeit": "^8.8.6"
},
"devDependencies": {
"@babel/preset-typescript": "^7.24.7",
"@testing-library/jest-dom": "^6.5.0",
"@babel/preset-typescript": "^7.25.9",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/react": "^16.0.1",
"@types/react": "^18.3.5",
"jsdom": "^25.0.0",
"terser": "^5.32.0",
"typescript": "^5.6.2",
"vite": "^5.4.5",
"vitest": "^2.1.1",
"@types/react": "^18.3.12",
"jsdom": "^25.0.1",
"terser": "^5.36.0",
"typescript": "^5.6.3",
"vite": "^5.4.10",
"vitest": "^2.1.3",
"vitest-dom": "^0.1.1"
}
}
19 changes: 18 additions & 1 deletion packages/typeit/__tests__/flush.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("deleting queue items", () => {
});
});

test("Doesn't delete permanent queue items.", () => {
test.only("Doesn't delete permanent queue items.", () => {
const el = document.getElementById("el");

return new Promise((resolve) => {
Expand All @@ -38,6 +38,23 @@ describe("deleting queue items", () => {
.go();
});
});

test("fires last callback when flush called multiple times", () => {
const el = document.getElementById("el");

return new Promise((resolve) => {
let iteration = 0;
const instance = new TypeIt(el, { speed: 0 });

instance.type("first").flush(() => (iteration = 1));
instance.type("second").flush(() => (iteration = 2));
instance.type("third").flush(() => {
expect(el.textContent).toEqual("firstsecondthird|");
expect(iteration).toEqual(0);
resolve();
});
});
});
});

describe("callbacks", () => {
Expand Down
Loading

0 comments on commit dce6fb6

Please sign in to comment.