diff --git a/src/popup/Popup.tsx b/src/popup/Popup.tsx
index 89d305cf..82d733ff 100644
--- a/src/popup/Popup.tsx
+++ b/src/popup/Popup.tsx
@@ -3,9 +3,14 @@ import './Popup.scss'
import React from 'react'
import { RouterProvider } from '@/components/router-provider'
+import { PopupProvider } from '@/providers/popup-context'
const Popup = () => {
- return
+ return (
+
+
+
+ )
}
export default Popup
diff --git a/src/providers/__tests__/popup-context.test.tsx b/src/providers/__tests__/popup-context.test.tsx
new file mode 100644
index 00000000..ed841a6c
--- /dev/null
+++ b/src/providers/__tests__/popup-context.test.tsx
@@ -0,0 +1,90 @@
+import { act, render, screen } from '@testing-library/react'
+import React, { useContext } from 'react'
+
+import { defaultData, PopupContext, PopupProvider } from '../popup-context'
+
+const TestComponent = () => {
+ const { data, setData } = useContext(PopupContext)
+
+ return (
+
+
{data.amount}
+
{data.rateOfPay}
+
+
+ )
+}
+
+const MockChildComponent = () => {
+ const { data } = useContext(PopupContext)
+ return {data.amount}
+}
+
+describe('PopupProvider', () => {
+ it('provides the initial context values', () => {
+ render(
+
+
+ ,
+ )
+
+ expect(screen.getByTestId('amount').textContent).toBe('0')
+ expect(screen.getByTestId('rateOfPay').textContent).toBe('0.36')
+ })
+
+ it('updates context values when setData is called', () => {
+ render(
+
+
+ ,
+ )
+
+ act(() => {
+ screen.getByText('Update Amount').click()
+ })
+
+ expect(screen.getByTestId('amount').textContent).toBe('100')
+ })
+
+ it('displays different initial values correctly', () => {
+ const customInitialData = {
+ ...defaultData,
+ amount: 50,
+ rateOfPay: 0.45,
+ }
+
+ render(
+ {} }}>
+
+ ,
+ )
+
+ expect(screen.getByTestId('amount').textContent).toBe('50')
+ expect(screen.getByTestId('rateOfPay').textContent).toBe('0.45')
+ })
+
+ it('handles multiple updates to context values', () => {
+ render(
+
+
+ ,
+ )
+
+ act(() => {
+ screen.getByText('Update Amount').click()
+ screen.getByText('Update Amount').click()
+ })
+
+ expect(screen.getByTestId('amount').textContent).toBe('100')
+ })
+
+ it('renders child component with context data', () => {
+ render(
+
+
+ ,
+ )
+
+ expect(screen.getByTestId('mock-child').textContent).toBe('0')
+ })
+})
diff --git a/src/providers/index.ts b/src/providers/index.ts
new file mode 100644
index 00000000..35b996f2
--- /dev/null
+++ b/src/providers/index.ts
@@ -0,0 +1,3 @@
+import { PopupProvider } from './popup-context'
+
+export { PopupProvider }
diff --git a/src/providers/popup-context.tsx b/src/providers/popup-context.tsx
new file mode 100644
index 00000000..392f2c7f
--- /dev/null
+++ b/src/providers/popup-context.tsx
@@ -0,0 +1,33 @@
+import React, { createContext, useState } from 'react'
+
+import { PopupContextValue, TPopupContext } from './providers.interface'
+
+export const defaultData = {
+ amount: 0,
+ amountType: {
+ recurring: true,
+ },
+ rateOfPay: 0.36,
+ wmEnabled: true,
+ accessTokenQuote: '',
+ accessTokenOutgoing: '',
+ refreshToken: '',
+ manageUrl: '',
+}
+
+interface IProps {
+ children: React.ReactNode
+}
+
+export const PopupContext = createContext({
+ data: defaultData,
+ setData: () => {},
+})
+
+export const PopupProvider: React.FC = ({ children }) => {
+ const [data, setData] = useState(defaultData)
+
+ return {children}
+}
+
+export default PopupProvider
diff --git a/src/providers/providers.interface.ts b/src/providers/providers.interface.ts
new file mode 100644
index 00000000..9be002fd
--- /dev/null
+++ b/src/providers/providers.interface.ts
@@ -0,0 +1,19 @@
+import React from 'react'
+
+export interface PopupContextValue {
+ data: TPopupContext
+ setData: React.Dispatch>
+}
+
+export type TPopupContext = {
+ amount: number
+ amountType: {
+ recurring: boolean
+ }
+ rateOfPay: number
+ wmEnabled: boolean
+ accessTokenQuote: string
+ accessTokenOutgoing: string
+ refreshToken: string
+ manageUrl: string
+}
diff --git a/tsconfig.json b/tsconfig.json
index a568303a..428a3871 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -21,6 +21,7 @@
"@/content/*": ["./content/*"],
"@/assets/*": ["./assets/*"],
"@/components/*": ["./components/*"],
+ "@/providers/*": ["./providers/*"],
"@/types/*": ["./types/*"],
"@/hooks/*": ["./hooks/*"]
}
diff --git a/webpack.config.utils.ts b/webpack.config.utils.ts
index 176e4579..3361087b 100644
--- a/webpack.config.utils.ts
+++ b/webpack.config.utils.ts
@@ -217,6 +217,7 @@ export const getResolves = () => {
'@/content': path.resolve(__dirname, './src/content/'),
'@/assets': path.resolve(__dirname, './src/assets/'),
'@/components': path.resolve(__dirname, './src/components/'),
+ '@/providers': path.resolve(__dirname, './src/providers/'),
'@/types': path.resolve(__dirname, './src/types/'),
'@/hooks': path.resolve(__dirname, './src/hooks/'),
},