Skip to content

🎥 Make videos programmatically with React

Update series test assertions for v5 breaking changes

Jonny Burgerbadc6b9843da
diff --git a/packages/core/src/test/series.test.tsx b/packages/core/src/test/series.test.tsx
index d24bdc94a8..18ca438358 100644
--- a/packages/core/src/test/series.test.tsx
+++ b/packages/core/src/test/series.test.tsx
@@ -7,8 +7,12 @@ import {Internals} from '../internals.js';
import {Series} from '../series/index.js';
import {TimelineContext} from '../TimelineContext.js';
import {useCurrentFrame} from '../use-current-frame.js';
+import {ENABLE_V5_BREAKING_CHANGES} from '../v5-flag.js';
import {WrapSequenceContext} from './wrap-sequence-context.js';
+const ABS_FILL =
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex">';
+
const First = () => {
const frame = useCurrentFrame();
return <div>{'first ' + frame}</div>;
@@ -73,7 +77,9 @@ test('Basic series test', () => {
</WrapSequenceContext>,
);
expect(outerHTML).toBe(
- '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>',
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}${ABS_FILL}<div>third 0</div></div></div>`
+ : `${ABS_FILL}<div>third 0</div></div>`,
);
});
@@ -103,7 +109,9 @@ test('Should support fragments', () => {
);
expect(outerHtml).not.toBe(
- '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>',
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}${ABS_FILL}<div>second 1</div></div></div>`
+ : `${ABS_FILL}<div>second 1</div></div>`,
);
});
test('Should not allow foreign elements', () => {
@@ -130,7 +138,9 @@ test('Should allow layout prop', () => {
</WrapSequenceContext>,
);
expect(outerHTML).toBe(
- '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>first 0</div></div>',
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}${ABS_FILL}<div>first 0</div></div></div>`
+ : `${ABS_FILL}<div>first 0</div></div>`,
);
const outerHTML2 = renderForFrame(
@@ -143,7 +153,11 @@ test('Should allow layout prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML2).toBe('<div>first 0</div>');
+ expect(outerHTML2).toBe(
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}<div>first 0</div></div>`
+ : '<div>first 0</div>',
+ );
});
test('Should render nothing after the end', () => {
const outerHTML = renderForFrame(
@@ -156,7 +170,9 @@ test('Should render nothing after the end', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe('');
+ expect(outerHTML).toBe(
+ ENABLE_V5_BREAKING_CHANGES ? `${ABS_FILL}</div>` : '',
+ );
});
test('Should throw if invalid or no duration provided', () => {
expect(() => {
@@ -202,7 +218,9 @@ test('Should allow whitespace', () => {
);
expect(outerHtml).toBe(
- '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>',
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}${ABS_FILL}<div>second 1</div></div></div>`
+ : `${ABS_FILL}<div>second 1</div></div>`,
);
});
test('Handle empty Series.Sequence', () => {
@@ -235,7 +253,11 @@ test('Should allow negative overlap prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe('<div>first 4</div><div>second 0</div>');
+ expect(outerHTML).toBe(
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}<div>first 4</div><div>second 0</div></div>`
+ : '<div>first 4</div><div>second 0</div>',
+ );
});
test('Should allow positive overlap prop', () => {
@@ -252,7 +274,9 @@ test('Should allow positive overlap prop', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe('');
+ expect(outerHTML).toBe(
+ ENABLE_V5_BREAKING_CHANGES ? `${ABS_FILL}</div>` : '',
+ );
});
test('Should disallow NaN as offset prop', () => {
@@ -317,7 +341,11 @@ test('Should cascade negative offset props', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe('<div>third 0</div>');
+ expect(outerHTML).toBe(
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}<div>third 0</div></div>`
+ : '<div>third 0</div>',
+ );
});
test('Should cascade positive offset props', () => {
@@ -337,7 +365,11 @@ test('Should cascade positive offset props', () => {
</Series>
</WrapSequenceContext>,
);
- expect(outerHTML).toBe('<div>third 0</div>');
+ expect(outerHTML).toBe(
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}<div>third 0</div></div>`
+ : '<div>third 0</div>',
+ );
});
test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
@@ -358,7 +390,9 @@ test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
</WrapSequenceContext>,
);
expect(outerHTML).toBe(
- '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>',
+ ENABLE_V5_BREAKING_CHANGES
+ ? `${ABS_FILL}${ABS_FILL}<div>third 0</div></div></div>`
+ : `${ABS_FILL}<div>third 0</div></div>`,
);
});