import { describe, expect, test } from "bun:test";
import parseCommandArgs, { parseCheerArgs } from "lib/parseCommandArgs";

describe("command argument parser", () => {
	test("split command into chunks", () => {
		expect(parseCommandArgs("!execute eponirewq")).toEqual(["eponirewq"]);
		expect(parseCommandArgs("!getloot")).toEqual([]);
		expect(parseCommandArgs("!inv qwerinope")).toEqual(["qwerinope"]);
		expect(parseCommandArgs("!admingive qwerinope silverbullet 67")).toEqual([
			"qwerinope",
			"silverbullet",
			"67",
		]);
	});

	test("handle the !use command", () => {
		expect(parseCommandArgs("!use silverbullet albeees")).toEqual(["albeees"]);
		expect(parseCommandArgs("!use grenade")).toEqual([]);
	});

	test("handle special aliases", () => {
		expect(parseCommandArgs("i blast mrockstar20", "i")).toEqual([
			"mrockstar20",
		]);
		expect(parseCommandArgs("blastin sefi", "blastin")).toEqual(["sefi"]);
		expect(parseCommandArgs("i grenade", "i")).toEqual([]);
	});
});

describe("cheer argument parser", () => {
	test("basic parsing", () => {
		expect(parseCheerArgs("cheer99")).toEqual([]);
		expect(parseCheerArgs("grenade out! cheer99")).toEqual(["grenade", "out!"]);
		expect(parseCheerArgs("cheer666 albeees")).toEqual(["albeees"]);
		expect(parseCheerArgs("albeees cheer666")).toEqual(["albeees"]);
	});

	test("Remove all cheers", () => {
		expect(parseCheerArgs("cheer1 cheer1 cheer1")).toEqual([]);
		expect(parseCheerArgs("TAKE CHEER1 THIS chEEr1 SPAM CheeR6969")).toEqual([
			"take",
			"this",
			"spam",
		]);
	});
});
