users-page.component.spec.ts 1.52 KB
Newer Older
1
import { async, ComponentFixture, TestBed } from '@angular/core/testing'
2

3
import { UsersPageComponent } from './users-page.component'
4 5 6 7 8
import { ActivatedRoute, Router } from '@angular/router'
import { FormBuilder } from '@angular/forms'
import { UsersService } from '../backend'
import { HttpClient, HttpHandler } from '@angular/common/http'
import { MessageService } from 'primeng/api'
9
import { of } from 'rxjs'
10

11 12 13 14 15 16
class MockParamMap {
    get(name: string): string | null {
        return null
    }
}

17
describe('UsersPageComponent', () => {
18 19
    let component: UsersPageComponent
    let fixture: ComponentFixture<UsersPageComponent>
20

21 22
    beforeEach(async(() => {
        TestBed.configureTestingModule({
23
            imports: [],
24
            declarations: [UsersPageComponent],
25 26 27 28 29 30 31 32 33
            providers: [
                FormBuilder,
                UsersService,
                HttpClient,
                HttpHandler,
                MessageService,
                {
                    provide: ActivatedRoute,
                    useValue: {
34
                        paramMap: of(new MockParamMap()),
35 36 37 38 39 40 41
                    },
                },
                {
                    provide: Router,
                    useValue: {},
                },
            ],
42 43
        }).compileComponents()
    }))
44

45 46 47 48 49
    beforeEach(() => {
        fixture = TestBed.createComponent(UsersPageComponent)
        component = fixture.componentInstance
        fixture.detectChanges()
    })
50

51 52 53 54
    it('should create', () => {
        expect(component).toBeTruthy()
    })
})