Skip to content

Commit

Permalink
chore: fix mock handler
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSnow committed Feb 26, 2024
1 parent a30cdb2 commit 5edf041
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"prettier.enable": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "always"
},
"files.associations": {
"*.css": "postcss"
Expand Down
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* tslint:disable */

/**
* Mock Service Worker (2.1.5).
* Mock Service Worker (2.2.1).
* @see https://github.com/mswjs/msw
* - Please do NOT modify this file.
* - Please do NOT serve this file on production.
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// src/mocks/browser.js
import { setupWorker } from 'msw'
import { setupWorker } from 'msw/browser'
import { handlers } from './handlers'

// This configures a Service Worker with the given request handlers.
Expand Down
12 changes: 6 additions & 6 deletions src/mocks/handlers/RequestSignInSubscriber.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { graphql } from 'msw'
import { HttpResponse, graphql } from 'msw'

export const handler = graphql.mutation('RequestSignInSubscriber', (_req, res, ctx) => {
return res(
ctx.data({
export const handler = graphql.mutation('RequestSignInSubscriber', () => {
return HttpResponse.json({
data: {
requestSignInSubscriber: true,
}),
)
},
})
})
30 changes: 14 additions & 16 deletions src/mocks/handlers/SiteInfo.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { graphql } from 'msw'
import { HttpResponse, graphql } from 'msw'

export const handler = graphql.query('SiteSubscriptionInfo', (_req, res, ctx) => {
return res(
ctx.data({
siteSubscriptionInfo: {
name: 'Storipress',
email: 'hello@storipress.com',
subscription: true,
newsletter: true,
monthly_price: '5',
yearly_price: '100',
monthly_price_id: 'price_1LPlC3Rhl9bYbVxV2AO42x0H',
yearly_price_id: 'price_1LPlC4Rhl9bYbVxVYA9I7Z53',
},
}),
)
export const handler = graphql.query('SiteSubscriptionInfo', () => {
return HttpResponse.json({
data: {
name: 'Storipress',
email: 'hello@storipress.com',
subscription: true,
newsletter: true,
monthly_price: '5',
yearly_price: '100',
monthly_price_id: 'price_1LPlC3Rhl9bYbVxV2AO42x0H',
yearly_price_id: 'price_1LPlC4Rhl9bYbVxVYA9I7Z53',
},
})
})
20 changes: 10 additions & 10 deletions src/mocks/handlers/SubscriberProfile.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { graphql } from 'msw'
import { HttpResponse, graphql } from 'msw'
import { context } from '../context'

export const handler = graphql.query('SubscriberProfile', (_req, res, ctx) => {
export const handler = graphql.query('SubscriberProfile', () => {
if (!context.login) {
return res(
ctx.data({
return HttpResponse.json({
data: {
subscriberProfile: null,
}),
)
},
})
}

return res(
ctx.data({
return HttpResponse.json({
data: {
subscriberProfile: {
id: '1',
email: 'hello@example.com',
Expand All @@ -30,6 +30,6 @@ export const handler = graphql.query('SubscriberProfile', (_req, res, ctx) => {
price: '500',
},
},
}),
)
},
})
})

0 comments on commit 5edf041

Please sign in to comment.