@blotch/dolan 22.2.1 → 22.2.3
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.
- package/dist/commands/add.d.ts +6 -2
- package/dist/commands/add.js +32 -10
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/add.test.js +129 -9
- package/dist/commands/add.test.js.map +1 -1
- package/dist/commands/diff.d.ts +2 -1
- package/dist/commands/diff.js +38 -25
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/diff.test.js +72 -11
- package/dist/commands/diff.test.js.map +1 -1
- package/dist/commands/doctor.js +41 -27
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/doctor.test.js +93 -9
- package/dist/commands/doctor.test.js.map +1 -1
- package/dist/commands/eject.js +7 -0
- package/dist/commands/eject.js.map +1 -1
- package/dist/commands/eject.test.js +39 -0
- package/dist/commands/eject.test.js.map +1 -1
- package/dist/commands/info.js +3 -2
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/init.d.ts +37 -1
- package/dist/commands/init.js +149 -40
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/init.test.js +285 -26
- package/dist/commands/init.test.js.map +1 -1
- package/dist/commands/install-packages.d.ts +6 -0
- package/dist/commands/install-packages.js +20 -0
- package/dist/commands/install-packages.js.map +1 -0
- package/dist/commands/install-packages.test.d.ts +1 -0
- package/dist/commands/install-packages.test.js +55 -0
- package/dist/commands/install-packages.test.js.map +1 -0
- package/dist/commands/list.js +21 -14
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/list.test.js +62 -5
- package/dist/commands/list.test.js.map +1 -1
- package/dist/commands/outdated.js +11 -10
- package/dist/commands/outdated.js.map +1 -1
- package/dist/commands/outdated.test.js +20 -5
- package/dist/commands/outdated.test.js.map +1 -1
- package/dist/commands/remove.d.ts +4 -0
- package/dist/commands/remove.js +17 -4
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/remove.test.js +53 -2
- package/dist/commands/remove.test.js.map +1 -1
- package/dist/commands/update.d.ts +6 -0
- package/dist/commands/update.js +59 -24
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/update.test.js +273 -31
- package/dist/commands/update.test.js.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/registry.d.ts +8 -0
- package/dist/registry.js +32 -24
- package/dist/registry.js.map +1 -1
- package/dist/registry.test.js +76 -37
- package/dist/registry.test.js.map +1 -1
- package/dist/testing/set-input-signal.d.ts +13 -0
- package/dist/testing/set-input-signal.js +20 -0
- package/dist/testing/set-input-signal.js.map +1 -0
- package/dist/testing/set-input-signal.test.d.ts +1 -0
- package/dist/testing/set-input-signal.test.js +20 -0
- package/dist/testing/set-input-signal.test.js.map +1 -0
- package/dist/ui/components/action-sheet/action-sheet.test.ts +48 -1
- package/dist/ui/components/action-sheet/action-sheet.ts +37 -9
- package/dist/ui/components/alert-dialog/alert-dialog.test.ts +49 -2
- package/dist/ui/components/alert-dialog/alert-dialog.ts +43 -12
- package/dist/ui/components/area-chart/area-chart-render.test.ts +52 -110
- package/dist/ui/components/area-chart/area-chart.test.ts +59 -146
- package/dist/ui/components/area-chart/area-chart.ts +100 -315
- package/dist/ui/components/area-chart/index.ts +2 -3
- package/dist/ui/components/bar-chart/bar-chart-render.test.ts +47 -163
- package/dist/ui/components/bar-chart/bar-chart.test.ts +82 -58
- package/dist/ui/components/bar-chart/bar-chart.ts +140 -294
- package/dist/ui/components/bar-chart/index.ts +3 -3
- package/dist/ui/components/bottom-sheet/bottom-sheet.test.ts +191 -9
- package/dist/ui/components/bottom-sheet/bottom-sheet.ts +136 -20
- package/dist/ui/components/button/button-render.test.ts +19 -0
- package/dist/ui/components/button/button.test.ts +2 -15
- package/dist/ui/components/button/button.ts +18 -2
- package/dist/ui/components/button-group/button-group.test.ts +2 -21
- package/dist/ui/components/candlestick-chart/candlestick-chart-render.test.ts +48 -163
- package/dist/ui/components/candlestick-chart/candlestick-chart.test.ts +107 -85
- package/dist/ui/components/candlestick-chart/candlestick-chart.ts +150 -323
- package/dist/ui/components/candlestick-chart/index.ts +3 -4
- package/dist/ui/components/chart/chart-focus.test.ts +132 -0
- package/dist/ui/components/chart/chart-focus.ts +115 -0
- package/dist/ui/components/chart/chart-presets.test.ts +139 -0
- package/dist/ui/components/chart/chart-presets.ts +271 -0
- package/dist/ui/components/chart/chart-render.test.ts +730 -0
- package/dist/ui/components/chart/chart-scene.test.ts +589 -0
- package/dist/ui/components/chart/chart-scene.ts +483 -0
- package/dist/ui/components/chart/chart-theme.test.ts +85 -0
- package/dist/ui/components/chart/chart-theme.ts +198 -0
- package/dist/ui/components/chart/chart-zoom.test.ts +159 -0
- package/dist/ui/components/chart/chart-zoom.ts +162 -0
- package/dist/ui/components/chart/chart.ts +921 -0
- package/dist/ui/components/chart/index.ts +24 -0
- package/dist/ui/components/dialog/dialog.test.ts +49 -2
- package/dist/ui/components/dialog/dialog.ts +43 -12
- package/dist/ui/components/icon/icon-theme.test.ts +133 -0
- package/dist/ui/components/icon/icon-theme.ts +204 -0
- package/dist/ui/components/icon/icon.test.ts +51 -2
- package/dist/ui/components/icon/icon.ts +38 -21
- package/dist/ui/components/line-chart/index.ts +2 -3
- package/dist/ui/components/line-chart/line-chart-render.test.ts +69 -107
- package/dist/ui/components/line-chart/line-chart.test.ts +63 -67
- package/dist/ui/components/line-chart/line-chart.ts +83 -241
- package/dist/ui/components/list/list.test.ts +69 -2
- package/dist/ui/components/list/list.ts +21 -15
- package/dist/ui/components/nav-drawer/nav-drawer.test.ts +80 -1
- package/dist/ui/components/nav-drawer/nav-drawer.ts +66 -11
- package/dist/ui/components/pagination/pagination.test.ts +62 -0
- package/dist/ui/components/pagination/pagination.ts +55 -8
- package/dist/ui/components/scatter-chart/index.ts +2 -3
- package/dist/ui/components/scatter-chart/scatter-chart-render.test.ts +51 -144
- package/dist/ui/components/scatter-chart/scatter-chart.test.ts +57 -47
- package/dist/ui/components/scatter-chart/scatter-chart.ts +104 -250
- package/dist/ui/components/scroll-area/scroll-area.test.ts +37 -2
- package/dist/ui/components/scroll-area/scroll-area.ts +8 -8
- package/dist/ui/components/spinner/spinner.test.ts +27 -0
- package/dist/ui/components/spinner/spinner.ts +33 -23
- package/dist/ui/components/toast/toast.test.ts +37 -0
- package/dist/ui/components/toast/toast.ts +20 -4
- package/dist/ui/theme/chart-colors.test.ts +30 -0
- package/dist/ui/theme/dark.css +8 -0
- package/dist/ui/theme/default.css +8 -0
- package/dist/ui/theme/icon-colors.test.ts +30 -0
- package/dist/ui/theme/tailwind-plugin.ts +10 -1
- package/dist/utils/installed.d.ts +17 -0
- package/dist/utils/installed.js +27 -0
- package/dist/utils/installed.js.map +1 -0
- package/dist/utils/installed.test.d.ts +1 -0
- package/dist/utils/installed.test.js +41 -0
- package/dist/utils/installed.test.js.map +1 -0
- package/dist/utils/interactive.d.ts +9 -0
- package/dist/utils/interactive.js +10 -0
- package/dist/utils/interactive.js.map +1 -0
- package/dist/utils/interactive.test.d.ts +1 -0
- package/dist/utils/interactive.test.js +24 -0
- package/dist/utils/interactive.test.js.map +1 -0
- package/dist/utils/packages.d.ts +36 -0
- package/dist/utils/packages.js +70 -0
- package/dist/utils/packages.js.map +1 -0
- package/dist/utils/packages.test.d.ts +1 -0
- package/dist/utils/packages.test.js +89 -0
- package/dist/utils/packages.test.js.map +1 -0
- package/dist/utils/resolve-paths.d.ts +17 -1
- package/dist/utils/resolve-paths.js +23 -3
- package/dist/utils/resolve-paths.js.map +1 -1
- package/dist/utils/resolve-paths.test.js +34 -2
- package/dist/utils/resolve-paths.test.js.map +1 -1
- package/package.json +5 -1
- package/dist/ui/components/cartesian-chart/cartesian-chart-render.test.ts +0 -188
- package/dist/ui/components/cartesian-chart/cartesian-chart.test.ts +0 -549
- package/dist/ui/components/cartesian-chart/cartesian-chart.ts +0 -1140
- package/dist/ui/components/cartesian-chart/index.ts +0 -18
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { detectPackageManager, installCommand, installPackages, missingPackages, packageName, } from './packages';
|
|
6
|
+
let root;
|
|
7
|
+
const makeRoot = () => {
|
|
8
|
+
root = mkdtempSync(join(tmpdir(), 'dolan-packages-'));
|
|
9
|
+
return root;
|
|
10
|
+
};
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
if (root)
|
|
13
|
+
rmSync(root, { recursive: true, force: true });
|
|
14
|
+
});
|
|
15
|
+
describe('detectPackageManager', () => {
|
|
16
|
+
it.each([
|
|
17
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
18
|
+
['yarn.lock', 'yarn'],
|
|
19
|
+
['bun.lock', 'bun'],
|
|
20
|
+
['bun.lockb', 'bun'],
|
|
21
|
+
['package-lock.json', 'npm'],
|
|
22
|
+
])('reads %s as %s', (lockfile, manager) => {
|
|
23
|
+
writeFileSync(join(makeRoot(), lockfile), '');
|
|
24
|
+
expect(detectPackageManager(root)).toBe(manager);
|
|
25
|
+
});
|
|
26
|
+
it("finds a workspace root's lockfile above the app", () => {
|
|
27
|
+
writeFileSync(join(makeRoot(), 'pnpm-lock.yaml'), '');
|
|
28
|
+
const app = join(root, 'apps', 'mobile');
|
|
29
|
+
mkdirSync(app, { recursive: true });
|
|
30
|
+
expect(detectPackageManager(app)).toBe('pnpm');
|
|
31
|
+
});
|
|
32
|
+
it('defaults to npm without a lockfile', () => {
|
|
33
|
+
expect(detectPackageManager(makeRoot())).toBe('npm');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('packageName', () => {
|
|
37
|
+
it('strips the version range, keeping a scope', () => {
|
|
38
|
+
expect(packageName('@tanstack/charts@^1.1.0')).toBe('@tanstack/charts');
|
|
39
|
+
expect(packageName('d3-shape@^3.2.0')).toBe('d3-shape');
|
|
40
|
+
expect(packageName('d3-shape')).toBe('d3-shape');
|
|
41
|
+
expect(packageName('@scope/name')).toBe('@scope/name');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('missingPackages', () => {
|
|
45
|
+
it("lists specs the project's package.json doesn't name in any section", () => {
|
|
46
|
+
writeFileSync(join(makeRoot(), 'package.json'), JSON.stringify({
|
|
47
|
+
dependencies: { a: '1' },
|
|
48
|
+
devDependencies: { b: '1' },
|
|
49
|
+
peerDependencies: { c: '1' },
|
|
50
|
+
}));
|
|
51
|
+
expect(missingPackages(root, ['a@^1', 'b', 'c@2', 'd@^4'])).toEqual([
|
|
52
|
+
'd@^4',
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
it('treats a missing package.json as listing nothing', () => {
|
|
56
|
+
expect(missingPackages(makeRoot(), ['a'])).toEqual(['a']);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('installCommand', () => {
|
|
60
|
+
it("uses each manager's add verb", () => {
|
|
61
|
+
expect(installCommand('npm', ['a', 'b'])).toEqual([
|
|
62
|
+
'npm',
|
|
63
|
+
'install',
|
|
64
|
+
'a',
|
|
65
|
+
'b',
|
|
66
|
+
]);
|
|
67
|
+
expect(installCommand('pnpm', ['a'])).toEqual(['pnpm', 'add', 'a']);
|
|
68
|
+
expect(installCommand('yarn', ['a'])).toEqual(['yarn', 'add', 'a']);
|
|
69
|
+
expect(installCommand('bun', ['a'])).toEqual(['bun', 'add', 'a']);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe('installPackages', () => {
|
|
73
|
+
it("runs the project's package manager in the project", () => {
|
|
74
|
+
writeFileSync(join(makeRoot(), 'yarn.lock'), '');
|
|
75
|
+
const run = vi.fn(() => ({ status: 0 }));
|
|
76
|
+
expect(installPackages(root, ['a@1'], run)).toBe(true);
|
|
77
|
+
expect(run).toHaveBeenCalledWith('yarn', ['add', 'a@1'], {
|
|
78
|
+
cwd: root,
|
|
79
|
+
stdio: 'inherit',
|
|
80
|
+
shell: process.platform === 'win32',
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it("reports an install that failed or couldn't start", () => {
|
|
84
|
+
makeRoot();
|
|
85
|
+
expect(installPackages(root, ['a'], (() => ({ status: 1 })))).toBe(false);
|
|
86
|
+
expect(installPackages(root, ['a'], (() => ({ status: null })))).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
//# sourceMappingURL=packages.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.test.js","sourceRoot":"","sources":["../../src/utils/packages.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,IAAI,IAAY,CAAC;AACjB,MAAM,QAAQ,GAAG,GAAG,EAAE;IACpB,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACtD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,SAAS,CAAC,GAAG,EAAE;IACb,IAAI,IAAI;QAAE,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,IAAI,CAAC;QACN,CAAC,gBAAgB,EAAE,MAAM,CAAC;QAC1B,C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AC,eAAe,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC,CAAC,CAAC,IAAI,CACzE,KAAK,CACN,CAAC;QACF,MAAM,CACJ,eAAe,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAU,CAAC,CAClE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
export declare const getUiSourceDir: () => string;
|
|
2
2
|
export declare const getComponentSourceDir: (componentName: string) => string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The files a component ships: its `.ts` sources and, when `tests` is set,
|
|
5
|
+
* its `<name>.test.ts`. Tests render with
|
|
6
|
+
* `@blotch/angular-lynx-testing-library`, so the commands pass
|
|
7
|
+
* `copiesTests(cwd)`: an app without the library would fail to compile them
|
|
8
|
+
* in `ng test`. `*-render.test.ts` always stays behind: those render the
|
|
9
|
+
* component through the library's own JIT test harness, so in an app they
|
|
10
|
+
* wouldn't compile either.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getComponentFiles: (componentName: string, { tests }: {
|
|
13
|
+
tests: boolean;
|
|
14
|
+
}) => string[];
|
|
4
15
|
/**
|
|
5
16
|
* When copying component source files from the bundled @blotch/ui package
|
|
6
17
|
* into the user's project, relative imports to shared utilities
|
|
@@ -8,5 +19,10 @@ export declare const getComponentFiles: (componentName: string) => string[];
|
|
|
8
19
|
* package path (`from '@blotch/dolan/utils/cn'`). The relative paths
|
|
9
20
|
* only work inside the monorepo source tree — in the user's project,
|
|
10
21
|
* the utils are consumed as package exports from @blotch/dolan.
|
|
22
|
+
*
|
|
23
|
+
* Tests import the library's test helpers the same way
|
|
24
|
+
* (`../../../test-utils/set-input-signal`), and @blotch/dolan ships those
|
|
25
|
+
* too, as `@blotch/dolan/testing/*`. Without the rewrite, a copied test
|
|
26
|
+
* imported a file the app doesn't have and broke its `ng test`.
|
|
11
27
|
*/
|
|
12
28
|
export declare const rewriteImports: (fileContent: string) => string;
|
|
@@ -9,9 +9,20 @@ export const getUiSourceDir = () => {
|
|
|
9
9
|
export const getComponentSourceDir = (componentName) => {
|
|
10
10
|
return join(getUiSourceDir(), 'components', componentName);
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The files a component ships: its `.ts` sources and, when `tests` is set,
|
|
14
|
+
* its `<name>.test.ts`. Tests render with
|
|
15
|
+
* `@blotch/angular-lynx-testing-library`, so the commands pass
|
|
16
|
+
* `copiesTests(cwd)`: an app without the library would fail to compile them
|
|
17
|
+
* in `ng test`. `*-render.test.ts` always stays behind: those render the
|
|
18
|
+
* component through the library's own JIT test harness, so in an app they
|
|
19
|
+
* wouldn't compile either.
|
|
20
|
+
*/
|
|
21
|
+
export const getComponentFiles = (componentName, { tests }) => {
|
|
13
22
|
const dir = getComponentSourceDir(componentName);
|
|
14
|
-
return readdirSync(dir).filter((f) => f.endsWith('.ts')
|
|
23
|
+
return readdirSync(dir).filter((f) => f.endsWith('.ts') &&
|
|
24
|
+
!f.endsWith('-render.test.ts') &&
|
|
25
|
+
(tests || !f.endsWith('.test.ts')));
|
|
15
26
|
};
|
|
16
27
|
/**
|
|
17
28
|
* When copying component source files from the bundled @blotch/ui package
|
|
@@ -20,10 +31,19 @@ export const getComponentFiles = (componentName) => {
|
|
|
20
31
|
* package path (`from '@blotch/dolan/utils/cn'`). The relative paths
|
|
21
32
|
* only work inside the monorepo source tree — in the user's project,
|
|
22
33
|
* the utils are consumed as package exports from @blotch/dolan.
|
|
34
|
+
*
|
|
35
|
+
* Tests import the library's test helpers the same way
|
|
36
|
+
* (`../../../test-utils/set-input-signal`), and @blotch/dolan ships those
|
|
37
|
+
* too, as `@blotch/dolan/testing/*`. Without the rewrite, a copied test
|
|
38
|
+
* imported a file the app doesn't have and broke its `ng test`.
|
|
23
39
|
*/
|
|
24
40
|
export const rewriteImports = (fileContent) => {
|
|
25
|
-
return fileContent
|
|
41
|
+
return fileContent
|
|
42
|
+
.replace(/from\s+['"]\.\.\/\.\.\/utils\/([^'"]+)['"];?/g, (_match, utilName) => {
|
|
26
43
|
return `from '@blotch/dolan/utils/${utilName}';`;
|
|
44
|
+
})
|
|
45
|
+
.replace(/from\s+['"]\.\.\/\.\.\/\.\.\/test-utils\/([^'"]+)['"];?/g, (_match, helperName) => {
|
|
46
|
+
return `from '@blotch/dolan/testing/${helperName}';`;
|
|
27
47
|
});
|
|
28
48
|
};
|
|
29
49
|
//# sourceMappingURL=resolve-paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-paths.js","sourceRoot":"","sources":["../../src/utils/resolve-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAW,EAAE;IACzC,iEAAiE;IACjE,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9E,OAAO,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,aAAqB,EAAU,EAAE;IACrE,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAA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W;SACf,OAAO,CACN,+CAA+C,EAC/C,CAAC,MAAM,EAAE,QAAgB,EAAE,EAAE;QAC3B,OAAO,6BAA6B,QAAQ,IAAI,CAAC;IACnD,CAAC,CACF;SACA,OAAO,CACN,0DAA0D,EAC1D,CAAC,MAAM,EAAE,UAAkB,EAAE,EAAE;QAC7B,OAAO,+BAA+B,UAAU,IAAI,CAAC;IACvD,CAAC,CACF,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { getUiSourceDir, getComponentSourceDir, getComponentFiles, rewriteImports, } from './resolve-paths';
|
|
5
5
|
// Deliberately unmocked (unlike the command tests, which stub this module out
|
|
@@ -24,13 +24,41 @@ describe('getComponentFiles', () => {
|
|
|
24
24
|
it('lists only .ts files for a real registry component', () => {
|
|
25
25
|
// card/ ships card.ts + index.ts alongside no non-.ts files, so this also
|
|
26
26
|
// pins that non-.ts assets (if any were added later) would be filtered.
|
|
27
|
-
const files = getComponentFiles('card');
|
|
27
|
+
const files = getComponentFiles('card', { tests: true });
|
|
28
28
|
expect(files).toContain('card.ts');
|
|
29
29
|
expect(files).toContain('index.ts');
|
|
30
30
|
for (const file of files) {
|
|
31
31
|
expect(file.endsWith('.ts')).toBe(true);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
+
it("leaves the library's render tests behind", () => {
|
|
35
|
+
// line-chart has both: line-chart.test.ts ships, the render test doesn't.
|
|
36
|
+
const files = getComponentFiles('line-chart', { tests: true });
|
|
37
|
+
expect(files).toContain('line-chart.test.ts');
|
|
38
|
+
expect(files).not.toContain('line-chart-render.test.ts');
|
|
39
|
+
});
|
|
40
|
+
it('leaves every test behind for an app without the testing library', () => {
|
|
41
|
+
const files = getComponentFiles('line-chart', { tests: false });
|
|
42
|
+
expect(files).toContain('line-chart.ts');
|
|
43
|
+
expect(files.filter((file) => file.endsWith('.test.ts'))).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
it('ships every test helper the copied tests import', () => {
|
|
46
|
+
// rewriteImports points `../../../test-utils/<name>` at
|
|
47
|
+
// `@blotch/dolan/testing/<name>`, so each one needs a file and an export.
|
|
48
|
+
const exports = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf-8')).exports;
|
|
49
|
+
const components = join(getUiSourceDir(), 'components');
|
|
50
|
+
for (const name of readdirSync(components)) {
|
|
51
|
+
for (const file of getComponentFiles(name, { tests: true })) {
|
|
52
|
+
const source = readFileSync(join(components, name, file), 'utf-8');
|
|
53
|
+
for (const [, helper] of source.matchAll(/from '\.\.\/\.\.\/\.\.\/test-utils\/([^']+)'/g)) {
|
|
54
|
+
expect(exports, `${name}/${file}`).toHaveProperty([
|
|
55
|
+
`./testing/${helper}`,
|
|
56
|
+
]);
|
|
57
|
+
expect(existsSync(new URL(`../testing/${helper}.ts`, import.meta.url))).toBe(true);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
34
62
|
});
|
|
35
63
|
describe('rewriteImports', () => {
|
|
36
64
|
it('rewrites relative ../../utils/* imports to the published package path', () => {
|
|
@@ -44,6 +72,10 @@ describe('rewriteImports', () => {
|
|
|
44
72
|
const content = "import { Foo } from './foo';\nexport const x = 1;\n";
|
|
45
73
|
expect(rewriteImports(content)).toBe(content);
|
|
46
74
|
});
|
|
75
|
+
it('rewrites the test helpers to the ones @blotch/dolan ships', () => {
|
|
76
|
+
const content = "import { setInputSignal } from '../../../test-utils/set-input-signal';";
|
|
77
|
+
expect(rewriteImports(content)).toBe("import { setInputSignal } from '@blotch/dolan/testing/set-input-signal';");
|
|
78
|
+
});
|
|
47
79
|
it('rewrites an import with no trailing semicolon', () => {
|
|
48
80
|
const content = "import { cn } from '../../utils/cn'";
|
|
49
81
|
expect(rewriteImports(content)).toBe("import { cn } from '@blotch/dolan/utils/cn';");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-paths.test.js","sourceRoot":"","sources":["../../src/utils/resolve-paths.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-paths.test.js","sourceRoot":"","sources":["../../src/utils/resolve-paths.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,8EAA8E;AAC9E,oEAAoE;AACpE,uEAAuE;AACvE,uEAAuE;AACvE,uEAAuE;AACvE,yEAAyE;AACzE,UAAU;AACV,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CACxC,IAAI,CAAC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AE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,MAAM,GAAG,YAAY,CACzB,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,EAC9C,OAAO,CACR,CAAC;QACF,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;QAEzC,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,qCAAqC,CAAC,CAAC;QACnE,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,MAAM,OAAO,GAAG,qDAAqD,CAAC;QACtE,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,OAAO,GACX,wEAAwE,CAAC;QAC3E,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAClC,0EAA0E,CAC3E,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,OAAO,GAAG,qCAAqC,CAAC;QACtD,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAClC,8CAA8C,CAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotch/dolan",
|
|
3
|
-
"version": "22.2.
|
|
3
|
+
"version": "22.2.3",
|
|
4
4
|
"description": "CLI for adding @blotch/ui components to your project",
|
|
5
5
|
"homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"./utils/animate": {
|
|
28
28
|
"types": "./dist/utils/animate.d.ts",
|
|
29
29
|
"default": "./dist/utils/animate.js"
|
|
30
|
+
},
|
|
31
|
+
"./testing/set-input-signal": {
|
|
32
|
+
"types": "./dist/testing/set-input-signal.d.ts",
|
|
33
|
+
"default": "./dist/testing/set-input-signal.js"
|
|
30
34
|
}
|
|
31
35
|
},
|
|
32
36
|
"scripts": {
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { render, waitForUpdate } from '@blotch/angular-lynx-testing-library';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import { setInputSignal } from '../../../test-utils/set-input-signal';
|
|
4
|
-
import { UiCartesianChart } from './cartesian-chart';
|
|
5
|
-
|
|
6
|
-
// These tests exercise the class methods and template-facing computed signals of the
|
|
7
|
-
// full chart component (the sibling test file covers just the exported pure
|
|
8
|
-
// geometry helpers with a mocked Angular).
|
|
9
|
-
describe('UiCartesianChart — component', () => {
|
|
10
|
-
const readComputedSignals = (inst: UiCartesianChart) => {
|
|
11
|
-
const cast = inst as unknown as {
|
|
12
|
-
containerClass: () => string;
|
|
13
|
-
containerStyle: () => string;
|
|
14
|
-
plotStyle: () => string;
|
|
15
|
-
gridlines: () => { style: string }[];
|
|
16
|
-
verticalGridlines: () => { style: string }[];
|
|
17
|
-
yLabels: () => { style: string; text: string }[];
|
|
18
|
-
xLabels: () => { style: string; text: string }[];
|
|
19
|
-
yAxisLabelStyle: () => string;
|
|
20
|
-
xAxisLabelStyle: () => string;
|
|
21
|
-
zoomControlsStyle: () => string;
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
containerClass: cast.containerClass(),
|
|
25
|
-
containerStyle: cast.containerStyle(),
|
|
26
|
-
plotStyle: cast.plotStyle(),
|
|
27
|
-
gridlines: cast.gridlines(),
|
|
28
|
-
verticalGridlines: cast.verticalGridlines(),
|
|
29
|
-
yLabels: cast.yLabels(),
|
|
30
|
-
xLabels: cast.xLabels(),
|
|
31
|
-
yAxisLabelStyle: cast.yAxisLabelStyle(),
|
|
32
|
-
xAxisLabelStyle: cast.xAxisLabelStyle(),
|
|
33
|
-
zoomControlsStyle: cast.zoomControlsStyle(),
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
it('renders with default configuration', async () => {
|
|
38
|
-
const { container } = await render(UiCartesianChart);
|
|
39
|
-
expect(container).toBeTruthy();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('exposes shared scales that project data into the plot area', async () => {
|
|
43
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
44
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
45
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
46
|
-
setInputSignal(inst.yDomain, [0, 50]);
|
|
47
|
-
await waitForUpdate();
|
|
48
|
-
expect(typeof inst.xScale()).toBe('function');
|
|
49
|
-
expect(typeof inst.yScale()).toBe('function');
|
|
50
|
-
expect(inst.plotWidth()).toBeGreaterThan(0);
|
|
51
|
-
expect(inst.plotHeight()).toBeGreaterThan(0);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('produces gridlines, tick labels, and axis label styles', async () => {
|
|
55
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
56
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
57
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
58
|
-
setInputSignal(inst.yDomain, [0, 100]);
|
|
59
|
-
setInputSignal(inst.xAxisLabel, 'X label');
|
|
60
|
-
setInputSignal(inst.yAxisLabel, 'Y label');
|
|
61
|
-
setInputSignal(inst.showGrid, true);
|
|
62
|
-
setInputSignal(inst.showXGrid, true);
|
|
63
|
-
await waitForUpdate();
|
|
64
|
-
const c = readComputedSignals(inst);
|
|
65
|
-
expect(c.gridlines.length).toBeGreaterThan(0);
|
|
66
|
-
expect(c.verticalGridlines.length).toBeGreaterThan(0);
|
|
67
|
-
expect(c.yLabels.length).toBeGreaterThan(0);
|
|
68
|
-
expect(c.xLabels.length).toBeGreaterThan(0);
|
|
69
|
-
expect(c.yAxisLabelStyle).toContain('transform');
|
|
70
|
-
expect(c.xAxisLabelStyle.length).toBeGreaterThan(0);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('uses explicit tick arrays when provided', async () => {
|
|
74
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
75
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
76
|
-
setInputSignal(inst.xDomain, [0, 10]);
|
|
77
|
-
setInputSignal(inst.yDomain, [0, 10]);
|
|
78
|
-
setInputSignal(inst.xTicks, [0, 5, 10]);
|
|
79
|
-
setInputSignal(inst.yTicks, [0, 2, 5, 10]);
|
|
80
|
-
await waitForUpdate();
|
|
81
|
-
const c = readComputedSignals(inst);
|
|
82
|
-
expect(c.yLabels.map((l) => l.text).join(',')).toContain('5');
|
|
83
|
-
expect(c.xLabels.map((l) => l.text).join(',')).toContain('5');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('hides gridlines when disabled', async () => {
|
|
87
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
88
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
89
|
-
setInputSignal(inst.showGrid, false);
|
|
90
|
-
setInputSignal(inst.showXGrid, false);
|
|
91
|
-
await waitForUpdate();
|
|
92
|
-
// Even with showGrid=false the computed still runs — just verify the
|
|
93
|
-
// container mounts cleanly.
|
|
94
|
-
expect(readComputedSignals(inst).plotStyle.length).toBeGreaterThan(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('applies inner padding to shrink the projected range', async () => {
|
|
98
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
99
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
100
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
101
|
-
setInputSignal(inst.yDomain, [0, 100]);
|
|
102
|
-
setInputSignal(inst.padding, {
|
|
103
|
-
top: 0.1,
|
|
104
|
-
bottom: 0.1,
|
|
105
|
-
left: 0.1,
|
|
106
|
-
right: 0.1,
|
|
107
|
-
});
|
|
108
|
-
await waitForUpdate();
|
|
109
|
-
const scaleAtZero = inst.xScale()(0);
|
|
110
|
-
expect(scaleAtZero).toBeGreaterThan(0);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('zoomIn / zoomOut / resetZoom on the xy axes', async () => {
|
|
114
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
115
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
116
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
117
|
-
setInputSignal(inst.yDomain, [0, 100]);
|
|
118
|
-
setInputSignal(inst.zoomable, true);
|
|
119
|
-
await waitForUpdate();
|
|
120
|
-
inst.zoomIn();
|
|
121
|
-
inst.zoomOut();
|
|
122
|
-
inst.zoomIn();
|
|
123
|
-
inst.resetZoom();
|
|
124
|
-
// No throw; the internal view domains reset to null at rest.
|
|
125
|
-
expect(inst.xScale()(0)).toBeLessThan(inst.xScale()(100));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('zoomIn only along the x-axis when zoomAxes = "x"', async () => {
|
|
129
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
130
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
131
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
132
|
-
setInputSignal(inst.yDomain, [0, 100]);
|
|
133
|
-
setInputSignal(inst.zoomable, true);
|
|
134
|
-
setInputSignal(inst.zoomAxes, 'x');
|
|
135
|
-
await waitForUpdate();
|
|
136
|
-
inst.zoomIn();
|
|
137
|
-
inst.zoomIn();
|
|
138
|
-
expect(typeof inst.xScale()).toBe('function');
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('zoomIn only along the y-axis when zoomAxes = "y"', async () => {
|
|
142
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
143
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
144
|
-
setInputSignal(inst.xDomain, [0, 100]);
|
|
145
|
-
setInputSignal(inst.yDomain, [0, 100]);
|
|
146
|
-
setInputSignal(inst.zoomable, true);
|
|
147
|
-
setInputSignal(inst.zoomAxes, 'y');
|
|
148
|
-
await waitForUpdate();
|
|
149
|
-
inst.zoomIn();
|
|
150
|
-
inst.zoomIn();
|
|
151
|
-
expect(typeof inst.yScale()).toBe('function');
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('shows zoom controls only when zoomable', async () => {
|
|
155
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
156
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
157
|
-
setInputSignal(inst.zoomable, true);
|
|
158
|
-
setInputSignal(inst.showZoomControls, true);
|
|
159
|
-
await waitForUpdate();
|
|
160
|
-
expect(readComputedSignals(inst).zoomControlsStyle.length).toBeGreaterThan(
|
|
161
|
-
0,
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('containerClass includes user class alias', async () => {
|
|
166
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
167
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
168
|
-
setInputSignal(inst.userClass, 'my-chart');
|
|
169
|
-
await waitForUpdate();
|
|
170
|
-
expect(readComputedSignals(inst).containerClass).toContain('my-chart');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('zoomIn on a zero-width x-domain collapses back to rest (full-span guard)', async () => {
|
|
174
|
-
const { componentRef } = await render(UiCartesianChart);
|
|
175
|
-
const inst = componentRef.instance as UiCartesianChart;
|
|
176
|
-
// A degenerate domain forces the #isFullSpan(baseSpan === 0) branch when
|
|
177
|
-
// any zoom write is attempted.
|
|
178
|
-
setInputSignal(inst.xDomain, [5, 5]);
|
|
179
|
-
setInputSignal(inst.yDomain, [5, 5]);
|
|
180
|
-
setInputSignal(inst.zoomable, true);
|
|
181
|
-
await waitForUpdate();
|
|
182
|
-
inst.zoomIn();
|
|
183
|
-
inst.zoomOut();
|
|
184
|
-
inst.resetZoom();
|
|
185
|
-
// Scales remain callable and produce a finite pixel value at the domain point.
|
|
186
|
-
expect(Number.isFinite(inst.xScale()(5))).toBe(true);
|
|
187
|
-
});
|
|
188
|
-
});
|