From d7235f80a4fb52db82b75e6d1f9cc13aefb520a4 Mon Sep 17 00:00:00 2001 From: beer-psi Date: Sun, 2 Nov 2025 09:48:37 +0700 Subject: [PATCH] test: add test cases for CJK truncation --- core/share_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/share_test.go b/core/share_test.go index 21069bb59..d85c4c582 100644 --- a/core/share_test.go +++ b/core/share_test.go @@ -38,6 +38,22 @@ var _ = Describe("Share", func() { Expect(id).ToNot(BeEmpty()) Expect(entity.ID).To(Equal(id)) }) + + It("does not truncate CJK labels shorter than 30 runes", func() { + _ = ds.MediaFile(ctx).Put(&model.MediaFile{ID: "456", Title: "青春コンプレックス"}) + entity := &model.Share{Description: "test", ResourceIDs: "456"} + _, err := repo.Save(entity) + Expect(err).ToNot(HaveOccurred()) + Expect(entity.Contents).To(Equal("青春コンプレックス")) + }) + + It("truncates CJK labels longer than 30 runes", func() { + _ = ds.MediaFile(ctx).Put(&model.MediaFile{ID: "789", Title: "私の中の幻想的世界観及びその顕現を想起させたある現実での出来事に関する一考察"}) + entity := &model.Share{Description: "test", ResourceIDs: "789"} + _, err := repo.Save(entity) + Expect(err).ToNot(HaveOccurred()) + Expect(entity.Contents).To(Equal("私の中の幻想的世界観及びその顕現を想起させたある現実...")) + }) }) Describe("Update", func() {