Files
driver.js/packages/driver/tests/config.test.ts
Kamran Ahmed 75edd1b4bc Restructure as a Turborepo monorepo
packages/driver is the library (still published as driver.js, with
repository.directory set); playground and docs move to apps/. One root
pnpm workspace and lockfile replace the three standalone projects, with
turbo orchestrating build/test/lint:package (apps depend on the library
build; local + CI caching via .turbo).

Apps keep importing the library from source for HMR — the aliases now
point at ../../packages/driver/src and each app gains a workspace:*
dependency so the task graph knows the edge. The dev-server fs scope
widens to the repo root accordingly.

Releases run from packages/driver (root `pnpm release` delegates). The
changelog still lives in the docs app, so the release scripts reach it
via ../../../apps/docs and the after:bump hook stages it explicitly —
release-it no longer sits above both directories.

The merged workspace settings keep sharp unbuilt on purpose (prebuilt
binaries; building from source needs node-gyp and fails) — the docs app
had this right and the playground setting was the accident. postcss and
postcss-scss were unreferenced devDependencies and are dropped; prettier
moves to the root as the only shared tool.
2026-07-16 19:45:23 +01:00

50 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { createDriver, popoverTitle, SAMPLE_STEPS, useDriverHarness } from "./utils";
useDriverHarness();
describe("configuration & state", () => {
it("returns the active configuration via getConfig", () => {
const d = createDriver({ animate: false, stagePadding: 12 });
expect(d.getConfig().animate).toBe(false);
expect(d.getConfig().stagePadding).toBe(12);
});
it("updates configuration via setConfig", () => {
const d = createDriver({ animate: false });
d.setConfig({ animate: false, stagePadding: 25 });
expect(d.getConfig().stagePadding).toBe(25);
});
it("replaces the steps via setSteps", () => {
const d = createDriver({ animate: false });
d.setSteps([{ element: "#card-1", popover: { title: "Replaced" } }]);
d.drive();
expect(popoverTitle()).toBe("Replaced");
expect(d.isLastStep()).toBe(true);
});
it("exposes the documented state shape via getState", () => {
const d = createDriver({ animate: false, steps: SAMPLE_STEPS });
d.drive();
expect(d.getState("isInitialized")).toBe(true);
expect(d.getState("activeIndex")).toBe(0);
const state = d.getState();
expect(state.activeStep?.popover?.title).toBe("Step 1");
expect(state.activeElement).toBe(document.querySelector("#intro"));
});
it("refreshes an active highlight without throwing", () => {
const d = createDriver({ animate: false });
d.highlight({ element: "#intro", popover: { title: "Intro" } });
expect(() => d.refresh()).not.toThrow();
expect(d.isActive()).toBe(true);
});
});