Skip to content

Commit

Permalink
Add an unicity test for features. (#824)
Browse files Browse the repository at this point in the history
And remove one duplicate
  • Loading branch information
rom1504 authored Jan 6, 2024
1 parent 00fc3e3 commit 587a134
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 0 additions & 8 deletions data/pc/common/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,6 @@
"description": "dimension is an nbt compound",
"versions": ["1.16.2", "latest"]
},
{
"name": "dimensionDataIsAvailable",
"description": "dimensionData is available, describing additional dimension information",
"versions": [
"1.17",
"latest"
]
},
{
"name": "doesntHaveChestType",
"description": "chests don't have a type property",
Expand Down
17 changes: 17 additions & 0 deletions tools/js/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,21 @@ minecraftTypes.forEach(function (type) {
})
})
})
describe('features.json quality is good', function () {
it('there is no duplicate feature in features.json', () => {
const features = require('../../../data/' + type + '/common/features.json')
const countPerFeature = {}
for (const feature of features) {
countPerFeature[feature.name] = countPerFeature[feature.name] ? countPerFeature[feature.name] + 1 : 1
}
let duplicateCount = 0
for (const [name, count] of Object.entries(countPerFeature)) {
if (count > 1) {
console.log(`feature ${name} is duplicated ${count} times, please remove ${count - 1}`)
duplicateCount += 1
}
}
assert.equal(duplicateCount, 0, `${duplicateCount} duplicates found. Please remove them.`)
})
})
})

0 comments on commit 587a134

Please sign in to comment.