Skip to content

Commit

Permalink
Rename component and function in user service
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanc19 committed Jan 9, 2025
1 parent fa3247c commit a5241ae
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import { FirstLoginPageComponent } from '@features/first-login-page/first-login-
import { ForgotYourPasswordComponent } from '@features/forgot-your-username-or-password/forgot-your-password/forgot-your-password.component';
import { ForgotYourUsernameOrPasswordComponent } from '@features/forgot-your-username-or-password/forgot-your-username-or-password.component';
import { ForgotYourUsernameComponent } from '@features/forgot-your-username-or-password/forgot-your-username/forgot-your-username.component';
import { UsernameFoundComponent } from '@features/forgot-your-username-or-password/username-found/username-found.component';
import { SecurityQuestionAnswerNotMatchComponent } from '@features/forgot-your-username-or-password/forgot-your-username/security-question-answer-not-match/security-question-answer-not-match.component';
import { UserAccountNotFoundComponent } from '@features/forgot-your-username-or-password/forgot-your-username/user-account-not-found/user-account-not-found.component';
import { UsernameFoundComponent } from '@features/forgot-your-username-or-password/username-found/username-found.component';
import { LoginComponent } from '@features/login/login.component';
import { StartersLeaversVacanciesLoginMessageComponent } from '@features/login/starters-leavers-vacancies-login-message/starters-leavers-vacancies-login-message.component';
import { VacanciesAndTurnoverLoginMessage } from '@features/login/vacancies-and-turnover-login-message/vacancies-and-turnover-login-message.component';
import { LogoutComponent } from '@features/logout/logout.component';
import { MigratedUserTermsConditionsComponent } from '@features/migrated-user-terms-conditions/migrated-user-terms-conditions.component';
import { BecomeAParentComponent } from '@features/new-dashboard/become-a-parent/become-a-parent.component';
Expand Down Expand Up @@ -151,7 +151,7 @@ const routes: Routes = [
},
{
path: 'update-your-vacancies-and-turnover-data',
component: StartersLeaversVacanciesLoginMessageComponent,
component: VacanciesAndTurnoverLoginMessage,
data: { title: 'Update your vacancies and turnover data' },
},
{
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import { SecurityQuestionAnswerNotMatchComponent } from '@features/forgot-your-u
import { UserAccountNotFoundComponent } from '@features/forgot-your-username-or-password/forgot-your-username/user-account-not-found/user-account-not-found.component';
import { UsernameFoundComponent } from '@features/forgot-your-username-or-password/username-found/username-found.component';
import { LoginComponent } from '@features/login/login.component';
import { StartersLeaversVacanciesLoginMessageComponent } from '@features/login/starters-leavers-vacancies-login-message/starters-leavers-vacancies-login-message.component';
import { VacanciesAndTurnoverLoginMessage } from '@features/login/vacancies-and-turnover-login-message/vacancies-and-turnover-login-message.component';
import { LogoutComponent } from '@features/logout/logout.component';
import { BecomeAParentComponent } from '@features/new-dashboard/become-a-parent/become-a-parent.component';
import { DashboardWrapperComponent } from '@features/new-dashboard/dashboard-wrapper.component';
Expand Down Expand Up @@ -151,7 +151,7 @@ import { SentryErrorHandler } from './SentryErrorHandler.component';
SelectStarterJobRolesComponent,
SecurityQuestionAnswerNotMatchComponent,
UserAccountNotFoundComponent,
StartersLeaversVacanciesLoginMessageComponent,
VacanciesAndTurnoverLoginMessage,
],
imports: [
Angulartics2Module.forRoot({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/core/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class UserService {
.pipe(map((response) => response.users));
}

public updateSLVMessage() {
public updateLastViewedVacanciesAndTurnoverLoginMessage() {
return this.http.post(
`${environment.appRunnerEndpoint}/api/user/update-last-viewed-slv-message/${this.loggedInUser.uid}`,
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { SharedModule } from '@shared/shared.module';
import { render } from '@testing-library/angular';
import { of } from 'rxjs';

import { StartersLeaversVacanciesLoginMessageComponent } from './starters-leavers-vacancies-login-message.component';
import { VacanciesAndTurnoverLoginMessage } from './vacancies-and-turnover-login-message.component';

describe('StartersLeaversVacanciesLoginMessageComponent', () => {
describe('VacanciesAndTurnoverLoginMessage', () => {
async function setup() {
const updateSLVMessageSpy = jasmine.createSpy('updateSLVMessage').and.returnValue(of(null));
const updateLastViewedVacanciesAndTurnoverLoginMessageSpy = jasmine
.createSpy('updateLastViewedVacanciesAndTurnoverLoginMessage')
.and.returnValue(of(null));

const setupTools = await render(StartersLeaversVacanciesLoginMessageComponent, {
const setupTools = await render(VacanciesAndTurnoverLoginMessage, {
imports: [SharedModule, RouterModule, RouterTestingModule],
providers: [
{
Expand All @@ -20,7 +22,7 @@ describe('StartersLeaversVacanciesLoginMessageComponent', () => {
loggedInUser: {
uid: 'ajoij3213213213',
},
updateSLVMessage: updateSLVMessageSpy,
updateLastViewedVacanciesAndTurnoverLoginMessage: updateLastViewedVacanciesAndTurnoverLoginMessageSpy,
},
},
],
Expand All @@ -31,11 +33,11 @@ describe('StartersLeaversVacanciesLoginMessageComponent', () => {
return {
...setupTools,
component,
updateSLVMessageSpy,
updateLastViewedVacanciesAndTurnoverLoginMessageSpy,
};
}

it('should render a StartersLeaversVacanciesLoginMessageComponent', async () => {
it('should render a VacanciesAndTurnoverLoginMessage', async () => {
const { component } = await setup();

expect(component).toBeTruthy();
Expand All @@ -49,9 +51,9 @@ describe('StartersLeaversVacanciesLoginMessageComponent', () => {
expect(continueButton.getAttribute('href')).toEqual('/dashboard');
});

it('should call updateSLVMessage in UserService on page load', async () => {
const { updateSLVMessageSpy } = await setup();
it('should call updateLastViewedVacanciesAndTurnoverLoginMessage in UserService on page load', async () => {
const { updateLastViewedVacanciesAndTurnoverLoginMessageSpy } = await setup();

expect(updateSLVMessageSpy).toHaveBeenCalled();
expect(updateLastViewedVacanciesAndTurnoverLoginMessageSpy).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { UserService } from '@core/services/user.service';
import { Subscription } from 'rxjs';

@Component({
selector: 'app-starters-leavers-vacancies-login-message',
templateUrl: './starters-leavers-vacancies-login-message.component.html',
selector: 'app-vacancies-and-turnover-login-message',
templateUrl: './vacancies-and-turnover-login-message.component.html',
})
export class StartersLeaversVacanciesLoginMessageComponent implements OnDestroy {
export class VacanciesAndTurnoverLoginMessage implements OnDestroy {
private subscriptions: Subscription = new Subscription();

constructor(private userService: UserService) {
this.subscriptions.add(this.userService.updateSLVMessage().subscribe(() => {}));
this.subscriptions.add(this.userService.updateLastViewedVacanciesAndTurnoverLoginMessage().subscribe(() => {}));
}

ngOnDestroy(): void {
Expand Down

0 comments on commit a5241ae

Please sign in to comment.