Skip to content

Commit

Permalink
normalize to string in pc test
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jul 22, 2024
1 parent b5326f7 commit 0b14160
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ function provider (registry, { Biome, version }) {

function parseValue (value, state) {
if (state.type === 'enum' || state.values) {
return state.values.indexOf(value)
return state.values.indexOf(String(value))
}
if (state.type === 'bool') {
if (value === true || value === 'true') return 0
Expand Down
10 changes: 8 additions & 2 deletions test/fromProperties.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ describe('versions should return block state and properties', () => {
// make sure that .fromProperties works
{
const blockData = registry.blocksByName.light_weighted_pressure_plate
const properties = { pc: { power: 2 }, bedrock: { redstone_signal: 2 } }[e]
const properties = { pc: { power: '2' }, bedrock: { redstone_signal: 2 } }[e]
const block = Block.fromProperties(blockData.name, properties, 0)
assert(block.stateId >= blockData.minStateId && block.stateId <= blockData.maxStateId)
expect(block.getProperties()).toMatchObject(properties)
const propertiesNormalized = block.getProperties();
if (e === 'pc') {
for (const key in propertiesNormalized) {
propertiesNormalized[key] = propertiesNormalized[key].toString();
}
}
expect(propertiesNormalized).toMatchObject(properties)
}

// Make sure type IDs work
Expand Down

0 comments on commit 0b14160

Please sign in to comment.