-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.component.spec.ts
72 lines (65 loc) · 2.64 KB
/
list.component.spec.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { PRIVATE_PATHS } from "@private/private-routing-constants";
import { RouterTestingModule } from "@angular/router/testing";
import { ButtonComponent } from "@shared/button/button.component";
import { FeatureFlagServiceMock } from "@fixtures/feature-flag.fixtures.spec";
import { CatalogManagerApiService } from "@api/catalog-manager/catalog-manager-api.service";
import {
MOCK_SUBSCRIPTION_SLOTS,
MOCK_SUBSCRIPTION_SLOT_CARS,
} from "@fixtures/subscription-slots.fixtures.spec";
import { ListingLimitService } from "@core/subscriptions/listing-limit/listing-limit.service";
import { ListingLimitServiceMock } from "@fixtures/private/pros/listing-limit.fixtures.spec";
import { ProModalComponent } from "@shared/modals/pro-modal/pro-modal.component";
import { MeApiService } from "@api/me/me-api.service";
import { BUMPS_PATHS } from "@private/features/bumps/bumps-routing-constants";
import { CatalogItemTrackingEventService } from "../../core/services/catalog-item-tracking-event.service";
import { VisibilityApiService } from "@api/visibility/visibility-api.service";
import { EmptyStateComponentStub } from "@fixtures/shared/components/empty-state.component.stub";
describe("ListComponent", () => {
let component: ListComponent;
let fixture: ComponentFixture<ListComponent>;
const prosButtonSelector = ".List__button--pros";
const deliveryButtonSelector = ".List__button--delivery";
const walletButtonSelector = ".List__button--wallet";
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HttpModule],
declarations: [
ListComponent,
ItemSoldDirective,
SubscriptionsSlotsListComponent,
SubscriptionsSlotItemComponent,
TryProSlotComponent,
ProBadgeComponent,
ButtonComponent,
EmptyStateComponentStub,
],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
describe("ngOnInit", () => {
it("should reset page on router event", fakeAsync(() => {
spyOn<any>(component, "getItems");
component["nextPage"] = "40";
component.end = true;
component.ngOnInit();
tick();
router.navigate([""]);
tick();
expect(component.scrollTop).toBe(0);
expect(component["nextPage"]).toBe(null);
expect(component.end).toBeFalsy();
expect(component["getItems"]).toHaveBeenCalledTimes(2);
}));
});
describe("when clicking the button", () => {
it("should open modal", () => {
component.openModal();
expect(component.modalOpened).toBe(true);
});
});
});