From 23160e1fe7862c7adbe3877633dd7dc9ea80ff0a Mon Sep 17 00:00:00 2001 From: Seven Du Date: Thu, 25 Jan 2024 10:38:37 +0800 Subject: [PATCH] test: test encoding (#240) --- test/encoding_test.dart | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/encoding_test.dart diff --git a/test/encoding_test.dart b/test/encoding_test.dart new file mode 100644 index 00000000..8f01961c --- /dev/null +++ b/test/encoding_test.dart @@ -0,0 +1,46 @@ +import 'package:orm/orm.dart'; +import 'package:test/test.dart'; + +import 'generated/client.dart'; +import 'generated/prisma.dart'; + +void main() { + late PrismaClient client; + + setUpAll(() async { + client = PrismaClient(datasourceUrl: 'file:test/test.db'); + await client.$connect(); + + // Clear database + await client.user.deleteMany(); + }); + + tearDownAll(() async { + await client.$disconnect(); + }); + + test('Encoding', () async { + final chars = [ + "中文", + '😊', + 'にちほん', + '한국어', + 'اَلْعَرَبِيَّةُ', + 'عربي/عربى', + 'خصوصي', + ]; + for (final char in chars) { + final user = await client.user.create( + data: PrismaUnion.$2(UserUncheckedCreateInput(name: char)), + ); + + expect(user.name, char); + + final found = await client.user.findUniqueOrThrow( + where: UserWhereUniqueInput(id: user.id), + select: UserSelect(name: true), + ); + expect(found.name, char); + } + }); +}