🎥 Make videos programmatically with React
move core to bun test
Jonny Burger487f23d83a37
diff --git a/packages/core/bunfig.toml b/packages/core/bunfig.tomlindex 6a56256c26..d20eff30d4 100644--- a/packages/core/bunfig.toml+++ b/packages/core/bunfig.toml@@ -1,2 +1,2 @@[test]-#preload = "./happydom.ts"+preload = "./happydom.ts"diff --git a/packages/core/src/test/absolute-src.test.ts b/packages/core/src/test/absolute-src.test.tsindex 6790a5059d..8fdc0ea433 100644--- a/packages/core/src/test/absolute-src.test.ts+++ b/packages/core/src/test/absolute-src.test.ts@@ -1,6 +1,3 @@-/**- * @vitest-environment jsdom- */import {describe, expect, test} from 'vitest';import {getAbsoluteSrc} from '../absolute-src.js';diff --git a/packages/core/src/test/expect-to-throw.ts b/packages/core/src/test/expect-to-throw.tsindex c2a5003c13..3d7e0e012a 100644--- a/packages/core/src/test/expect-to-throw.ts+++ b/packages/core/src/test/expect-to-throw.ts@@ -1,9 +1,9 @@-import {expect, vitest} from 'vitest';+import {expect, spyOn} from 'bun:test';export const expectToThrow = (func: Function, err: RegExp) => {// Even though the error is caught, it still gets printed to the console// so we mock that out to avoid the wall of red text.- vitest.spyOn(console, 'error');+ spyOn(console, 'error');// @ts-expect-error// eslint-disable-next-line no-consoleconsole.error.mockImplementation(() => undefined);diff --git a/packages/core/src/test/input-props.test.ts b/packages/core/src/test/input-props.test.tsindex bf1b29840e..408692c627 100644--- a/packages/core/src/test/input-props.test.ts+++ b/packages/core/src/test/input-props.test.ts@@ -1,14 +1,13 @@/*** @vitest-environment jsdom*/-import {afterAll, beforeEach, describe, expect, test, vitest} from 'vitest';+import {afterAll, beforeEach, describe, expect, test} from 'bun:test';import {getInputProps} from '../config/input-props.js';describe('input props', () => {const OLD_ENV = process.env;beforeEach(() => {- vitest.resetModules(); // Most important - it clears the cacheprocess.env = {...OLD_ENV}; // Make a copy});diff --git a/packages/core/src/test/static-file-safe-uri.test.ts b/packages/core/src/test/static-file-safe-uri.test.tsindex f0833bfc5f..2c4eb401c7 100644--- a/packages/core/src/test/static-file-safe-uri.test.ts+++ b/packages/core/src/test/static-file-safe-uri.test.ts@@ -3,30 +3,34 @@ import {staticFile} from '../static-file.js';test('staticFile() should convert # into %23', () => {const unsafeName = 'test/example#music';- expect(staticFile(unsafeName)).toBe('/test/example%23music');+ expect(staticFile(unsafeName)).toBe('/static-abcdef/test/example%23music');});test('staticFile() passing already encoded path should give warning', () => {const unsafeName = '/test%2Fexample%23music';- expect(staticFile(unsafeName)).toBe('/test%252Fexample%2523music');+ expect(staticFile(unsafeName)).toBe(+ '/static-abcdef/test%252Fexample%2523music',+ );});test('staticFile() should not encode slashes', () => {const nameWithSlashes = '/test/example/word';- expect(staticFile(nameWithSlashes)).toBe(nameWithSlashes);+ expect(staticFile(nameWithSlashes)).toBe(`/static-abcdef${nameWithSlashes}`);});test('staticFile() should encode all problematic characters except slashes', () => {const nameWithSlashes = '/test/#example/$word';- expect(staticFile(nameWithSlashes)).toBe('/test/%23example/%24word');+ expect(staticFile(nameWithSlashes)).toBe(+ '/static-abcdef/test/%23example/%24word',+ );});test('if no leading slash exists, one should be added', () => {const nameWithSlashes = 'test/example';- expect(staticFile(nameWithSlashes)).toBe('/test/example');+ expect(staticFile(nameWithSlashes)).toBe('/static-abcdef/test/example');});test('problematic character at the beginning should be encoded correctly', () => {const problematicStart = '#test/example';- expect(staticFile(problematicStart)).toBe('/%23test/example');+ expect(staticFile(problematicStart)).toBe('/static-abcdef/%23test/example');});diff --git a/packages/core/src/test/use-media-in-timeline.test.tsx b/packages/core/src/test/use-media-in-timeline.test.tsxindex 79a0ea53a6..fd8d623550 100644--- a/packages/core/src/test/use-media-in-timeline.test.tsx+++ b/packages/core/src/test/use-media-in-timeline.test.tsx@@ -1,10 +1,7 @@-/**- * @vitest-environment jsdom- */import {renderHook} from '@testing-library/react';+import {afterAll, beforeAll, expect, mock, spyOn, test} from 'bun:test';import type {RefObject} from 'react';import React, {useMemo} from 'react';-import {afterAll, beforeAll, expect, test, vitest} from 'vitest';import {ResolveCompositionConfig} from '../ResolveCompositionConfig.js';import type {SequenceManagerContext} from '../SequenceManager.js';import {SequenceManager} from '../SequenceManager.js';@@ -13,26 +10,24 @@ import * as useVideoConfigModule from '../use-video-config.js';import {WrapSequenceContext} from './wrap-sequence-context.js';beforeAll(() => {- vitest- .spyOn(useVideoConfigModule, 'useVideoConfig')- .mockImplementation(() => ({- width: 10,- height: 10,- fps: 30,- durationInFrames: 100,- id: 'hithere',- defaultProps: {},- props: {},- defaultCodec: null,- }));+ spyOn(useVideoConfigModule, 'useVideoConfig').mockImplementation(() => ({+ width: 10,+ height: 10,+ fps: 30,+ durationInFrames: 100,+ id: 'hithere',+ defaultProps: {},+ props: {},+ defaultCodec: null,+ }));});afterAll(() => {- vitest.spyOn(useVideoConfigModule, 'useVideoConfig').mockClear();+ spyOn(useVideoConfigModule, 'useVideoConfig').mockClear();});test('useMediaInTimeline registers and unregisters new sequence', () => {- const registerSequence = vitest.fn();- const unregisterSequence = vitest.fn();+ const registerSequence = mock();+ const unregisterSequence = mock();const wrapper: React.FC<{children: React.ReactNode;}> = ({children}) => {