Skip to content

Commit f8ee204

Browse files
committed
test: add integration tests for encrypted model functionality
1 parent 7784099 commit f8ee204

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { loadSchema } from '@zenstackhq/testtools';
2+
import path from 'path';
3+
4+
describe('Encrypted test', () => {
5+
let origDir: string;
6+
7+
beforeAll(async () => {
8+
origDir = path.resolve('.');
9+
});
10+
11+
afterEach(async () => {
12+
process.chdir(origDir);
13+
});
14+
15+
it('encrypted tests', async () => {
16+
const { enhance } = await loadSchema(`
17+
model User {
18+
id String @id @default(cuid())
19+
encrypted_value String @encrypted(saltLength: 16)
20+
21+
@@allow('all', true)
22+
}`);
23+
24+
const db = enhance();
25+
const r = await db.user.create({
26+
data: {
27+
id: '1',
28+
encrypted_value: 'abc123',
29+
},
30+
});
31+
32+
expect(r.encrypted_value).toBe('abc123');
33+
});
34+
});

0 commit comments

Comments
 (0)