Browse Source

add a success case to the unit test

ryosei-f 1 week ago
parent
commit
7c8a6d76ba
1 changed files with 19 additions and 14 deletions
  1. 19 14
      packages/presentation/src/client/components/GrowiSlides.spec.tsx

+ 19 - 14
packages/presentation/src/client/components/GrowiSlides.spec.tsx

@@ -1,4 +1,4 @@
-import { render } from '@testing-library/react';
+import { render, screen } from '@testing-library/react';
 import { describe, expect, it, vi } from 'vitest';
 import { describe, expect, it, vi } from 'vitest';
 
 
 import { GrowiSlides } from './GrowiSlides';
 import { GrowiSlides } from './GrowiSlides';
@@ -21,33 +21,38 @@ vi.mock('./RichSlideSection', () => ({
   PresentationRichSlideSection: () => <div />,
   PresentationRichSlideSection: () => <div />,
 }));
 }));
 
 
+const validRendererOptions = {
+  remarkPlugins: [],
+  rehypePlugins: [],
+  components: {},
+};
+
 describe('GrowiSlides', () => {
 describe('GrowiSlides', () => {
   it('does not throw when rendererOptions is undefined', () => {
   it('does not throw when rendererOptions is undefined', () => {
     expect(() =>
     expect(() =>
       render(
       render(
-        <GrowiSlides options={{ rendererOptions: undefined as any }}>
+        <GrowiSlides options={{ rendererOptions: undefined }}>
           {'# Slide'}
           {'# Slide'}
         </GrowiSlides>,
         </GrowiSlides>,
       ),
       ),
     ).not.toThrow();
     ).not.toThrow();
   });
   });
 
 
-  it('does not throw when rendererOptions is null', () => {
-    expect(() =>
-      render(
-        <GrowiSlides options={{ rendererOptions: null as any }}>
-          {'# Slide'}
-        </GrowiSlides>,
-      ),
-    ).not.toThrow();
-  });
-
-  it('renders nothing when rendererOptions is null', () => {
+  it('renders nothing when rendererOptions is undefined', () => {
     const { container } = render(
     const { container } = render(
-      <GrowiSlides options={{ rendererOptions: null as any }}>
+      <GrowiSlides options={{ rendererOptions: undefined }}>
         {'# Slide'}
         {'# Slide'}
       </GrowiSlides>,
       </GrowiSlides>,
     );
     );
     expect(container.firstChild).toBeNull();
     expect(container.firstChild).toBeNull();
   });
   });
+
+  it('renders slides content when rendererOptions is valid', () => {
+    render(
+      <GrowiSlides options={{ rendererOptions: validRendererOptions }}>
+        {'# Slide 1'}
+      </GrowiSlides>,
+    );
+    expect(screen.queryByText('Slide 1')).toBeTruthy();
+  });
 });
 });