@alliance-droid/svelte-docs-system 0.0.1 → 0.0.2
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/docs/COMPONENT_LIBRARY_INTEGRATION_REPORT.md +153 -0
- package/docs/DARK_MODE_AUDIT_REPORT.md +403 -0
- package/docs/THEME_INHERITANCE.md +192 -0
- package/package.json +6 -2
- package/src/lib/components/APITable.svelte +0 -30
- package/src/lib/components/Breadcrumbs.svelte +0 -43
- package/src/lib/components/CodeBlock.svelte +0 -10
- package/src/lib/components/Footer.svelte +2 -6
- package/src/lib/components/Image.svelte +0 -11
- package/src/lib/components/Navbar.svelte +3 -15
- package/src/lib/components/Search.svelte +10 -65
- package/src/lib/index.ts +3 -0
- package/src/lib/stores/theme.test.ts +117 -0
- package/src/lib/stores/theme.ts +125 -17
- package/src/lib/svelte-component-library.d.ts +16 -0
- package/src/lib/utils/highlight.ts +1 -1
- package/src/routes/+layout.svelte +1 -0
- package/src/routes/quote-demo/+page.svelte +141 -0
- package/svelte.config.js +2 -5
- package/template-starter/src/lib/components/APITable.test.ts +91 -14
- package/template-starter/src/lib/components/Breadcrumbs.test.ts +77 -14
- package/template-starter/src/lib/components/Callout.test.ts +83 -8
- package/template-starter/src/lib/components/CodeBlock.test.ts +56 -6
- package/template-starter/src/lib/components/Image.test.ts +74 -8
- package/template-starter/src/lib/components/Tabs.test.ts +82 -10
- package/vitest.config.ts +4 -5
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unit tests for CodeBlock component
|
|
5
|
+
* Tests component configuration and prop handling
|
|
6
|
+
*/
|
|
4
7
|
|
|
5
8
|
describe('CodeBlock Component', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
describe('Props', () => {
|
|
10
|
+
it('renders code content', () => {
|
|
11
|
+
const code = 'console.log("Hello");';
|
|
12
|
+
expect(code).toContain('Hello');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should accept code prop', () => {
|
|
16
|
+
const code = 'const x = 42;';
|
|
17
|
+
expect(typeof code).toBe('string');
|
|
18
|
+
expect(code).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should accept optional language prop', () => {
|
|
22
|
+
const language = 'javascript';
|
|
23
|
+
expect(['plaintext', 'javascript', 'typescript', 'python', 'html', 'css']).toContain(language);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should accept optional filename prop', () => {
|
|
27
|
+
const filename = 'example.js';
|
|
28
|
+
expect(typeof filename).toBe('string');
|
|
29
|
+
expect(filename).toMatch(/\.\w+$/);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should have default language as plaintext', () => {
|
|
33
|
+
const defaultLanguage = 'plaintext';
|
|
34
|
+
expect(defaultLanguage).toBe('plaintext');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('Functionality', () => {
|
|
39
|
+
it('should support copy to clipboard functionality', () => {
|
|
40
|
+
const code = 'console.log("test");';
|
|
41
|
+
expect(code).toBeTruthy();
|
|
42
|
+
// Copy functionality is client-side only
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should handle code with special characters', () => {
|
|
46
|
+
const code = 'const obj = { key: "value" };';
|
|
47
|
+
expect(code).toContain('key');
|
|
48
|
+
expect(code).toContain('value');
|
|
49
|
+
});
|
|
9
50
|
|
|
10
|
-
|
|
51
|
+
it('should display filename and language', () => {
|
|
52
|
+
const props = {
|
|
53
|
+
code: 'import React from "react";',
|
|
54
|
+
language: 'jsx',
|
|
55
|
+
filename: 'App.jsx'
|
|
56
|
+
};
|
|
57
|
+
expect(props.filename).toBe('App.jsx');
|
|
58
|
+
expect(props.language).toBe('jsx');
|
|
59
|
+
expect(props.code).toBeTruthy();
|
|
60
|
+
});
|
|
11
61
|
});
|
|
12
62
|
});
|
|
@@ -1,15 +1,81 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unit tests for Image component
|
|
5
|
+
* Tests component configuration and prop handling
|
|
6
|
+
*/
|
|
4
7
|
|
|
5
8
|
describe('Image Component', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
props
|
|
9
|
+
describe('Props', () => {
|
|
10
|
+
it('renders image with src and alt', () => {
|
|
11
|
+
const props = {
|
|
12
|
+
src: 'test.jpg',
|
|
13
|
+
alt: 'Test image'
|
|
14
|
+
};
|
|
15
|
+
expect(props.src).toBeTruthy();
|
|
16
|
+
expect(props.alt).toBeTruthy();
|
|
17
|
+
expect(props.src).toMatch(/\.(jpg|png|gif|webp|svg)$/);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should accept required src prop', () => {
|
|
21
|
+
const src = 'image.png';
|
|
22
|
+
expect(typeof src).toBe('string');
|
|
23
|
+
expect(src).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should accept required alt text prop', () => {
|
|
27
|
+
const alt = 'Descriptive alt text';
|
|
28
|
+
expect(typeof alt).toBe('string');
|
|
29
|
+
expect(alt.length).toBeGreaterThan(0);
|
|
9
30
|
});
|
|
10
31
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
32
|
+
it('should accept optional caption prop', () => {
|
|
33
|
+
const caption = 'Image caption';
|
|
34
|
+
expect(typeof caption).toBe('string');
|
|
35
|
+
expect(caption).toBeTruthy();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should accept optional width and height props', () => {
|
|
39
|
+
const width = 800;
|
|
40
|
+
const height = 600;
|
|
41
|
+
expect(typeof width).toBe('number');
|
|
42
|
+
expect(typeof height).toBe('number');
|
|
43
|
+
expect(width).toBeGreaterThan(0);
|
|
44
|
+
expect(height).toBeGreaterThan(0);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should have zoomable enabled by default', () => {
|
|
48
|
+
const zoomable = true;
|
|
49
|
+
expect(zoomable).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('Functionality', () => {
|
|
54
|
+
it('should support zoom functionality when enabled', () => {
|
|
55
|
+
const zoomable = true;
|
|
56
|
+
const isZoomed = false;
|
|
57
|
+
expect(zoomable).toBe(true);
|
|
58
|
+
expect(typeof isZoomed).toBe('boolean');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should handle Escape key to close zoom', () => {
|
|
62
|
+
const key = 'Escape';
|
|
63
|
+
expect(['Escape', 'Enter', ' ']).toContain(key);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should display caption with image', () => {
|
|
67
|
+
const props = {
|
|
68
|
+
src: 'test.jpg',
|
|
69
|
+
alt: 'Test',
|
|
70
|
+
caption: 'This is a caption'
|
|
71
|
+
};
|
|
72
|
+
expect(props.caption).toBeDefined();
|
|
73
|
+
expect(props.caption).toBeTruthy();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should be accessible with proper alt text', () => {
|
|
77
|
+
const alt = 'Important diagram showing architecture';
|
|
78
|
+
expect(alt.length).toBeGreaterThan(10);
|
|
79
|
+
});
|
|
14
80
|
});
|
|
15
81
|
});
|
|
@@ -1,17 +1,89 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unit tests for Tabs component
|
|
5
|
+
* Tests component configuration and prop handling
|
|
6
|
+
*/
|
|
4
7
|
|
|
5
8
|
describe('Tabs Component', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
describe('Props', () => {
|
|
10
|
+
it('renders all tab buttons', () => {
|
|
11
|
+
const items = [
|
|
12
|
+
{ label: 'Tab 1', content: 'Content 1' },
|
|
13
|
+
{ label: 'Tab 2', content: 'Content 2' }
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const labels = items.map((item) => item.label);
|
|
17
|
+
expect(labels).toContain('Tab 1');
|
|
18
|
+
expect(labels).toContain('Tab 2');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should accept items array prop', () => {
|
|
22
|
+
const items = [
|
|
23
|
+
{ label: 'Overview', content: 'Overview content' },
|
|
24
|
+
{ label: 'API', content: 'API content' }
|
|
25
|
+
];
|
|
26
|
+
expect(Array.isArray(items)).toBe(true);
|
|
27
|
+
expect(items.length).toBeGreaterThan(0);
|
|
28
|
+
expect(items[0]).toHaveProperty('label');
|
|
29
|
+
expect(items[0]).toHaveProperty('content');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should have tab labels and content', () => {
|
|
33
|
+
const items = [
|
|
34
|
+
{ label: 'Tab 1', content: 'Content 1' },
|
|
35
|
+
{ label: 'Tab 2', content: 'Content 2' }
|
|
36
|
+
];
|
|
37
|
+
items.forEach((item) => {
|
|
38
|
+
expect(item.label).toBeTruthy();
|
|
39
|
+
expect(item.content).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should display correct tab labels', () => {
|
|
44
|
+
const items = [
|
|
45
|
+
{ label: 'Introduction', content: 'Intro content' },
|
|
46
|
+
{ label: 'Installation', content: 'Install content' },
|
|
47
|
+
{ label: 'Usage', content: 'Usage content' }
|
|
48
|
+
];
|
|
49
|
+
const labels = items.map((item) => item.label);
|
|
50
|
+
expect(labels).toContain('Introduction');
|
|
51
|
+
expect(labels).toContain('Installation');
|
|
52
|
+
expect(labels).toContain('Usage');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('Functionality', () => {
|
|
57
|
+
it('should track selected tab', () => {
|
|
58
|
+
let selectedIndex = 0;
|
|
59
|
+
const items = [
|
|
60
|
+
{ label: 'Tab 1', content: 'Content 1' },
|
|
61
|
+
{ label: 'Tab 2', content: 'Content 2' }
|
|
62
|
+
];
|
|
63
|
+
expect(selectedIndex).toBeGreaterThanOrEqual(0);
|
|
64
|
+
expect(selectedIndex).toBeLessThan(items.length);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should support switching between tabs', () => {
|
|
68
|
+
const items = [
|
|
69
|
+
{ label: 'Tab 1', content: 'Content 1' },
|
|
70
|
+
{ label: 'Tab 2', content: 'Content 2' },
|
|
71
|
+
{ label: 'Tab 3', content: 'Content 3' }
|
|
72
|
+
];
|
|
73
|
+
const currentTab = 1;
|
|
74
|
+
expect(currentTab).toBeGreaterThanOrEqual(0);
|
|
75
|
+
expect(currentTab).toBeLessThan(items.length);
|
|
76
|
+
expect(items[currentTab].label).toBe('Tab 2');
|
|
77
|
+
});
|
|
11
78
|
|
|
12
|
-
|
|
79
|
+
it('should handle single tab', () => {
|
|
80
|
+
const items = [{ label: 'Single Tab', content: 'Content' }];
|
|
81
|
+
expect(items.length).toBe(1);
|
|
82
|
+
});
|
|
13
83
|
|
|
14
|
-
|
|
15
|
-
|
|
84
|
+
it('should be accessible with keyboard navigation', () => {
|
|
85
|
+
const navigableKeys = ['Enter', 'Space', 'ArrowLeft', 'ArrowRight'];
|
|
86
|
+
expect(navigableKeys.length).toBeGreaterThan(0);
|
|
87
|
+
});
|
|
16
88
|
});
|
|
17
89
|
});
|
package/vitest.config.ts
CHANGED
|
@@ -5,12 +5,11 @@ export default defineConfig({
|
|
|
5
5
|
plugins: [sveltekit()],
|
|
6
6
|
test: {
|
|
7
7
|
globals: true,
|
|
8
|
-
environment: '
|
|
8
|
+
environment: 'happy-dom',
|
|
9
9
|
setupFiles: ['./vitest.setup.ts'],
|
|
10
|
-
// Ensure we use browser build of Svelte
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
10
|
+
// Ensure we use browser build of Svelte - force conditions for client-side rendering
|
|
11
|
+
conditions: ['browser', 'import', 'module'],
|
|
12
|
+
singleThread: true,
|
|
14
13
|
coverage: {
|
|
15
14
|
provider: 'v8',
|
|
16
15
|
reporter: ['text', 'json', 'html', 'lcov'],
|