Skip to content

🎥 Make videos programmatically with React

Fix Google Fonts registry test mock

Jonny Burger469b628d739a
diff --git a/packages/google-fonts/test/variable-font.test.ts b/packages/google-fonts/test/variable-font.test.ts
index 94fcbeae19..1e2f87e718 100644
--- a/packages/google-fonts/test/variable-font.test.ts
+++ b/packages/google-fonts/test/variable-font.test.ts
@@ -1,5 +1,7 @@
import {expect, mock, test} from 'bun:test';
+const registeredFontFaces: unknown[] = [];
+
mock.module('remotion', () => ({
continueRender: () => undefined,
delayRender: () => 0,
@@ -7,6 +9,9 @@ mock.module('remotion', () => ({
mock.module('remotion/no-react', () => ({
NoReactInternals: {
ENABLE_V5_BREAKING_CHANGES: false,
+ registerFontFace: (fontFace: unknown) => {
+ registeredFontFaces.push(fontFace);
+ },
},
}));
@@ -80,6 +85,22 @@ test('loads variable font faces from a generated module and font info', async ()
expect(addedFontFaces).toHaveLength(2);
expect(addedFontFaces[0]).toBeInstanceOf(MockFontFace);
expect(addedFontFaces[1]).toBeInstanceOf(MockFontFace);
+ expect(registeredFontFaces).toEqual([
+ expect.objectContaining({
+ fontFamily: 'Noto Sans',
+ format: 'woff2',
+ stretch: '62.5% 100%',
+ style: 'normal',
+ weight: '100 900',
+ }),
+ expect.objectContaining({
+ fontFamily: 'Noto Sans',
+ format: 'woff2',
+ stretch: '62.5% 100%',
+ style: 'italic',
+ weight: '100 900',
+ }),
+ ]);
} finally {
globalThis.FontFace = originalFontFace;
}