Files
healer-man/scripts/runewaker-pipeline/lib/native-alpha-audit-helpers.test.mjs
T
2026-10-06 22:25:34 -04:00

27 lines
1.3 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import {
alphaMaterialMatches,
alphaSemanticRolesMatch,
effectiveAlphaMaterialRole,
preparedAlphaTextureFilename,
} from "./native-alpha-audit-helpers.mjs";
test("prepared texture lookup does not append .png to an image name that already has it", () => {
assert.equal(preparedAlphaTextureFilename("ae07_grass03"), "ae07_grass03.png");
assert.equal(preparedAlphaTextureFilename("ae07_grass03.png"), "ae07_grass03.png");
assert.equal(preparedAlphaTextureFilename("ae07_grass03.PNG"), "ae07_grass03.PNG");
});
test("alpha audit treats source cutout/mask and blend/additive labels as equivalent while checking alpha mode", () => {
assert.equal(alphaSemanticRolesMatch("cutout", "mask"), true);
assert.equal(alphaSemanticRolesMatch("blend", "additive"), true);
assert.equal(alphaMaterialMatches("MASK", "cutout", "MASK", "mask"), true);
assert.equal(alphaMaterialMatches("BLEND", "blend", "BLEND", "additive"), true);
assert.equal(alphaMaterialMatches("BLEND", "blend", "OPAQUE", "additive"), false);
assert.equal(alphaSemanticRolesMatch("opaque", "mask"), false);
assert.equal(effectiveAlphaMaterialRole(undefined, "OPAQUE"), "opaque");
assert.equal(effectiveAlphaMaterialRole(undefined, "BLEND"), "missing");
});