52 lines
2.2 KiB
TypeScript
52 lines
2.2 KiB
TypeScript
/**
|
|
* Public-API barrel contract.
|
|
*
|
|
* Asserts the documented exports are wired through the three entry
|
|
* points declared in package.json (`.`, `./targeting`, `./client`).
|
|
* Catches a broken re-export (typo / removed symbol) before it reaches
|
|
* a consumer, which a unit test on the underlying module would miss.
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
import * as root from "./index.js";
|
|
import * as targeting from "./targeting/index.js";
|
|
import * as client from "./client/index.js";
|
|
|
|
describe("root barrel (@hivegrid/feature-flags)", () => {
|
|
it("re-exports the evaluation + cache + publisher functions", () => {
|
|
expect(typeof root.evaluateFlag).toBe("function");
|
|
expect(typeof root.getFeatureFlagVariant).toBe("function");
|
|
expect(typeof root.createFlagEvalCache).toBe("function");
|
|
expect(typeof root.buildCacheKey).toBe("function");
|
|
expect(typeof root.hashContext).toBe("function");
|
|
expect(typeof root.publishFeatureFlagInvalidationOnce).toBe("function");
|
|
expect(typeof root.publishFeatureFlagInvalidationViaStore).toBe("function");
|
|
});
|
|
|
|
it("exposes the invalidation channel constant", () => {
|
|
expect(root.FEATURE_FLAGS_INVALIDATION_CHANNEL).toBe("feature-flags:invalidate");
|
|
});
|
|
|
|
it("transitively re-exports the targeting helpers via `export *`", () => {
|
|
expect(typeof root.evaluateRule).toBe("function");
|
|
expect(typeof root.computeBucket).toBe("function");
|
|
expect(typeof root.isInRolloutBucket).toBe("function");
|
|
});
|
|
});
|
|
|
|
describe("targeting barrel (@hivegrid/feature-flags/targeting)", () => {
|
|
it("exposes the evaluator and percentage helpers", () => {
|
|
expect(typeof targeting.evaluateRule).toBe("function");
|
|
expect(typeof targeting.computeBucket).toBe("function");
|
|
expect(typeof targeting.isInRolloutBucket).toBe("function");
|
|
});
|
|
});
|
|
|
|
describe("client barrel (@hivegrid/feature-flags/client)", () => {
|
|
it("exposes the provider and hooks", () => {
|
|
expect(typeof client.FeatureFlagProvider).toBe("function");
|
|
expect(typeof client.useFeatureFlag).toBe("function");
|
|
expect(typeof client.useFeatureFlagEnabled).toBe("function");
|
|
expect(typeof client.useFeatureFlagVariant).toBe("function");
|
|
});
|
|
});
|