Skip to content

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Arodab committed Oct 9, 2024
1 parent 97ad586 commit 22168d8
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/mahoji/commands/fish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { stringMatches } from '@oldschoolgg/toolkit/util';
import type { CommandRunOptions } from '@oldschoolgg/toolkit/util';
import { ApplicationCommandOptionType } from 'discord.js';

import { WildernessDiary, userhasDiaryTier } from '../../lib/diaries';
import { Time } from 'e';
import { Bank, Monsters } from 'oldschooljs';
import { WildernessDiary, userhasDiaryTier } from '../../lib/diaries';

import type { MUserClass } from '../../lib/MUser';
import Fishing from '../../lib/skilling/skills/fishing';
Expand Down
142 changes: 73 additions & 69 deletions tests/unit/commands/fish.test.ts
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');
});
});

0 comments on commit 22168d8

Please sign in to comment.