Skip to content

Commit

Permalink
test: add integration tests for encrypted model functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
genu committed Dec 20, 2024
1 parent 7784099 commit f8ee204
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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');
});
});

0 comments on commit f8ee204

Please sign in to comment.