Skip to content

Commit

Permalink
Update test case for durabilityUsed with damage component
Browse files Browse the repository at this point in the history
* Use `fromNotch` method to create the item
* Add `components` array with `damage` component to the item
* Verify `durabilityUsed` returns correct value for items with and without `damage` component
  • Loading branch information
rom1504 committed Jan 11, 2025
1 parent 88cf0d7 commit 973f1a9
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,33 +452,41 @@ describe('durabilityUsed with damage component', () => {
const Item = require('prismarine-item')('1.20.5')

it('should return correct durabilityUsed for item with damage component', () => {
const item = new Item(830, 1, 0, {
type: 'compound',
name: '',
value: {
Damage: {
type: 'int',
value: 0
const item = Item.fromNotch({
itemId: 830,
itemCount: 1,
nbtData: {
type: 'compound',
name: '',
value: {
Damage: {
type: 'int',
value: 0
}
}
}
},
components: [
{
type: 'damage',
data: 15
}
]
})
item.components = [
{
type: 'damage',
data: 15
}
]
expect(item.durabilityUsed).toBe(15)
})

it('should return correct durabilityUsed for item without damage component', () => {
const item = new Item(830, 1, 0, {
type: 'compound',
name: '',
value: {
Damage: {
type: 'int',
value: 10
const item = Item.fromNotch({
itemId: 830,
itemCount: 1,
nbtData: {
type: 'compound',
name: '',
value: {
Damage: {
type: 'int',
value: 10
}
}
}
})
Expand Down

0 comments on commit 973f1a9

Please sign in to comment.