test(67): cover the remaining 4 bug-preview locations; note the MiddleCenter divergence (#503)
This commit is contained in:
@@ -47,6 +47,38 @@ describe('bugPreviewStyle', () => {
|
||||
expect(style.transform).toBe('translate(-50%, -50%)');
|
||||
});
|
||||
|
||||
it('anchors BottomLeft using the margins', () => {
|
||||
const style = bugPreviewStyle({ ...base, location: 'BottomLeft' });
|
||||
expect(style.bottom).toBe('1%');
|
||||
expect(style.left).toBe('1%');
|
||||
expect(style.top).toBeUndefined();
|
||||
expect(style.right).toBeUndefined();
|
||||
expect(style.transform).toBeUndefined();
|
||||
});
|
||||
|
||||
it('anchors TopRight using the margins', () => {
|
||||
const style = bugPreviewStyle({ ...base, location: 'TopRight' });
|
||||
expect(style.top).toBe('1%');
|
||||
expect(style.right).toBe('1%');
|
||||
expect(style.bottom).toBeUndefined();
|
||||
expect(style.left).toBeUndefined();
|
||||
expect(style.transform).toBeUndefined();
|
||||
});
|
||||
|
||||
it('centers vertically for RightMiddle', () => {
|
||||
const style = bugPreviewStyle({ ...base, location: 'RightMiddle' });
|
||||
expect(style.right).toBe('1%');
|
||||
expect(style.top).toBe('50%');
|
||||
expect(style.transform).toBe('translateY(-50%)');
|
||||
});
|
||||
|
||||
it('centers horizontally for BottomMiddle', () => {
|
||||
const style = bugPreviewStyle({ ...base, location: 'BottomMiddle' });
|
||||
expect(style.bottom).toBe('1%');
|
||||
expect(style.left).toBe('50%');
|
||||
expect(style.transform).toBe('translateX(-50%)');
|
||||
});
|
||||
|
||||
it('scales width by percent when size is Scaled', () => {
|
||||
expect(bugPreviewStyle({ ...base, width: 12 }).width).toBe('12%');
|
||||
});
|
||||
|
||||
@@ -28,6 +28,9 @@ export function bugPreviewStyle(geometry: BugPreviewGeometry): CSSProperties {
|
||||
return { bottom: vertical, right: horizontal };
|
||||
case 'LeftMiddle':
|
||||
return { left: horizontal, top: '50%', transform: 'translateY(-50%)' };
|
||||
// NOTE: FFmpeg currently renders MiddleCenter bottom-right (OverlayWatermarkFilter has no
|
||||
// arm for it, so it hits the bottom-right default) — see #503. We keep the semantically
|
||||
// correct centered preview here rather than encoding that defect.
|
||||
case 'MiddleCenter':
|
||||
return { left: '50%', top: '50%', transform: 'translate(-50%, -50%)' };
|
||||
case 'RightMiddle':
|
||||
|
||||
Reference in New Issue
Block a user