task(D-ext): array-rect and array-polar tools for v2
This commit is contained in:
@@ -810,3 +810,53 @@ describe('A3 pilot: select tool', () => {
|
||||
expect(sel?.manifest.tags).toContain('basic');
|
||||
});
|
||||
});
|
||||
|
||||
describe('D-Ext: array-rect tool', () => {
|
||||
it('vervielfaeltigt Selektion rows×cols in EINER Transaktion', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
doc.addElement(makeEl('a1'));
|
||||
let selIds: string[] = ['a1'];
|
||||
const bridge = {
|
||||
getIds: () => selIds,
|
||||
setIds: (ids: string[]) => { selIds = ids; },
|
||||
hitTest: () => null,
|
||||
};
|
||||
const ctx = makeCtx({ doc, selection: bridge, options: { rows: 2, cols: 2, dx: 60, dy: 60 } });
|
||||
const arr = coreModifyPlugin.tools!.find((t) => t.manifest.id === 'array-rect')!;
|
||||
|
||||
arr.handlers.down!(pe(0, 0), ctx);
|
||||
arr.handlers.down!(pe(0, 0), ctx);
|
||||
|
||||
expect(doc.getAllElements().length).toBe(4);
|
||||
expect(doc.undo()).toBe(true);
|
||||
expect(doc.getAllElements().length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('D-Ext: array-polar tool', () => {
|
||||
it('verteilt count Kopien gleichmaessig um das Zentrum', () => {
|
||||
const { ydoc } = createInMemoryDoc();
|
||||
const doc = new CADDocument(ydoc);
|
||||
const elem = makeEl('p1');
|
||||
elem.x = 100;
|
||||
elem.y = 0;
|
||||
doc.addElement(elem);
|
||||
let selIds: string[] = ['p1'];
|
||||
const bridge = {
|
||||
getIds: () => selIds,
|
||||
setIds: (ids: string[]) => { selIds = ids; },
|
||||
hitTest: () => null,
|
||||
};
|
||||
const ctx = makeCtx({ doc, selection: bridge, options: { count: 4 } });
|
||||
const polar = coreModifyPlugin.tools!.find((t) => t.manifest.id === 'array-polar')!;
|
||||
|
||||
polar.handlers.down!(pe(0, 0), ctx);
|
||||
polar.handlers.down!(pe(0, 0), ctx);
|
||||
|
||||
const all = doc.getAllElements();
|
||||
expect(all.length).toBe(4);
|
||||
expect(doc.undo()).toBe(true);
|
||||
expect(doc.getAllElements().length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user