Skip to content

🎥 Make videos programmatically with React

add test to ensure that duration is not negative

Jonny Burgera40598971c98
diff --git a/packages/core/src/test/sequence-from-initial-offset.test.tsx b/packages/core/src/test/sequence-from-initial-offset.test.tsx
new file mode 100644
index 0000000000..f1c5b1b044
--- /dev/null
+++ b/packages/core/src/test/sequence-from-initial-offset.test.tsx
@@ -0,0 +1,52 @@
+/**
+ * @vitest-environment jsdom
+ */
+
+import {render} from '@testing-library/react';
+import React from 'react';
+import {describe, expect, test} from 'vitest';
+import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks';
+import {Freeze} from '../freeze';
+import type {TimelineContextValue} from '../internals';
+import {Internals} from '../internals';
+import {Sequence} from '../Sequence';
+import {useVideoConfig} from '../use-video-config';
+import {WrapSequenceContext} from './wrap-sequence-context';
+
+const Inner: React.FC = () => {
+ const config = useVideoConfig();
+
+ return <div>{config.durationInFrames}</div>;
+};
+
+const context: TimelineContextValue = {
+ audioAndVideoTags: {current: []},
+ frame: 10000,
+ imperativePlaying: {
+ current: false,
+ },
+ playbackRate: 0,
+ playing: false,
+ rootId: 'hither',
+ setPlaybackRate: () => undefined,
+};
+
+describe('Composition-validation render should NOT throw with valid props', () => {
+ test('It should allow undefined as children', () => {
+ const {queryByText} = render(
+ <CanUseRemotionHooksProvider>
+ <WrapSequenceContext>
+ <Internals.Timeline.TimelineContext.Provider value={context}>
+ <Freeze frame={10000}>
+ <Sequence durationInFrames={2424} from={9265}>
+ <Inner />
+ </Sequence>
+ </Freeze>
+ </Internals.Timeline.TimelineContext.Provider>
+ </WrapSequenceContext>
+ </CanUseRemotionHooksProvider>
+ );
+
+ expect(queryByText(/^0$/)).not.toBe(null);
+ });
+});