Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mtvspec/bffa07ef0420be53c31dbb02c78d1632 to your computer and use it in GitHub Desktop.
Save mtvspec/bffa07ef0420be53c31dbb02c78d1632 to your computer and use it in GitHub Desktop.
Test
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RealPropertyCommentListComponent } from './real-property-comment-list.component';
import { MessageService } from "primeng/api";
import { PrincipalService } from "@app/principal/service/principal.service";
import { DeviceService } from "@helpers/device.service";
import { DATA_MANAGER_URI, USER_MANAGER_URI, VIEW_MANAGER_URI } from "../../const";
import { environment } from "@environments/environment.prod";
import { NO_ERRORS_SCHEMA } from "@angular/core";
import { RealPropertyCommentListService } from "@modules/real-property-comments/real-property-comment-list.service";
import { of } from "rxjs";
import { HttpClientTestingModule } from "@angular/common/http/testing";
describe('RealPropertyCommentListComponent', () => {
let component: RealPropertyCommentListComponent;
let fixture: ComponentFixture<RealPropertyCommentListComponent>;
let fakeCommentsService: RealPropertyCommentListService;
beforeEach(async () => {
fakeCommentsService = jasmine.createSpyObj<RealPropertyCommentListService>('RealPropertyCommentListService', {
commentListRequestAction$: of([]),
commentList$: of([]),
commentTotalCount$: of(0),
commentListHasNextPage$: of(false),
});
await TestBed.configureTestingModule({
declarations: [
RealPropertyCommentListComponent,
],
imports: [
HttpClientTestingModule,
],
schemas: [
NO_ERRORS_SCHEMA,
],
providers: [
MessageService,
PrincipalService,
DeviceService,
{
provide: USER_MANAGER_URI,
useValue: environment.apiUserManagerUrl,
},
{
provide: VIEW_MANAGER_URI,
useValue: environment.apiViewManagerUrl,
},
{
provide: DATA_MANAGER_URI,
useValue: environment.apiDataManagerUrl,
},
{
provide: RealPropertyCommentListService,
useValue: fakeCommentsService,
},
],
})
.compileComponents();
fixture = TestBed.createComponent(RealPropertyCommentListComponent);
component = fixture.componentInstance;
(component.realPropertyId as any) = 7825;
fixture.detectChanges();
});
beforeEach(() => {
expect(component).toBeTruthy();
});
it('should fetch comment list', function () {
expect(component).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment