chartjs-test-utils 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ export declare function toBeCloseToPixel(actual: any, expected: any): {
2
+ message: () => string;
3
+ pass: boolean;
4
+ };
5
+ export declare function toBeCloseToPoint(actual: any, expected: any): {
6
+ message: () => string;
7
+ pass: boolean;
8
+ };
9
+ export declare function toEqualOneOf(actual: any, expecteds: any): {
10
+ message: () => string;
11
+ pass: boolean;
12
+ };
13
+ export declare function toBeValidChart(actual: any): {
14
+ message: () => string;
15
+ pass: boolean;
16
+ };
17
+ export declare function toBeChartOfSize(actual: any, expected: any): {
18
+ message: () => string;
19
+ pass: boolean;
20
+ };
21
+ /**
22
+ * Compares a rendered canvas against a reference image.
23
+ * @param {object} actual - a Chart, a canvas or a 2d context
24
+ * @param {ImageData} [expected] - the reference image data
25
+ * @param {object} [opts] - comparison options
26
+ * @param {number} [opts.threshold] - per pixel color distance, see pixelmatch
27
+ * @param {number} [opts.tolerance] - accepted ratio of differing pixels
28
+ * @param {boolean} [opts.checkerboard] - blend transparency against a checkerboard instead of white
29
+ * @param {boolean} [opts.debug] - always fail and log the preview
30
+ * @param {string} [opts.description] - label for the logged preview
31
+ */
32
+ export declare function toEqualImageData(actual: object, expected?: ImageData, opts?: {
33
+ threshold?: number;
34
+ tolerance?: number;
35
+ checkerboard?: boolean;
36
+ debug?: boolean;
37
+ description?: string;
38
+ }): {
39
+ message: () => string;
40
+ pass: boolean;
41
+ };
42
+ export declare function toEqualOptions(actual: any, expected: any): {
43
+ message: () => string;
44
+ pass: boolean;
45
+ };
46
+ export declare const matchers: {
47
+ toBeChartOfSize: typeof toBeChartOfSize;
48
+ toBeCloseToPixel: typeof toBeCloseToPixel;
49
+ toBeCloseToPoint: typeof toBeCloseToPoint;
50
+ toBeValidChart: typeof toBeValidChart;
51
+ toEqualImageData: typeof toEqualImageData;
52
+ toEqualOneOf: typeof toEqualOneOf;
53
+ toEqualOptions: typeof toEqualOptions;
54
+ };
55
+ export default matchers;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Compares resolved chart options, ignoring private (`_`-prefixed) properties.
3
+ * @param {object} actual - the options to check
4
+ * @param {object} expected - the expected subset
5
+ * @returns {{pass: boolean, message: string}}
6
+ */
7
+ export declare function compareOptions(actual: object, expected: object): {
8
+ pass: boolean;
9
+ message: string;
10
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The node side of the fixture update mode.
3
+ *
4
+ * Kept out of the browser entry on purpose: this module reads `node:fs`, which
5
+ * the browser bundle must never pull in. Import it from the Vitest browser
6
+ * config, which runs in node.
7
+ */
8
+ /**
9
+ * Builds the `saveFixtureImage` browser command.
10
+ *
11
+ * Register it only when actually updating, and let the suite detect the mode
12
+ * from the command's presence. A flag would have to be passed through `define`,
13
+ * which Vitest re-encodes: `JSON.stringify(false)` arrives in the browser as
14
+ * the string "false", which is truthy, and every fixture quietly rewrites
15
+ * itself while reporting a pass.
16
+ *
17
+ * @param {object} [options]
18
+ * @param {string} [options.dir] - fixture root, relative to the working directory
19
+ * @returns the browser command
20
+ *
21
+ * @example
22
+ * const updating = process.env.UPDATE_FIXTURES === '1';
23
+ * export default defineConfig({
24
+ * test: {
25
+ * browser: {
26
+ * commands: updating ? {saveFixtureImage: createSaveFixtureImage()} : {}
27
+ * }
28
+ * }
29
+ * });
30
+ */
31
+ export declare function createSaveFixtureImage({ dir }?: {
32
+ dir?: string;
33
+ }): import("vitest/node").BrowserCommand<[name: unknown, dataUrl: unknown], any>;
@@ -0,0 +1,2 @@
1
+ export declare function spritingOn(ctx: any): void;
2
+ export declare function spritingOff(ctx: any): void;