Skip to content

Commit 40d6b8d

Browse files
authored
feat(#10): account password reset (#57)
chore: run format
1 parent fd61cb2 commit 40d6b8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5995
-1568
lines changed

Diff for: AppManager.tsx

-5
This file was deleted.

Diff for: __tests__/auth/login/OrgLogin.test.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ describe('<OrgLogin />', () => {
2626
expect(pulse_co).toBeTruthy();
2727
expect(pulse_co.props.children).toBe('.pulse.co');
2828

29-
fireEvent.changeText(orgInput, 'MyOrganization');
29+
fireEvent.changeText(orgInput, 'MyOrganization');
3030
expect(orgInput.props.value).toBe('MyOrganization');
3131

32-
const expectedWidth = Math.min('MyOrganization'.length * 11, 200);
32+
const expectedWidth = Math.min('MyOrganization'.length * 11, 200);
3333
expect(orgInput.props.style.width).toBe(expectedWidth);
34-
3534
});
3635

3736
test('shows validation error if input is empty and submitted', async () => {

Diff for: __tests__/auth/login/UserLogin.test.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ describe('UserLogin Component', () => {
3434
fireEvent.changeText(getByPlaceholderText('Password'), 'ValidPassword');
3535
fireEvent.press(getByText('Sign In'));
3636

37-
await waitFor(() => expect(mockOnSubmit).toHaveBeenCalledWith({
38-
39-
password: 'ValidPassword',
40-
}));
37+
await waitFor(() =>
38+
expect(mockOnSubmit).toHaveBeenCalledWith({
39+
40+
password: 'ValidPassword',
41+
})
42+
);
4143

4244
expect(mockOnSubmit).toHaveBeenCalledTimes(1);
4345
});

Diff for: __tests__/components/About_trainee.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ describe('AboutTrainee Component', () => {
3939
expect(getByText('Available upon request.')).toBeTruthy();
4040
expect(getByText('A passionate developer.')).toBeTruthy();
4141
});
42-
});
42+
});

Diff for: __tests__/components/LanguagePicker.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react';
22
import { render, fireEvent } from '@testing-library/react-native';
33
import { I18nextProvider } from 'react-i18next';
4-
import i18n from '@/internationalization';
4+
import i18n from '@/internationalization';
55
import LanguagePicker from '@/components/LanguagePicker';
66

77
jest.mock('react-native/Libraries/Utilities/useColorScheme', () => ({
88
__esModule: true,
9-
default: jest.fn(() => 'light'),
9+
default: jest.fn(() => 'light'),
1010
}));
1111

