Skip to content

Commit 8b3da11

Browse files
committed
Start transition to bun test
1 parent 5fe79e8 commit 8b3da11

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

__tests__/CoreShader.tsx renamed to __tests__/CoreShader.test.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
import '@testing-library/jest-dom';
1+
// import '@testing-library/jest-dom';
22
import { SimpleShaderCanvas } from '../src/core';
3-
import { setupJestCanvasMock } from 'jest-webgl-canvas-mock';
3+
// import { setupJestCanvasMock } from 'jest-webgl-canvas-mock';
44
import { UniformValue, shaderArgs } from '../src/types';
5+
import { describe, expect, test, beforeAll } from "bun:test";
56

6-
beforeEach(() => {
7-
jest.resetAllMocks();
8-
setupJestCanvasMock();
9-
});
7+
// beforeEach(() => {
8+
// // jest.resetAllMocks();
9+
// // setupJestCanvasMock();
10+
// });
1011

1112
describe('CoreShader', () => {
1213
const args = { /* mock shader args */ };
1314
const canvas = document.createElement('canvas');
1415
canvas.width = 800
1516
canvas.height = 400
1617

17-
it('initializes Shader', () => {
18+
test('initializes Shader', () => {
1819
const shader = new SimpleShaderCanvas(canvas, args)
1920
shader.init()
2021

2122
expect(shader).toBeDefined()
2223
expect(shader.getElapsedTime()).toBeGreaterThan(0);
2324
});
2425

25-
it('runs custom logic', () => {
26+
test('runs custom logic', () => {
2627
const initLogic = (shader: SimpleShaderCanvas) => {
2728
throw new Error("Throw to test custom logic has run")
2829
}
@@ -38,7 +39,7 @@ describe('CoreShader', () => {
3839
expect(() => { shader.init() }).toThrow("Throw to test custom logic has run")
3940
});
4041

41-
it('uniforms are set properly', () => {
42+
test('uniforms are set properly', () => {
4243
const testVertShader = 'attribute vec2 a_position; void main() { gl_Position = vec4(a_position, 0.0, 1.0); }'
4344
const testFragShader = 'precision mediump float; uniform float u_test; void main() { gl_FragColor = vec4(u_test, 0.0, 0.0, 0.0); }'
4445

__tests__/ReactRender.tsx renamed to __tests__/ReactRender.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import '@testing-library/jest-dom';
1+
// import '@testing-library/jest-dom';
22

33
import { render } from '@testing-library/react';
44
import { SimpleShaderCanvas } from '../src/react';
55
// import React from 'react';
6-
import { setupJestCanvasMock } from 'jest-webgl-canvas-mock';
7-
8-
beforeEach(() => {
9-
jest.resetAllMocks();
10-
setupJestCanvasMock();
11-
});
6+
// import { setupJestCanvasMock } from 'jest-webgl-canvas-mock';
7+
import { describe, expect, test, beforeAll } from "bun:test";
8+
// beforeEach(() => {
9+
// jest.resetAllMocks();
10+
// setupJestCanvasMock();
11+
// });
1212

1313
describe('ReactSimpleShaderComponent', () => {
1414
const args = { /* mock shader args */ };
1515

16-
it('renders the canvas and initializes Shader', () => {
16+
test('renders the canvas and initializes Shader', () => {
1717
const screen = render(<SimpleShaderCanvas args={args} />);
1818
const canvas = screen.container.querySelector('canvas')
1919

2020
expect(canvas).toBeInTheDocument();
2121
expect(canvas).toHaveClass('loaded'); // default loadedClass
2222
});
2323

24-
it('applies custom className and loadedClass', () => {
24+
test('applies custom className and loadedClass', () => {
2525
const screen = render(<SimpleShaderCanvas args={args} className="test-class" loadedClass="custom-loaded" />);
2626
const canvas = screen.container.querySelector('canvas')
2727

bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[test]
2+
preload = "./happydom.ts"

happydom.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { GlobalRegistrator } from "@happy-dom/global-registrator";
2+
GlobalRegistrator.register();

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
"type": "git",
1818
"url": "git+https://github.com/svey-xyz/simple-shader-component.git"
1919
},
20-
"bugs": {
21-
"url": "https://github.com/svey-xyz/simple-shader-component/issues"
22-
},
23-
"homepage": "https://github.com/svey-xyz/simple-shader-component#readme",
20+
"bugs": {
21+
"url": "https://github.com/svey-xyz/simple-shader-component/issues"
22+
},
23+
"homepage": "https://github.com/svey-xyz/simple-shader-component#readme",
2424
"files": [
2525
"dist/",
2626
"README.md",
2727
"LICENSE"
2828
],
2929
"devDependencies": {
30+
"@happy-dom/global-registrator": "^15.11.6",
3031
"@testing-library/jest-dom": "^6.6.3",
3132
"@testing-library/react": "^16.0.1",
3233
"@types/jest": "^29.5.14",
@@ -60,5 +61,8 @@
6061
"build": "tsc"
6162
},
6263
"type": "module",
63-
"types": "dist/core/index.d.ts"
64+
"types": "dist/core/index.d.ts",
65+
"dependencies": {
66+
"bun": "^1.1.34"
67+
}
6468
}

0 commit comments

Comments
 (0)