Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
charlieforward9 committed Jan 3, 2025
1 parent 9f50ad6 commit 0fb3b1e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion src/mocks/amplifyconfiguration_mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"aws_appsync_graphqlEndpoint": "https://mock.appsync-api.us-east-2.amazonaws.com/graphql",
"aws_appsync_region": "us-east-2",
"aws_appsync_authenticationType": "AWS_LAMBDA",
"aws_cognito_identity_pool_id": "us-east-2:mock", //This needs to be set to a real id, see README
"aws_cognito_identity_pool_id": "us-east-2:mock",
"aws_cognito_region": "us-east-2",
"aws_user_pools_id": "us-east-2_mock",
"aws_user_pools_web_client_id": "mock",
Expand Down
25 changes: 23 additions & 2 deletions src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { http, graphql, HttpResponse } from "msw";
import { http, HttpResponse } from "msw";

export const handlers = [
http.post("https://cognito-identity.us-east-2.amazonaws.com/", () => {
Expand All @@ -12,7 +12,28 @@ export const handlers = [
IdentityId: "us-east-2:mock",
});
}),

http.options(
`https://mock-staging.s3.us-east-2.amazonaws.com/path/to/file.json`,
() => {
return new Response(null, {
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,POST,DELETE",
"Access-Control-Allow-Headers": "*",
"Access-Control-Expose-Headers":
"x-amz-server-side-encryption, x-amz-request-id, x-amz-id-2, ETag",
"Access-Control-Max-Age": "3000",
"Content-Length": "0",
Date: "Fri, 03 Jan 2025 03:30:11 GMT",
Server: "AmazonS3",
Vary: "Origin, Access-Control-Request-Headers, Access-Control-Request-Method",
"x-amz-id-2": "mock",
"x-amz-request-id": "mock",
},
});
}
),
http.get(
`https://mock-staging.s3.us-east-2.amazonaws.com/path/to/file.json`,
() => {
Expand Down
4 changes: 2 additions & 2 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Amplify } from "aws-amplify";
import { worker } from "./src/mocks/worker.js";
import amplifyconfig from "./src/mocks/amplifyconfiguration_mock.json";
beforeAll(() => {
beforeAll(async () => {
Amplify.configure(amplifyconfig);
worker.start();
await worker.start();
});

afterEach(() => {
Expand Down

0 comments on commit 0fb3b1e

Please sign in to comment.