summaryrefslogtreecommitdiff
path: root/client/src/mocks
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/mocks')
-rw-r--r--client/src/mocks/handlers.ts57
-rw-r--r--client/src/mocks/server.ts4
-rw-r--r--client/src/mocks/worker.ts (renamed from client/src/mocks/browser.ts)0
3 files changed, 40 insertions, 21 deletions
diff --git a/client/src/mocks/handlers.ts b/client/src/mocks/handlers.ts
index 0e882ee..153a70c 100644
--- a/client/src/mocks/handlers.ts
+++ b/client/src/mocks/handlers.ts
@@ -3,28 +3,43 @@ import { nanoid } from '@reduxjs/toolkit';
const token = nanoid();
+export const initialGuest = {
+ guest: {
+ id: 1,
+ firstName: 'Michael',
+ lastName: 'Hunteman',
+ attendance: 'decline',
+ email: '',
+ message: '',
+ partySize: 1,
+ },
+ token: token,
+};
+
+export const updatedGuest = {
+ id: 1,
+ firstName: 'Michael',
+ lastName: 'Hunteman',
+ attendance: 'accept',
+ email: 'mhunteman@cox.net',
+ message: '',
+ partySize: 1,
+ partyList: [],
+};
+
+export const guests = {
+ guests: [initialGuest],
+ token: token,
+};
+
export const handlers = [
- http.post('/guests/login', () => {
- return HttpResponse.json({
- guest: {
- id: 1,
- firstName: 'Michael',
- lastName: 'Hunteman',
- attendance: 'false',
- email: '',
- message: '',
- },
- token,
- });
+ http.post(`${import.meta.env.VITE_BASE_URL}guests/login`, () => {
+ return HttpResponse.json(initialGuest);
+ }),
+ http.put(`${import.meta.env.VITE_BASE_URL}guests/1`, () => {
+ return HttpResponse.json(updatedGuest);
}),
- http.patch('/guests/1', () => {
- return HttpResponse.json({
- id: 1,
- firstName: 'Michael',
- lastName: 'Hunteman',
- attendance: 'true',
- email: '',
- message: '',
- });
+ http.post(`${import.meta.env.VITE_BASE_URL}admin/login`, () => {
+ return HttpResponse.json(guests);
}),
];
diff --git a/client/src/mocks/server.ts b/client/src/mocks/server.ts
new file mode 100644
index 0000000..e52fee0
--- /dev/null
+++ b/client/src/mocks/server.ts
@@ -0,0 +1,4 @@
+import { setupServer } from 'msw/node';
+import { handlers } from './handlers';
+
+export const server = setupServer(...handlers);
diff --git a/client/src/mocks/browser.ts b/client/src/mocks/worker.ts
index 0a56427..0a56427 100644
--- a/client/src/mocks/browser.ts
+++ b/client/src/mocks/worker.ts