forked from oldschoolgg/oldschoolbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,96 @@ | ||
import { Bank } from 'oldschooljs'; | ||
import { describe, it } from 'vitest'; | ||
import { Bank, EItem } from 'oldschooljs'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { Gear } from '../../../src/lib/structures/Gear'; | ||
import { fishCommand } from '../../../src/mahoji/commands/fish'; | ||
import { testRunCmd } from '../utils'; | ||
import { createTestUser, mockClient } from '../util'; | ||
|
||
describe('Fish Command', () => { | ||
it('should handle insufficient fishing level', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Trout/Salmon', quantity: 1 }, | ||
result: '<:minion:778418736180494347> Your minion needs 20 Fishing to fish Trout/Salmon.' | ||
}); | ||
describe('Fish Command', async () => { | ||
const client = await mockClient(); | ||
|
||
it('should handle insufficient fishing level', async () => { | ||
const user = await createTestUser(); | ||
const res = await user.runCommand(fishCommand, { name: 'trout', quantity: 1 }); | ||
expect(res).toEqual('<:minion:778418736180494347> Your minion needs 20 Fishing to fish Trout.'); | ||
}); | ||
|
||
it('should handle insufficient QP', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'karambwanji', quantity: 1 }, | ||
user: { skills_fishing: 9_999_999, QP: 0 }, | ||
result: 'You need 15 qp to catch those!' | ||
it('should handle insufficient QP', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ | ||
skills_fishing: 9_999_999, | ||
QP: 0 | ||
}); | ||
const res = await user.runCommand(fishCommand, { name: 'karambwanji', quantity: 1 }); | ||
expect(res).toEqual('You need 15 qp to catch those!'); | ||
}); | ||
|
||
it('should handle invalid fish', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'asdf' }, | ||
result: 'Thats not a valid fish to catch.' | ||
}); | ||
it('should handle invalid fish', async () => { | ||
const user = await createTestUser(); | ||
const res = await user.runCommand(fishCommand, { name: 'asdf' }); | ||
expect(res).toEqual('Thats not a valid fish to catch.'); | ||
}); | ||
|
||
it('should handle insufficient barb fishing levels', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Barbarian fishing' }, | ||
user: { skills_fishing: 1 }, | ||
result: '<:minion:778418736180494347> Your minion needs 48 Fishing to fish Barbarian fishing.' | ||
}); | ||
it('should handle insufficient barb fishing levels', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ skills_fishing: 1 }); | ||
const res = await user.runCommand(fishCommand, { name: 'Barbarian fishing' }); | ||
expect(res).toEqual('<:minion:778418736180494347> Your minion needs 48 Fishing to fish Barbarian fishing.'); | ||
}); | ||
|
||
it('should fish', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Shrimps/Anchovies' }, | ||
result: "<:minion:778418736180494347> Your minion is now fishing Shrimps/Anchovies, it'll take 30 minutes, 1 second to finish." | ||
}); | ||
it('should fish', async () => { | ||
const user = await createTestUser(); | ||
const res = await user.runCommand(fishCommand, { name: 'shrimps' }); | ||
expect(res).toContain('is now fishing Shrimps/Anchovies'); | ||
}); | ||
|
||
it('should catch insufficient feathers', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Barbarian fishing' }, | ||
user: { | ||
skills_fishing: 999_999, | ||
skills_agility: 999_999, | ||
skills_strength: 999_999, | ||
meleeGear: new Gear({ weapon: 'Pearl barbarian rod' }) | ||
}, | ||
result: 'You need Feather to fish Barbarian fishing!' | ||
it('should catch insufficient feathers', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ | ||
bank: new Bank().add('Feather', 0), | ||
skills_fishing: 999_999, | ||
skills_agility: 999_999, | ||
skills_strength: 999_999 | ||
}); | ||
await user.equip('skilling', [EItem.PEARL_BARBARIAN_ROD]); | ||
const res = await user.runCommand(fishCommand, { name: 'Barbarian fishing' }); | ||
expect(res).toEqual('You need Feather to fish Barbarian fishing!'); | ||
}); | ||
|
||
it('should boost', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Barbarian fishing' }, | ||
user: { | ||
skills_fishing: 999_999, | ||
skills_agility: 999_999, | ||
skills_strength: 999_999, | ||
bank: new Bank().add('Feather', 1000) | ||
}, | ||
result: `<:minion:778418736180494347> Your minion is now fishing Barbarian fishing, it'll take 30 minutes, 3 seconds to finish.` | ||
it('should boost', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ | ||
bank: new Bank().add('Feather', 100), | ||
skills_fishing: 999_999, | ||
skills_agility: 999_999, | ||
skills_strength: 999_999 | ||
}); | ||
const res = await user.runCommand(fishCommand, { name: 'Barbarian fishing' }); | ||
expect(res).toContain('is now fishing Barbarian fishing'); | ||
}); | ||
|
||
it('should fish barrel boost', () => { | ||
testRunCmd({ | ||
cmd: fishCommand, | ||
opts: { name: 'Shrimps/Anchovies' }, | ||
user: { | ||
skills_fishing: 999_999, | ||
meleeGear: new Gear({ cape: 'Fish sack barrel' }) | ||
}, | ||
result: `<:minion:778418736180494347> Your minion is now fishing Shrimps/Anchovies, it'll take 48 minutes, 1 second to finish. | ||
it('should fish barrel boost', async () => { | ||
const user = await client.mockUser({ maxed: true }); | ||
await user.equip('skilling', [EItem.FISH_SACK_BARREL_CLOSED]); | ||
const res = await user.runCommand(fishCommand, { name: 'shrimps' }); | ||
expect(res).toContain('+9 trip minutes and +28 inventory slots for having'); | ||
}); | ||
|
||
**Boosts:** +9 trip minutes and +28 inventory slots for having a Fish sack barrel.` | ||
}); | ||
it('should handle using flakes without flakes in bank', async () => { | ||
const user = await createTestUser(); | ||
const res = await user.runCommand(fishCommand, { name: 'shrimps', flakes: true }); | ||
expect(res).toEqual('You need to have at least one spirit flake!'); | ||
}); | ||
|
||
it('should fish with flakes', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ bank: new Bank({ 'Spirit flakes': 100 }) }); | ||
const res = await user.runCommand(fishCommand, { name: 'shrimps', flakes: true }); | ||
expect(res).toContain('50% more fish from using spirit flakes'); | ||
}); | ||
|
||
it('should still use flakes if bank contains fewer flakes than fish quantity', async () => { | ||
const user = await createTestUser(); | ||
await user.update({ bank: new Bank({ 'Spirit flakes': 100 }) }); | ||
const res = await user.runCommand(fishCommand, { name: 'shrimps', flakes: true }); | ||
expect(res).toContain('50% more fish from using spirit flakes'); | ||
}); | ||
}); |