import test from 'node:test';import assert from 'node:assert/strict'; import {nativeToolCatalogue,nativeToolDefinition} from '../../tools/generate-native-tools.mjs'; import {toolTemplate} from '../control-panel/public/tool-template-policy.mjs'; import {defaultItemDesign} from '../control-panel/public/item-design-model.mjs'; test('native tool export uses the actual server version and never substitutes copper materials',()=>{ const old=nativeToolCatalogue({minecraftVersion:'1.21.8'}),modern=nativeToolCatalogue({minecraftVersion:'1.21.9'}); assert.equal(old.unavailable.length,10);assert.equal(modern.unavailable.length,0);assert.equal(old.definitions.length+old.unavailable.length,modern.definitions.length); assert(old.definitions.every(d=>!d.config.material.startsWith('COPPER_'))); assert.throws(()=>nativeToolDefinition(toolTemplate('shovel',5),{minecraftVersion:'1.21.8'}),/Copper tools/); assert.equal(modern.definitions.find(d=>d.id==='dr_s1_spice_shovel_mk5').config.material,'COPPER_SHOVEL'); }); test('the native item engine receives the same validated name, lore and enchantment choices as the web design',()=>{ const design=defaultItemDesign('dr_s1_spice_shovel_mk14');design.name='Desert Artisan';design.enchantments.efficiency=6;design.lore=[{text:'Made for the deep dunes.',color:'#FFAA00',bold:false,italic:true}]; const native=nativeToolDefinition(design);assert.equal(native.config.name,'&6&lDesert Artisan');assert.equal(native.config.enchantments.enchantment1.level,6);assert(native.config.lore.some(line=>line.endsWith('&oMade for the deep dunes.'))); assert.throws(()=>nativeToolDefinition({...design,enchantments:{...design.enchantments,efficiency:255}})); assert.throws(()=>nativeToolDefinition({...design,name:'&kHidden name'})); }); test('every native definition has quality and MK, bounded enchantments and no automatic issuance',()=>{ for(const d of nativeToolCatalogue({minecraftVersion:'1.21.8'}).definitions){assert(d.quality);assert(d.equipmentMark>=1&&d.equipmentMark<=14);assert.equal(d.config.giveFirstJoinFeatures.giveFirstJoin,false);assert.deepEqual(d.config.activators,{});assert.equal(d.config.keepItemOnDeath,false);} const max=nativeToolDefinition(toolTemplate('shovel',14));assert.equal(max.config.material,'NETHERITE_SHOVEL');assert.equal(max.config.enchantments.enchantment1.level,7); const forged=nativeToolDefinition({...toolTemplate('shovel',14),enchantments:{efficiency:255}});assert.equal(forged.config.enchantments.enchantment1.level,7); const tokens=nativeToolCatalogue({minecraftVersion:'1.21.8'}).definitions.filter(d=>d.id.endsWith('_upgrade'));assert.equal(tokens.length,2);assert(tokens.every(t=>t.config.material==='NETHERITE_UPGRADE_SMITHING_TEMPLATE')); });