Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createMoveDimensionOverlay, formatMoveDimension } from "@/lib/moveDimensionLines";
|
|
|
|
describe("move dimension lines", () => {
|
|
const project = ({ x, z }: { x: number; y: number; z: number }) => ({ x: 400 + x * 4, y: 300 + z * 4 });
|
|
|
|
it("creates signed X and Z measurements from the common drag origin", () => {
|
|
const overlay = createMoveDimensionOverlay({
|
|
originX: 10,
|
|
originZ: -5,
|
|
planeY: 0,
|
|
deltaX: -14,
|
|
deltaZ: -17,
|
|
accuracy: 2,
|
|
width: 800,
|
|
height: 600,
|
|
project,
|
|
});
|
|
|
|
expect(overlay?.lines.map((line) => [line.axis, line.label])).toEqual([
|
|
["x", "-14.00"],
|
|
["z", "-17.00"],
|
|
]);
|
|
expect(overlay?.lines[0]).toMatchObject({ x1: 452, y1: 280, x2: 384, y2: 280 });
|
|
expect(overlay?.lines[1]).toMatchObject({ x1: 440, y1: 292, x2: 440, y2: 212 });
|
|
expect(overlay?.guides).toEqual([
|
|
{ axis: "x", x1: 384, y1: 280, x2: 384, y2: 212 },
|
|
{ axis: "z", x1: 440, y1: 212, x2: 384, y2: 212 },
|
|
]);
|
|
});
|
|
|
|
it("uses the workspace accuracy and suppresses near-zero movement", () => {
|
|
expect(formatMoveDimension(-0.0001, 2)).toBe("0.00");
|
|
expect(createMoveDimensionOverlay({
|
|
originX: 0,
|
|
originZ: 0,
|
|
planeY: 0,
|
|
deltaX: 0.004,
|
|
deltaZ: -0.004,
|
|
accuracy: 2,
|
|
width: 800,
|
|
height: 600,
|
|
project,
|
|
})).toBeNull();
|
|
});
|
|
|
|
it("shows only the axis that actually moved", () => {
|
|
const overlay = createMoveDimensionOverlay({
|
|
originX: 0,
|
|
originZ: 0,
|
|
planeY: 0,
|
|
deltaX: 12.5,
|
|
deltaZ: 0,
|
|
accuracy: 1,
|
|
width: 800,
|
|
height: 600,
|
|
project,
|
|
});
|
|
|
|
expect(overlay?.lines).toHaveLength(1);
|
|
expect(overlay?.lines[0]).toMatchObject({ axis: "x", label: "12.5" });
|
|
});
|
|
|
|
it("keeps a single-axis label on a stable side when projection noise changes sign", () => {
|
|
const makeOverlay = (noise: number) => createMoveDimensionOverlay({
|
|
originX: 0,
|
|
originZ: 0,
|
|
planeY: 0,
|
|
deltaX: 12.5,
|
|
deltaZ: 0,
|
|
accuracy: 1,
|
|
width: 800,
|
|
height: 600,
|
|
project: ({ x, z }) => ({
|
|
x: 400 + x * 4,
|
|
y: 300 + z * 4 + (x === 0 && z === 0 ? noise : 0),
|
|
}),
|
|
});
|
|
|
|
const above = makeOverlay(0.001)?.lines[0];
|
|
const below = makeOverlay(-0.001)?.lines[0];
|
|
expect(above?.labelY).toBeGreaterThan(300);
|
|
expect(below?.labelY).toBeGreaterThan(300);
|
|
});
|
|
|
|
});
|