server/laf-cloud/tests/revive-shine.test.mjs
2026-09-01 16:04:15 +08:00

27 lines
1.7 KiB
JavaScript

import assert from "node:assert/strict";
import { access, readFile } from "node:fs/promises";
import test from "node:test";
test("JungleShine is manually attachable and does not load a bundle", async () => {
const [reviveSource, shopSource, componentSource, effectSource, resMetaSource] = await Promise.all([
readFile(new URL("../../../assets/Script/Revive.ts", import.meta.url), "utf8"),
readFile(new URL("../../../assets/shop/script/shop.ts", import.meta.url), "utf8"),
readFile(new URL("../../../assets/res/effect/JungleShine.ts", import.meta.url), "utf8"),
readFile(new URL("../../../assets/res/effect/jungle_shine.effect", import.meta.url), "utf8"),
readFile(new URL("../../../assets/res.meta", import.meta.url), "utf8"),
]);
const resMeta = JSON.parse(resMetaSource);
await assert.rejects(access(new URL("../../../assets/shop/script/ShopJungleShine.ts", import.meta.url)));
await assert.rejects(access(new URL("../../../assets/shop/script/ShopJungleShine.ts.meta", import.meta.url)));
await assert.rejects(access(new URL("../../../assets/shared_shader.meta", import.meta.url)));
assert.doesNotMatch(reviveSource, /ShopJungleShine|shared_shader|loadShineMaterial|RUNTIME_JUNGLE_SHINE/);
assert.doesNotMatch(shopSource, /ShopJungleShine|shared_shader|loadJungleShineMaterial|RUNTIME_JUNGLE_SHINE/);
assert.match(componentSource, /@requireComponent\(cc\.Sprite\)/);
assert.match(componentSource, /@property\(cc\.EffectAsset\)/);
assert.match(componentSource, /material\.effectAsset = this\.effectAsset/);
assert.doesNotMatch(componentSource, /loadBundle|getBundle|cc\.resources|\bimport\b/);
assert.equal(resMeta.isBundle, false);
assert.match(effectSource, /CCProgram shop-jungle-shine-fs/);
});