From f8ee2045c91e9ab555a3f991aaef92d904872fec Mon Sep 17 00:00:00 2001 From: Eugen Istoc Date: Fri, 20 Dec 2024 16:01:15 -0300 Subject: [PATCH] test: add integration tests for encrypted model functionality --- .../with-encrypted/with-encrypted.test.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/integration/tests/enhancements/with-encrypted/with-encrypted.test.ts diff --git a/tests/integration/tests/enhancements/with-encrypted/with-encrypted.test.ts b/tests/integration/tests/enhancements/with-encrypted/with-encrypted.test.ts new file mode 100644 index 000000000..63c80cccc --- /dev/null +++ b/tests/integration/tests/enhancements/with-encrypted/with-encrypted.test.ts @@ -0,0 +1,34 @@ +import { loadSchema } from '@zenstackhq/testtools'; +import path from 'path'; + +describe('Encrypted test', () => { + let origDir: string; + + beforeAll(async () => { + origDir = path.resolve('.'); + }); + + afterEach(async () => { + process.chdir(origDir); + }); + + it('encrypted tests', async () => { + const { enhance } = await loadSchema(` + model User { + id String @id @default(cuid()) + encrypted_value String @encrypted(saltLength: 16) + + @@allow('all', true) + }`); + + const db = enhance(); + const r = await db.user.create({ + data: { + id: '1', + encrypted_value: 'abc123', + }, + }); + + expect(r.encrypted_value).toBe('abc123'); + }); +});