|
| 1 | +import { describe, expect, test } from "vitest"; |
| 2 | +import slugify from "."; |
| 3 | + |
| 4 | +describe("slugify", () => { |
| 5 | + test("문자열을 slug 형태로 변환한다.", () => { |
| 6 | + const input = " Hello World! This is a Test. "; |
| 7 | + const output = slugify(input); |
| 8 | + expect(output).toBe("hello-world-this-is-a-test"); |
| 9 | + }); |
| 10 | + |
| 11 | + test("특수 문자가 포함된 문자열을 올바르게 변환한다.", () => { |
| 12 | + const input = "Café & Restaurant @ Downtown #1"; |
| 13 | + const output = slugify(input); |
| 14 | + expect(output).toBe("caf-restaurant-downtown-1"); |
| 15 | + }); |
| 16 | + |
| 17 | + test("여러 공백과 대시가 포함된 문자열을 올바르게 변환한다.", () => { |
| 18 | + const input = "This is---a test---string"; |
| 19 | + const output = slugify(input); |
| 20 | + expect(output).toBe("this-is-a-test-string"); |
| 21 | + }); |
| 22 | + |
| 23 | + test("빈 문자열을 처리한다.", () => { |
| 24 | + expect(slugify("")).toBe(""); |
| 25 | + expect(slugify(" ")).toBe(""); |
| 26 | + }); |
| 27 | + |
| 28 | + test("숫자가 포함된 문자열을 올바르게 변환한다.", () => { |
| 29 | + const input = "Product 123 - Version 2.0"; |
| 30 | + const output = slugify(input); |
| 31 | + expect(output).toBe("product-123-version-20"); |
| 32 | + }); |
| 33 | + |
| 34 | + test("특수 문자만 있는 경우를 처리한다.", () => { |
| 35 | + const input = "!@#$%^&*()"; |
| 36 | + const output = slugify(input); |
| 37 | + expect(output).toBe(""); |
| 38 | + }); |
| 39 | + |
| 40 | + test("한글이 포함된 문자열을 처리한다.", () => { |
| 41 | + expect(slugify("안녕하세요")).toBe("안녕하세요"); |
| 42 | + expect(slugify("한글 테스트")).toBe("한글-테스트"); |
| 43 | + expect(slugify("안녕하세요 Hello World")).toBe("안녕하세요-hello-world"); |
| 44 | + expect(slugify("프로젝트 개발")).toBe("프로젝트-개발"); |
| 45 | + }); |
| 46 | +}); |
0 commit comments