Skip to content

Commit f77f2c4

Browse files
committed
test(sp): мигрировать ui на Vitest
1 parent 4a162b9 commit f77f2c4

46 files changed

Lines changed: 237 additions & 302 deletions

File tree

Some content is hidden

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

projects/social_platform/src/app/ui/pages/auth/confirm-email/confirm-email.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("ConfirmEmailComponent", () => {
1515
let fixture: ComponentFixture<ConfirmEmailComponent>;
1616

1717
beforeEach(async () => {
18-
const authSpy = jasmine.createSpyObj(["getTokens", "memTokens"]);
18+
const authSpy = { getTokens: vi.fn(), memTokens: vi.fn() };
1919
const authPortSpy = {
2020
login: of({} as any),
2121
logout: of(undefined),

projects/social_platform/src/app/ui/pages/auth/email-verification/email-verification.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("EmailVerificationComponent", () => {
1515
let fixture: ComponentFixture<EmailVerificationComponent>;
1616

1717
beforeEach(async () => {
18-
const authSpy = jasmine.createSpyObj(["memTokens"]);
18+
const authSpy = { memTokens: vi.fn() };
1919
const authPortSpy = {
2020
login: of({} as any),
2121
logout: of(undefined),

projects/social_platform/src/app/ui/pages/auth/login/login.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("LoginComponent", () => {
1818
let fixture: ComponentFixture<LoginComponent>;
1919

2020
beforeEach(async () => {
21-
const authSpy = jasmine.createSpyObj("AuthRepository", ["login", "memTokens", "clearTokens"]);
21+
const authSpy = { login: vi.fn(), memTokens: vi.fn(), clearTokens: vi.fn() };
2222
const authPortSpy = {
2323
login: of({} as any),
2424
logout: of(undefined),

projects/social_platform/src/app/ui/pages/auth/register/register.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("RegisterComponent", () => {
1818
let fixture: ComponentFixture<RegisterComponent>;
1919

2020
beforeEach(async () => {
21-
const authSpy = jasmine.createSpyObj("AuthRepository", ["login", "memTokens", "clearTokens"]);
21+
const authSpy = { login: vi.fn(), memTokens: vi.fn(), clearTokens: vi.fn() };
2222
const authPortSpy = {
2323
login: of({} as any),
2424
logout: of(undefined),

projects/social_platform/src/app/ui/pages/auth/reset-password/reset-password.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("ResetPasswordComponent", () => {
1515
let fixture: ComponentFixture<ResetPasswordComponent>;
1616

1717
beforeEach(async () => {
18-
const authSpy = jasmine.createSpyObj({ resetPassword: of({}) });
18+
const authSpy = { resetPassword: vi.fn().mockReturnValue(of({})) };
1919
const authPortSpy = {
2020
login: of({} as any),
2121
logout: of(undefined),

projects/social_platform/src/app/ui/pages/auth/set-password/set-password.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("SetPasswordComponent", () => {
1515
let fixture: ComponentFixture<SetPasswordComponent>;
1616

1717
beforeEach(async () => {
18-
const authSpy = jasmine.createSpyObj({ setPassword: of({}) });
18+
const authSpy = { setPassword: vi.fn().mockReturnValue(of({})) };
1919
const authPortSpy = {
2020
login: of({} as any),
2121
logout: of(undefined),

projects/social_platform/src/app/ui/pages/chat/chat-direct/chat-direct.component.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ describe("ChatDirectComponent", () => {
2121
typingPersons: signal([]),
2222
chat: signal(undefined),
2323
messages: signal([]),
24-
initializationChatDirect: jasmine.createSpy("initializationChatDirect"),
25-
destroy: jasmine.createSpy("destroy"),
26-
onSubmitMessage: jasmine.createSpy("onSubmitMessage"),
27-
onEditMessage: jasmine.createSpy("onEditMessage"),
28-
onDeleteMessage: jasmine.createSpy("onDeleteMessage"),
29-
onFetchMessages: jasmine.createSpy("onFetchMessages"),
30-
onType: jasmine.createSpy("onType"),
31-
onReadMessage: jasmine.createSpy("onReadMessage"),
24+
initializationChatDirect: vi.fn(),
25+
destroy: vi.fn(),
26+
onSubmitMessage: vi.fn(),
27+
onEditMessage: vi.fn(),
28+
onDeleteMessage: vi.fn(),
29+
onFetchMessages: vi.fn(),
30+
onType: vi.fn(),
31+
onReadMessage: vi.fn(),
3232
};
3333

3434
const chatDirectUIInfoServiceSpy = {

projects/social_platform/src/app/ui/pages/chat/chat.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ describe("ChatComponent", () => {
1515
beforeEach(async () => {
1616
const chatInfoServiceSpy = {
1717
chats: of([]),
18-
initializationChats: jasmine.createSpy("initializationChats"),
19-
destroy: jasmine.createSpy("destroy"),
20-
onGotoChat: jasmine.createSpy("onGotoChat"),
18+
initializationChats: vi.fn(),
19+
destroy: vi.fn(),
20+
onGotoChat: vi.fn(),
2121
};
2222

2323
const chatUIInfoServiceSpy = {

projects/social_platform/src/app/ui/pages/courses/lesson/complete/complete.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function makeFakeRouteWithCourseId(courseId: string | null): ActivatedRoute {
2121
describe("TaskCompleteComponent", () => {
2222
let fixture: ComponentFixture<TaskCompleteComponent>;
2323
let component: TaskCompleteComponent;
24-
let routerSpy: jasmine.SpyObj<Router>;
24+
let routerSpy: any;
2525

2626
async function setup(courseId: string | null): Promise<void> {
27-
routerSpy = jasmine.createSpyObj<Router>("Router", ["navigateByUrl"]);
27+
routerSpy = { navigateByUrl: vi.fn() };
2828

2929
await TestBed.configureTestingModule({
3030
imports: [TaskCompleteComponent],
@@ -65,7 +65,7 @@ describe("TaskCompleteComponent", () => {
6565
await setup("7");
6666

6767
const button = fixture.debugElement.query(By.css("app-button"));
68-
expect(button).withContext("кнопка должна быть в DOM").toBeTruthy();
68+
expect(button, "кнопка должна быть в DOM").toBeTruthy();
6969

7070
button.triggerEventHandler("click", null);
7171

projects/social_platform/src/app/ui/pages/members/members-filters/members-filters.component.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ describe("MembersFiltersComponent ", () => {
1717
const searchesServiceSpy = {
1818
inlineSpecs: signal([]),
1919
inlineSkills: signal([]),
20-
onSearchSpec: jasmine.createSpy("onSearchSpec"),
21-
onSearchSkill: jasmine.createSpy("onSearchSkill"),
20+
onSearchSpec: vi.fn(),
21+
onSearchSkill: vi.fn(),
2222
};
2323

2424
const loggerServiceSpy = {
25-
info: jasmine.createSpy("info"),
25+
info: vi.fn(),
2626
};
2727

2828
await TestBed.configureTestingModule({

0 commit comments

Comments
 (0)