1212
describe('LanguagePicker', () => {

Diff for: __tests__/components/TraineeRatings.test.tsx

+19-20
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ describe('TraineeRatings Component', () => {
4444
it('fetches user token from AsyncStorage', async () => {
4545
const mockToken = 'mock-token';
4646
AsyncStorage.getItem = jest.fn(() => Promise.resolve(mockToken));
47-
47+
4848
render(<TraineeRatings />);
49-
49+
5050
await waitFor(() => {
5151
expect(AsyncStorage.getItem).toHaveBeenCalledWith('authToken');
5252
});
5353
});
54-
54+
5555
it('alerts when token is not found', async () => {
5656
AsyncStorage.getItem = jest.fn(() => Promise.resolve(null));
5757
global.alert = jest.fn();
58-
58+
5959
render(<TraineeRatings />);
60-
60+
6161
await waitFor(() => {
6262
expect(global.alert).toHaveBeenCalledWith('Error', 'User token not found.');
6363
});
@@ -68,13 +68,13 @@ describe('TraineeRatings Component', () => {
6868
request: { query: TRAINEE_RATING },
6969
error: mockError,
7070
};
71-
71+
7272
const { getByText } = render(
7373
<MockedProvider mocks={[mockErrorQuery]} addTypename={false}>
7474
<TraineeRatings />
7575
</MockedProvider>
7676
);
77-
77+
7878
await waitFor(() => {
7979
expect(getByText('Error')).toBeTruthy();
8080
});
@@ -85,9 +85,9 @@ describe('TraineeRatings Component', () => {
8585
<TraineeRatings />
8686
</MockedProvider>
8787
);
88-
88+
8989
fireEvent.changeText(getByPlaceholderText('Filter by Sprint'), '2');
90-
90+
9191
await waitFor(() => {
9292
const sprintFiltered = getAllByText(/Sprint 2/i);
9393
expect(sprintFiltered.length).toBeGreaterThan(0);
@@ -99,9 +99,9 @@ describe('TraineeRatings Component', () => {
9999
<TraineeRatings />
100100
</MockedProvider>
101101
);
102-
102+
103103
fireEvent.press(getByText('Phase II'));
104-
104+
105105
await waitFor(() => {
106106
const phaseFiltered = getAllByText('Phase II');
107107
expect(phaseFiltered.length).toBeGreaterThan(0);
@@ -113,7 +113,7 @@ describe('TraineeRatings Component', () => {
113113
<TraineeRatings />
114114
</MockedProvider>
115115
);
116-
116+
117117
await waitFor(() => {
118118
expect(getByText('SPRINT')).toBeTruthy();
119119
expect(getByText('QUANTITY')).toBeTruthy();
@@ -124,13 +124,13 @@ describe('TraineeRatings Component', () => {
124124
request: { query: TRAINEE_RATING },
125125
result: { data: { fetchRatingsTrainee: [] } },
126126
};
127-
127+
128128
const { getByText } = render(
129129
<MockedProvider mocks={[emptyMockData]} addTypename={false}>
130130
<TraineeRatings />
131131
</MockedProvider>
132132
);
133-
133+
134134
await waitFor(() => {
135135
expect(getByText('No Ratings Available')).toBeTruthy();
136136
});
@@ -141,16 +141,16 @@ describe('TraineeRatings Component', () => {
141141
<TraineeRatings />
142142
</MockedProvider>
143143
);
144-
144+
145145
const viewButtons = getAllByText('View');
146146
fireEvent.press(viewButtons[0]);
147-
147+
148148
await waitFor(() => {
149149
expect(getByText('From: Manager')).toBeTruthy();
150150
expect(getByText('Feedback: Great performance')).toBeTruthy();
151151
});
152152
});
153-
153+
154154
it('renders without errors and displays fetched data', async () => {
155155
const { getByText, getByPlaceholderText } = render(
156156
<MockedProvider mocks={[mockRatingsData]} addTypename={false}>
@@ -194,14 +194,13 @@ describe('TraineeRatings Component', () => {
194194
<TraineeRatings />
195195
</MockedProvider>
196196
);
197-
197+
198198
const viewButtons = await findAllByText('View'); // Async await find method
199199
fireEvent.press(viewButtons[0]);
200-
200+
201201
await waitFor(() => {
202202
expect(getByText('From: Manager')).toBeTruthy();
203203
expect(getByText('Feedback: Great performance')).toBeTruthy();
204204
});
205205
});
206-
207206
});

Diff for: __tests__/components/Trainee_org.test.tsx

+57-57
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,65 @@ import { render } from '@testing-library/react-native';
33
import TraineeOrg from '../../components/trainee/Organisation';
44

55
describe('TraineeOrg Component', () => {
6-
const profile = {
7-
user: {
8-
organizations: 'Andela',
9-
role: 'Trainee',
10-
team: {
11-
cohort: {
12-
program: {
13-
name: 'Software Engineering',
14-
},
15-
name: 'Cohort 1',
16-
phase: {
17-
name: 'Phase 1',
18-
},
19-
},
20-
name: 'Team A',
21-
},
22-
},
23-
};
6+
const profile = {
7+
user: {
8+
organizations: 'Andela',
9+
role: 'Trainee',
10+
team: {
11+
cohort: {
12+
program: {
13+
name: 'Software Engineering',
14+
},
15+
name: 'Cohort 1',
16+
phase: {
17+
name: 'Phase 1',
18+
},
19+
},
20+
name: 'Team A',
21+
},
22+
},
23+
};
2424

25-
const pulse = '<svg></svg>';
26-
const bgColor = 'bg-white';
27-
const textColor = 'text-black';
25+
const pulse = '<svg></svg>';
26+
const bgColor = 'bg-white';
27+
const textColor = 'text-black';
2828

29-
it('renders organization details correctly', () => {
30-
const { getByText } = render(<TraineeOrg profile={profile} bgColor={bgColor} textColor={textColor} />);
29+
it('renders organization details correctly', () => {
30+
const { getByText } = render(
31+
<TraineeOrg profile={profile} bgColor={bgColor} textColor={textColor} />
32+
);
3133

32-
expect(getByText('YOUR ORGANISATION DETAILS')).toBeTruthy();
33-
expect(getByText('Organisation Name:')).toBeTruthy();
34-
expect(getByText('Andela')).toBeTruthy();
35-
expect(getByText('Admin email:')).toBeTruthy();
36-
expect(getByText('[email protected]')).toBeTruthy();
37-
expect(getByText('Role:')).toBeTruthy();
38-
expect(getByText('Trainee')).toBeTruthy();
39-
});
34+
expect(getByText('YOUR ORGANISATION DETAILS')).toBeTruthy();
35+
expect(getByText('Organisation Name:')).toBeTruthy();
36+
expect(getByText('Andela')).toBeTruthy();
37+
expect(getByText('Admin email:')).toBeTruthy();
38+
expect(getByText('[email protected]')).toBeTruthy();
39+
expect(getByText('Role:')).toBeTruthy();
40+
expect(getByText('Trainee')).toBeTruthy();
41+
});
4042

41-
it('renders management details correctly', () => {
42-
const { getByText } = render(<TraineeOrg profile={profile} bgColor={bgColor} textColor={textColor} />);
43+
it('renders management details correctly', () => {
44+
const { getByText } = render(
45+
<TraineeOrg profile={profile} bgColor={bgColor} textColor={textColor} />
46+
);
4347

44-
expect(getByText('MANAGEMENT')).toBeTruthy();
45-
expect(getByText('Program:')).toBeTruthy();
46-
expect(getByText('Software Engineering')).toBeTruthy();
47-
expect(getByText('Cohort :')).toBeTruthy();
48-
expect(getByText('Cohort 1')).toBeTruthy();
49-
expect(getByText('Team:')).toBeTruthy();
50-
expect(getByText('Team A')).toBeTruthy();
51-
expect(getByText('Phase:')).toBeTruthy();
52-
expect(getByText('Phase 1')).toBeTruthy();
53-
});
54-
it('renders unavailable text when data is missing', () => {
55-
const emptyProfile = {};
56-
const { getAllByText } = render(
57-
<TraineeOrg
58-
profile={emptyProfile}
59-
bgColor="bg-white"
60-
textColor="text-black"
61-
/>
62-
);
63-
64-
const unavailableElements = getAllByText('Unavailable');
65-
expect(unavailableElements.length).toBe(6); // Adjust the expected count to match the actual rendered elements
66-
});
67-
});
48+
expect(getByText('MANAGEMENT')).toBeTruthy();
49+
expect(getByText('Program:')).toBeTruthy();
50+
expect(getByText('Software Engineering')).toBeTruthy();
51+
expect(getByText('Cohort :')).toBeTruthy();
52+
expect(getByText('Cohort 1')).toBeTruthy();
53+
expect(getByText('Team:')).toBeTruthy();
54+
expect(getByText('Team A')).toBeTruthy();
55+
expect(getByText('Phase:')).toBeTruthy();
56+
expect(getByText('Phase 1')).toBeTruthy();
57+
});
58+
it('renders unavailable text when data is missing', () => {
59+
const emptyProfile = {};
60+
const { getAllByText } = render(
61+
<TraineeOrg profile={emptyProfile} bgColor="bg-white" textColor="text-black" />
62+
);
63+
64+
const unavailableElements = getAllByText('Unavailable');
65+
expect(unavailableElements.length).toBe(6); // Adjust the expected count to match the actual rendered elements
66+
});
67+
});

Diff for: __tests__/components/sidebar.test.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,4 @@ describe('Sidebar', () => {
7878
expect(mockPush).toHaveBeenCalledWith('/auth/login');
7979
});
8080
});
81-
8281
});

Diff for: __tests__/dashboard/trainee/Profile.test.tsx

+23-11
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,25 @@ describe('<Profile />', () => {
7474
render(<Profile />);
7575

7676
await waitFor(() => {
77-
expect(showMock).toHaveBeenCalledWith('Token Not found.', { type: 'danger', placement: 'top', duration: 3000 });
77+
expect(showMock).toHaveBeenCalledWith('Token Not found.', {
78+
type: 'danger',
79+
placement: 'top',
80+
duration: 3000,
81+
});
7882
});
7983
});
8084

8185
test('handles tab switching correctly', async () => {
8286
mockUseQuery.mockReturnValue({
8387
data: {
8488
getProfile: {
85-
avatar: 'https://example.com/avatar.png',
86-
name: 'John Doe',
87-
88-
phoneNumber: '1234567890',
89-
address: '123 Main St',
90-
resume: 'https://example.com/resume.pdf',
91-
biography: 'This is a biography.',
89+
avatar: 'https://example.com/avatar.png',
90+
name: 'John Doe',
91+
92+
phoneNumber: '1234567890',
93+
address: '123 Main St',
94+
resume: 'https://example.com/resume.pdf',
95+
biography: 'This is a biography.',
9296
},
9397
},
9498
loading: false,
@@ -136,7 +140,11 @@ describe('<Profile />', () => {
136140
render(<Profile />);
137141

138142
await waitFor(() => {
139-
expect(showMock).toHaveBeenCalledWith('Error fetching profile.', { type: 'danger', placement: 'top', duration: 3000 });
143+
expect(showMock).toHaveBeenCalledWith('Error fetching profile.', {
144+
type: 'danger',
145+
placement: 'top',
146+
duration: 3000,
147+
});
140148
});
141149
});
142150

@@ -176,7 +184,11 @@ describe('<Profile />', () => {
176184
fireEvent.press(getByTestId('edit-button'));
177185

178186
await waitFor(() => {
179-
expect(showMock).toHaveBeenCalledWith('Edit button pressed', { type: 'info', placement: 'top', duration: 3000 });
187+
expect(showMock).toHaveBeenCalledWith('Edit button pressed', {
188+
type: 'info',
189+
placement: 'top',
190+
duration: 3000,
191+
});
180192
});
181193
});
182194

@@ -200,4 +212,4 @@ describe('<Profile />', () => {
200212
expect(getByText('John Doe')).toHaveStyle({ color: 'text-gray-100' });
201213
});
202214
});
203-
});
215+
});

0 commit comments

Comments
 (0)