/*
 * © 2026 TiedUp! Remake Contributors, distributed under GPLv3.
 */

package com.tiedup.remake.rig.bridge;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

class GlbJointAliasTableTest {

	@Test
	void mapLegacyPlayerAnimatorNames() {
		assertEquals("Chest", GlbJointAliasTable.mapGltfJointName("body"));
		assertEquals("Chest", GlbJointAliasTable.mapGltfJointName("torso"));
		assertEquals("Head", GlbJointAliasTable.mapGltfJointName("head"));
		assertEquals("Arm_L", GlbJointAliasTable.mapGltfJointName("leftUpperArm"));
		assertEquals("Arm_L", GlbJointAliasTable.mapGltfJointName("leftArm"));
		assertEquals("Elbow_L", GlbJointAliasTable.mapGltfJointName("leftLowerArm"));
		assertEquals("Elbow_L", GlbJointAliasTable.mapGltfJointName("leftForearm"));
		assertEquals("Arm_R", GlbJointAliasTable.mapGltfJointName("rightUpperArm"));
		assertEquals("Elbow_R", GlbJointAliasTable.mapGltfJointName("rightLowerArm"));
		assertEquals("Thigh_L", GlbJointAliasTable.mapGltfJointName("leftUpperLeg"));
		assertEquals("Knee_L", GlbJointAliasTable.mapGltfJointName("leftLowerLeg"));
		assertEquals("Thigh_R", GlbJointAliasTable.mapGltfJointName("rightUpperLeg"));
		assertEquals("Knee_R", GlbJointAliasTable.mapGltfJointName("rightLowerLeg"));
	}

	@Test
	void isCaseInsensitive() {
		assertEquals("Chest", GlbJointAliasTable.mapGltfJointName("BODY"));
		assertEquals("Arm_L", GlbJointAliasTable.mapGltfJointName("LeftUpperArm"));
		assertEquals("Arm_L", GlbJointAliasTable.mapGltfJointName("leftupperarm"));
	}

	@Test
	void bypassBipedNames() {
		assertEquals("Arm_L", GlbJointAliasTable.mapGltfJointName("Arm_L"));
		assertEquals("Elbow_R", GlbJointAliasTable.mapGltfJointName("Elbow_R"));
		assertEquals("Head", GlbJointAliasTable.mapGltfJointName("Head"));
		assertEquals("Chest", GlbJointAliasTable.mapGltfJointName("Chest"));
		assertEquals("Torso", GlbJointAliasTable.mapGltfJointName("Torso"));
		assertEquals("Root", GlbJointAliasTable.mapGltfJointName("Root"));
	}

	@Test
	void unknownReturnsNull() {
		assertNull(GlbJointAliasTable.mapGltfJointName("UnknownJoint"));
		assertNull(GlbJointAliasTable.mapGltfJointName(""));
		assertNull(GlbJointAliasTable.mapGltfJointName(null));
	}

	@Test
	void isBipedJointNameDetection() {
		assertTrue(GlbJointAliasTable.isBipedJointName("Arm_L"));
		assertTrue(GlbJointAliasTable.isBipedJointName("Thigh_R"));
		assertTrue(GlbJointAliasTable.isBipedJointName("Root"));
		assertTrue(GlbJointAliasTable.isBipedJointName("Torso"));
		assertTrue(GlbJointAliasTable.isBipedJointName("Head"));
		// False cases
		assertEquals(false, GlbJointAliasTable.isBipedJointName("leftUpperArm"));
		assertEquals(false, GlbJointAliasTable.isBipedJointName("body"));
	}
}
