Configure board deployment and backend proxy
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { mapImportedWordLocations } from '../wordcloudImport';
|
||||
import type { ImportedWordLocationResult } from '../wordcloudImport';
|
||||
|
||||
const result: ImportedWordLocationResult = {
|
||||
job_id: 'job-1',
|
||||
query: '',
|
||||
mode: 'exact',
|
||||
total: 2,
|
||||
canvas_width: 1000,
|
||||
canvas_height: 2000,
|
||||
matches: [
|
||||
{
|
||||
id: 1,
|
||||
name: '王小明',
|
||||
x: 100,
|
||||
y: 200,
|
||||
font_size: 100,
|
||||
color: '#000000',
|
||||
orientation: 'horizontal',
|
||||
box_x: 100,
|
||||
box_y: 200,
|
||||
box_width: 100,
|
||||
box_height: 50,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '李欣',
|
||||
x: 700,
|
||||
y: 1200,
|
||||
font_size: 25,
|
||||
color: '#000000',
|
||||
orientation: 'vertical',
|
||||
box_x: 700,
|
||||
box_y: 1200,
|
||||
box_width: 60,
|
||||
box_height: 200,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe('imported word locations', () => {
|
||||
it('maps database pixels to responsive percentage coordinates', () => {
|
||||
const words = mapImportedWordLocations(result, {
|
||||
jobId: 'job-1',
|
||||
eyebrow: '',
|
||||
title: '',
|
||||
subtitle: '',
|
||||
});
|
||||
|
||||
expect(words).toHaveLength(2);
|
||||
expect(words[0].x).toBeCloseTo(15);
|
||||
expect(words[0].y).toBeCloseTo(11.25);
|
||||
expect(words[0].fontSize).toBe(100);
|
||||
expect(words[0]).toMatchObject({
|
||||
sourceBox: { width: 100, height: 50 },
|
||||
});
|
||||
expect(words[0].tier).toBe(4);
|
||||
expect(words[1].x).toBeCloseTo(73);
|
||||
expect(words[1].y).toBeCloseTo(65);
|
||||
expect(words[1].fontSize).toBe(25);
|
||||
expect(words[1].tier).toBe(1);
|
||||
expect(words[1].rotation).toBe(90);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user