-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgh-user.component.spec.ts
More file actions
55 lines (47 loc) · 1.62 KB
/
Copy pathgh-user.component.spec.ts
File metadata and controls
55 lines (47 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { Component, input } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { GhFullUser, GhUserMock, GhUserRepo } from '@gh/shared/models';
import { testSetup } from 'core/utils/test/setup';
import { describe, expect, test } from 'vitest';
import { GhUserReposComponent } from '../gh-user-repos/gh-user-repos.component';
import { GhUserComponent } from './gh-user.component';
import { GhUserPageObject } from './gh-user.page-object';
@Component({
selector: 'gh-user-repos',
standalone: true,
template: '',
})
class GhUserReposMockComponent {
user = input.required<GhFullUser>();
repos = input.required<GhUserRepo[]>();
}
describe('GhUserComponent', () => {
const userMock = new GhUserMock().withId(1);
const setup = () => {
const { fixture, component } = testSetup(GhUserComponent);
return { fixture, component, po: new GhUserPageObject(fixture) };
};
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [GhUserComponent],
providers: [provideHttpClientTesting()],
})
.overrideComponent(GhUserComponent, {
remove: {
imports: [GhUserReposComponent],
},
add: {
imports: [GhUserReposMockComponent],
},
})
.compileComponents();
});
test('should display the correct user ID in the badge', () => {
const { fixture, po } = setup();
fixture.componentRef.setInput('user', userMock.model);
fixture.detectChanges();
const userIdBadge = po.getUserIdBadge();
expect((userIdBadge?.nativeElement as HTMLElement).textContent).toBe(userMock.model.id.toString());
});
});