75 lines
3.1 KiB
TypeScript
75 lines
3.1 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||
/**
|
||
* Catalogue section 23 — Terms (`tests/pages/terms.test.tsx`).
|
||
*
|
||
* TERMS-04/05 (the `showTitle` / `compact` props of the shared content) live in
|
||
* `tests/components/static-chrome.test.tsx`; TERMS-01..03 and TERMS-06 cover the
|
||
* terms route and the login terms dialog here.
|
||
*/
|
||
import React from 'react'
|
||
import { fireEvent } from '@testing-library/react-native'
|
||
|
||
import Terms from '@/app/(drawer)/(tabs)/me/terms/index'
|
||
import Login from '@/app/(auth)/login'
|
||
|
||
import { renderWithProviders, flush } from '../helpers/test-utils'
|
||
import { resetAllMocks } from '../helpers/reset'
|
||
import { router } from '../mocks/expo-router-mock'
|
||
|
||
describe('Terms (TERMS-01..TERMS-03, TERMS-06)', () => {
|
||
beforeEach(() => resetAllMocks())
|
||
|
||
it('TERMS-01: the terms page shows the header and the policy title', () => {
|
||
const view = renderWithProviders(<Terms />, { auth: 'in' })
|
||
|
||
expect(view.getByText('Terms & Conditions')).toBeTruthy()
|
||
expect(view.getByText('FRESHYO – Legal Policies')).toBeTruthy()
|
||
})
|
||
|
||
it('TERMS-02: the page renders sections A–E including COD, privacy, refunds and contact', () => {
|
||
const view = renderWithProviders(<Terms />, { auth: 'in' })
|
||
|
||
expect(view.getByText('A. TERMS & CONDITIONS')).toBeTruthy()
|
||
expect(view.getByText('B. PRIVACY POLICY')).toBeTruthy()
|
||
expect(view.getByText('C. REFUND & CANCELLATION POLICY')).toBeTruthy()
|
||
expect(view.getByText('D. CONTACT INFORMATION')).toBeTruthy()
|
||
expect(view.getByText('E. ACCEPTANCE')).toBeTruthy()
|
||
|
||
expect(
|
||
view.getByText(
|
||
'Prices are displayed in INR and include applicable taxes unless stated otherwise. Only Cash on Delivery (COD) is accepted. Full payment must be made at the time of delivery. Failure to pay may result in order cancellation and account restrictions.'
|
||
)
|
||
).toBeTruthy()
|
||
expect(
|
||
view.getByText('FRESHYO respects your privacy and is committed to protecting your data.')
|
||
).toBeTruthy()
|
||
expect(
|
||
view.getByText(
|
||
"Since payments are Cash on Delivery, refunds (if applicable) will be handled via: cash adjustment, replacement, or store credit (at FRESHYO's discretion)."
|
||
)
|
||
).toBeTruthy()
|
||
expect(view.getByText('📧 Email: support@freshyo.in')).toBeTruthy()
|
||
expect(view.getByText('📞 Customer Support: 8688182552')).toBeTruthy()
|
||
})
|
||
|
||
it('TERMS-03: the back button calls router.back', () => {
|
||
const view = renderWithProviders(<Terms />, { auth: 'in' })
|
||
|
||
fireEvent.press(view.getByTestId('terms-back'))
|
||
|
||
expect(router.back).toHaveBeenCalledTimes(1)
|
||
})
|
||
|
||
it('TERMS-06: the login terms dialog reuses the shared legal content', async () => {
|
||
const view = renderWithProviders(<Login />, { auth: 'out' })
|
||
await flush(1)
|
||
|
||
expect(view.queryByText('FRESHYO – Legal Policies')).toBeNull()
|
||
fireEvent.press(view.getByText('Terms and Conditions'))
|
||
|
||
expect(view.getByText('FRESHYO – Legal Policies')).toBeTruthy()
|
||
expect(view.getByText('A. TERMS & CONDITIONS')).toBeTruthy()
|
||
expect(view.getByText('E. ACCEPTANCE')).toBeTruthy()
|
||
expect(view.getByText('📧 Email: support@freshyo.in')).toBeTruthy()
|
||
})
|
||
})
|