Skip to content

Commit 661f692

Browse files
committed
chore: format code
1 parent e85b757 commit 661f692

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

Sandbox.AngularWorkspace/projects/sandbox-app/src/app/app.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ import Header from './core/header/header';
99
styleUrl: './app.css',
1010
changeDetection: ChangeDetectionStrategy.OnPush,
1111
})
12+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
1213
export class App {}

Sandbox.AngularWorkspace/projects/sandbox-app/src/app/core/header/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ <h3>👋 Hello, {{ user()?.name }}</h3>
1212
<a routerLink="/customers">Customers</a> | <a routerLink="/user">Current User</a> |
1313
<a href="/bff/logout">Logout</a>
1414
</nav>
15-
</header>
15+
</header>

Sandbox.AngularWorkspace/projects/sandbox-app/src/app/core/header/header.spec.ts

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,37 @@ import { signal } from '@angular/core';
55
import Header from './header';
66
import { Authentication } from '@sandbox-app/authentication/authentication';
77

8-
const mockUser = signal<{ isAuthenticated: boolean; name: string | null }>({
9-
isAuthenticated: true,
10-
name: 'Test User',
11-
});
12-
const mockAuthService = {
13-
user: mockUser,
14-
};
15-
168
it('renders anonymous header when user is not authenticated', async () => {
17-
mockUser.set({ isAuthenticated: false, name: null });
18-
19-
await render(Header, {
20-
providers: [provideRouter([]), { provide: Authentication, useValue: mockAuthService }],
21-
});
9+
await setup({ isAuthenticated: false, name: null });
2210

2311
expect(screen.getByText('Login')).toBeInTheDocument();
2412
expect(screen.getByText('Customers')).toBeInTheDocument();
2513
});
2614

2715
it('renders authenticated header when user is authenticated', async () => {
28-
mockUser.set({ isAuthenticated: true, name: 'John Doe' });
29-
30-
await render(Header, {
31-
providers: [provideRouter([]), { provide: Authentication, useValue: mockAuthService }],
32-
});
16+
await setup({ isAuthenticated: true, name: 'John Doe' });
3317

3418
expect(screen.getByText('👋 Hello, John Doe')).toBeInTheDocument();
3519
expect(screen.getByText('Logout')).toBeInTheDocument();
3620
expect(screen.getByText('Customers')).toBeInTheDocument();
3721
});
3822

3923
it('has working navigation links', async () => {
40-
mockUser.set({ isAuthenticated: true, name: 'John Doe' });
41-
42-
await render(Header, {
43-
providers: [
44-
provideRouter([
45-
{ path: 'customers', component: Header },
46-
{ path: 'user', component: Header },
47-
]),
48-
],
49-
});
24+
await setup({ isAuthenticated: true, name: 'John Doe' });
5025

5126
const customersLink = screen.getByRole('link', { name: 'Customers' });
5227
const userLink = screen.getByRole('link', { name: 'Current User' });
5328

5429
expect(customersLink).toHaveAttribute('href', '/customers');
5530
expect(userLink).toHaveAttribute('href', '/user');
5631
});
32+
33+
function setup(user: { isAuthenticated: boolean; name: string | null }) {
34+
const mockAuthService = {
35+
user: signal(user),
36+
};
37+
38+
return render(Header, {
39+
providers: [provideRouter([]), { provide: Authentication, useValue: mockAuthService }],
40+
});
41+
}

Sandbox.AngularWorkspace/projects/sandbox-app/src/app/core/header/header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ import { Anonymous } from '@sandbox-app/authentication/anonymous';
1414
export default class Header {
1515
private readonly authenticationService = inject(Authentication);
1616
protected readonly user = this.authenticationService.user;
17-
}
17+
}

0 commit comments

Comments
 (0)