cleanTalk.spec.ts 1001 B

123456789101112131415161718192021222324252627282930313233
  1. import { describe, expect, test } from "@jest/globals";
  2. import { Talk } from "../src/features/chat/messages";
  3. import { cleanTalk } from "../src/utils/cleanTalk";
  4. function makeTalk(message: string): Talk {
  5. return {
  6. style: "talk",
  7. message,
  8. }
  9. }
  10. describe("Cleaning Talk Tests", () => {
  11. test("should return same thing", () => {
  12. const t = makeTalk("Hello");
  13. expect(cleanTalk(t).message).toBe("Hello");
  14. });
  15. test("should remove emoji", () => {
  16. const t = makeTalk("Hello 😊 Goodbye");
  17. expect(cleanTalk(t).message).toBe("Hello Goodbye");
  18. });
  19. test("should remove smiley", () => {
  20. const t = makeTalk("Hello :) how are you");
  21. expect(cleanTalk(t).message).toBe("Hello how are you");
  22. });
  23. test("should not remove non smiley", () => {
  24. const t = makeTalk("(WOOD)");
  25. expect(cleanTalk(t).message).toBe("(WOOD)");
  26. });
  27. test("should remove smiley start of sentence", () => {
  28. const t = makeTalk(":D");
  29. expect(cleanTalk(t).message).toBe("");
  30. });
  31. });