forked from cardosofelipe/fast-next-template
Add comprehensive unit tests for homepage components and utilities
- Introduced unit tests for homepage components: `QuickStartCode`, `Header`, `DemoCredentialsModal`, `AnimatedTerminal`, `CTASection`, and `StatsSection`. - Added utility tests for `chart-colors` including opacity, palettes, and gradient validation. - Mocked dependencies (`framer-motion`, `react-syntax-highlighter`, `DemoCredentialsModal`) for isolated testing. - Verified accessibility features, animations, and interactive behaviors across components.
This commit is contained in:
@@ -23,6 +23,19 @@ global.BroadcastChannel = class BroadcastChannel {
|
||||
removeEventListener() {}
|
||||
};
|
||||
|
||||
// Mock IntersectionObserver for components that use viewport detection
|
||||
global.IntersectionObserver = class IntersectionObserver {
|
||||
constructor(callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
observe() {
|
||||
// Immediately trigger the callback with isIntersecting: true for tests
|
||||
this.callback([{ isIntersecting: true }]);
|
||||
}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
};
|
||||
|
||||
// Use real Web Crypto API polyfill for Node environment
|
||||
const cryptoPolyfill = new Crypto();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user