Skip to content

🎥 Make videos programmatically with React

add more testa

Jonny Burger79ced05eb5a1
diff --git a/packages/core/src/test/nested-sequences.test.tsx b/packages/core/src/test/nested-sequences.test.tsx
index 6483b127b0..897903e1f3 100644
--- a/packages/core/src/test/nested-sequences.test.tsx
+++ b/packages/core/src/test/nested-sequences.test.tsx
@@ -57,11 +57,92 @@ test('Negative offset test', () => {
>
<Sequence from={-200} durationInFrames={300}>
<Sequence from={10} durationInFrames={300}>
- <NestedChild />
+ <Sequence from={10} durationInFrames={300}>
+ <NestedChild />
+ </Sequence>
</Sequence>
</Sequence>
</TimelineContext.Provider>
);
- const result = queryByText(/^frame230/i);
+ const result = queryByText(/^frame220/i);
expect(result).not.toBe(null);
});
+
+test('Nested negative offset test', () => {
+ const NestedChild = () => {
+ const frame = useCurrentFrame();
+ return <div>{'frame' + frame}</div>;
+ };
+
+ const startAt = 40;
+ const endAt = 90;
+
+ const content = (
+ <Sequence from={0 - startAt} durationInFrames={endAt}>
+ <NestedChild />
+ </Sequence>
+ );
+
+ const getForFrame = (frame: number) => {
+ const {queryByText} = render(
+ <TimelineContext.Provider
+ value={{
+ frame,
+ playing: false,
+ shouldRegisterSequences: true,
+ }}
+ >
+ {content}
+ </TimelineContext.Provider>
+ );
+ return queryByText;
+ };
+
+ const frame0 = getForFrame(0);
+ expect(frame0(/^frame40$/i)).not.toBe(null);
+ const frame39 = getForFrame(39);
+ expect(frame39(/^frame79$/i)).not.toBe(null);
+ const frame50 = getForFrame(50);
+ expect(frame50(/^frame90$/i)).toBe(null);
+});
+
+test('Negative offset edge case', () => {
+ const NestedChild = () => {
+ const frame = useCurrentFrame();
+ return <div>{'frame' + frame}</div>;
+ };
+
+ const startAt = 40;
+ const endAt = 90;
+
+ const content = (
+ <Sequence from={40} durationInFrames={Infinity}>
+ <Sequence from={0 - startAt} durationInFrames={endAt}>
+ <NestedChild />
+ </Sequence>
+ </Sequence>
+ );
+
+ const getForFrame = (frame: number) => {
+ const {queryByText} = render(
+ <TimelineContext.Provider
+ value={{
+ frame,
+ playing: false,
+ shouldRegisterSequences: true,
+ }}
+ >
+ {content}
+ </TimelineContext.Provider>
+ );
+ return queryByText;
+ };
+
+ expect(getForFrame(0)(/^frame/i)).toBe(null);
+ expect(getForFrame(10)(/^frame/i)).toBe(null);
+ expect(getForFrame(40)(/^frame40$/i)).not.toBe(null);
+ const atFrame80 = getForFrame(80)(/^frame80$/i);
+ expect(atFrame80).not.toBe(null);
+ const atFrame90 = getForFrame(90)(/^frame90$/i);
+ expect(atFrame90).toBe(null);
+});