Files
game-cards-poker-design/frontend/node_modules/fabric/extensions/linear_gradient_controls/linearGradientControls.spec.ts
Poker Design Developer 5dbcebf7a2 Fix frontend blank page issues
- Fix router import path in main.js
- Handle Django REST Framework pagination format in API calls
- Add getTemplates function to project API
- Restart frontend development server
2026-05-31 18:40:56 +08:00

52 lines
1.2 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import { Control, Gradient } from 'fabric';
import { createLinearGradientControls } from './linearGradientControls';
describe('createLinearGradientControls', () => {
test('returns an object as many controls as necessary', () => {
const gradient = new Gradient({
type: 'linear',
// gradientTransform: [1, 0, 0, 2, 50, 40], <-- unsupported yet
coords: {
x1: 20,
x2: 380,
y1: 20,
y2: 230,
},
colorStops: [
{
offset: 0.2,
color: 'red',
},
{
offset: 0.4,
color: 'green',
},
{
offset: 0.6,
color: 'blue',
},
{
offset: 0.8,
color: 'yellow',
},
],
});
const controls = createLinearGradientControls(gradient);
expect(typeof controls).toBe('object');
expect(Object.keys(controls)).toEqual(
expect.arrayContaining([
'lgp_1',
'lgo_0',
'lgo_1',
'lgo_2',
'lgo_3',
'lgp_2',
]),
);
Object.values(controls).forEach((control) => {
expect(control).toBeInstanceOf(Control);
});
});
});