-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.test.js
41 lines (32 loc) · 1007 Bytes
/
user.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'dotenv/config'
import { Client, fql } from 'fauna'
import { addUser } from './users.js'
console.log('Test =>', process.env.FAUNA_SECRET_KEY)
// Initialize the Fauna client
const client = new Client({
secret: process.env.FAUNA_SECRET_KEY
})
let testDb;
beforeAll(async () => {
});
afterAll(async () => {
// Cleanup tasks after all tests are run, if necessary
});
describe('User operations', () => {
it('should create a new user', async () => {
const user = {
email: 'test@example.com',
phone: '1234567890',
address: '123 Test St'
}
const result = await addUser(user, client);
expect(result).toBeDefined();
// verify that the user was created
const userByEmail = await client.query(fql`
User.where(.email == ${user.email}).first()
`)
expect(userByEmail).toBeDefined();
expect(userByEmail.data.email).toEqual(user.email);
});
// Add more tests here
});