-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a74e24
commit 1166bda
Showing
12 changed files
with
201 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
frontend/occupi-mobile4/components/LoadingGradientButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { LinearGradient } from 'expo-linear-gradient'; | ||
import { ActivityIndicator } from 'react-native'; | ||
import { widthPercentageToDP as wp, heightPercentageToDP as hp } from 'react-native-responsive-screen'; | ||
|
||
const LoadingGradientButton = () => { | ||
return ( | ||
<LinearGradient | ||
testID="gradient-loading-button" | ||
colors={['#614DC8', '#86EBCC', '#B2FC3A', '#EEF060']} | ||
locations={[0.02, 0.31, 0.67, 0.97]} | ||
start={[0, 1]} | ||
end={[1, 0]} | ||
style={{ | ||
paddingVertical: 15, | ||
alignItems: 'center', | ||
borderRadius: 15, | ||
marginTop: hp('2%'), | ||
width: wp('90%'), | ||
height: hp('6%'), | ||
alignSelf: 'center', | ||
}} | ||
> | ||
<ActivityIndicator testID="loading-indicator" size="small" color="#000" /> | ||
</LinearGradient> | ||
); | ||
}; | ||
|
||
export default LoadingGradientButton; |
30 changes: 30 additions & 0 deletions
30
frontend/occupi-mobile4/components/__tests__/GradientButton-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react-native'; | ||
import GradientButton from '../GradientButton'; | ||
|
||
describe('GradientButton', () => { | ||
it('renders correctly with the given text', () => { | ||
const { getByText } = render(<GradientButton text="Click Me" />); | ||
const buttonText = getByText('Click Me'); | ||
expect(buttonText).toBeTruthy(); | ||
}); | ||
|
||
it('calls the onPress function when pressed', () => { | ||
const onPressMock = jest.fn(); | ||
const { getByText } = render(<GradientButton text="Click Me" onPress={onPressMock} />); | ||
const buttonText = getByText('Click Me'); | ||
fireEvent.press(buttonText); | ||
expect(onPressMock).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('has the correct gradient colors', () => { | ||
const { getByTestId } = render(<GradientButton text="Click Me" />); | ||
const linearGradient = getByTestId('gradient-button').props; | ||
|
||
// Numeric color values | ||
const expectedColors = [4284566984, 4287032268, 4289920058, 4293849184]; | ||
|
||
expect(linearGradient.colors).toEqual(expectedColors); | ||
expect(linearGradient.locations).toEqual([0.02, 0.31, 0.67, 0.97]); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
frontend/occupi-mobile4/components/__tests__/LoadingGradient-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
import LoadingGradientButton from '../LoadingGradientButton'; | ||
|
||
describe('LoadingGradientButton', () => { | ||
it('renders the gradient with the correct colors and locations', () => { | ||
const { getByTestId } = render(<LoadingGradientButton />); | ||
const linearGradient = getByTestId('gradient-loading-button').props; | ||
|
||
// Numeric color values | ||
const expectedColors = [4284566984, 4287032268, 4289920058, 4293849184]; | ||
|
||
expect(linearGradient.colors).toEqual(expectedColors); | ||
expect(linearGradient.locations).toEqual([0.02, 0.31, 0.67, 0.97]); | ||
}); | ||
|
||
it('renders an ActivityIndicator with the correct properties', () => { | ||
const { getByTestId } = render(<LoadingGradientButton />); | ||
const activityIndicator = getByTestId('loading-indicator'); | ||
|
||
expect(activityIndicator).toBeTruthy(); | ||
expect(activityIndicator.props.size).toBe('small'); | ||
expect(activityIndicator.props.color).toBe('#000'); | ||
}); | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
frontend/occupi-mobile4/screens/Settings/__tests__/Profile-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
import Profile from '../Profile'; // Adjust the import based on your file structure | ||
|
||
// Mocking SecureStore and router | ||
jest.mock('expo-secure-store', () => ({ | ||
getItemAsync: jest.fn(), | ||
setItemAsync: jest.fn(), | ||
})); | ||
|
||
jest.mock('expo-router', () => ({ | ||
router: () => ({ replace: jest.fn() }), | ||
})); | ||
|
||
describe('Profile Component', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('renders the Profile component with initial state', async () => { | ||
// Mock data that would typically come from SecureStore | ||
const mockedData = { | ||
data: { | ||
details: { | ||
name: 'John Doe', | ||
contactNo: '1234567890', | ||
pronouns: 'He/Him', | ||
dob: '1990-01-01T00:00:00Z', // Make sure the format matches your component's expectations | ||
}, | ||
email: '[email protected]', | ||
occupiId: 'EMP12345', | ||
}, | ||
}; | ||
|
||
// Mock SecureStore getItemAsync to resolve with the mocked data | ||
require('expo-secure-store').getItemAsync.mockResolvedValueOnce(JSON.stringify(mockedData)); | ||
|
||
// Render the component | ||
const { getByText } = render(<Profile />); | ||
|
||
// Assertions for initial render | ||
expect(getByText('My account')).toBeTruthy(); | ||
expect(getByText('Full name')).toBeTruthy(); | ||
// expect(getByPlaceholderText('Kamogelo Moeket')).toBeTruthy(); // Example: Change to actual initial value | ||
expect(getByText('Date of birth')).toBeTruthy(); | ||
expect(getByText('Gender')).toBeTruthy(); | ||
expect(getByText('Email Address')).toBeTruthy(); | ||
// expect(getByPlaceholderText('[email protected]')).toBeTruthy(); // Example: Change to actual initial value | ||
expect(getByText('Occupi ID')).toBeTruthy(); | ||
// expect(getByPlaceholderText('EMP12345')).toBeTruthy(); // Example: Change to actual initial value | ||
expect(getByText('Cell No')).toBeTruthy(); | ||
expect(getByText('Pronouns (optional)')).toBeTruthy(); | ||
// expect(getByPlaceholderText('He/Him')).toBeTruthy(); // Example: Change to actual initial value | ||
expect(getByText('Save')).toBeTruthy(); // Assuming there's a "Save" button | ||
}); | ||
|
||
// Add more tests as needed for specific UI components | ||
}); | ||
|