Skip to content

Commit

Permalink
test: test encoding (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
Seven Du committed Jan 25, 2024
1 parent 98b828f commit 23160e1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/encoding_test.dart
Original file line number Diff line number Diff line change
@@ -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);
}
});
}

1 comment on commit 23160e1

@vercel
Copy link

@vercel vercel bot commented on 23160e1 Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.