unit testing for ngAfterViewInit?

Discussão em 'Angular' iniciado por Ramesh vemula, Janeiro 27, 2025.

  1. I am new to writing unit test cases for angular. I have to write a test case for ngAfterViewInit. I don't know how to start. I am using angular 7.

    My component code:

    export class MyAccessComponent implements OnInit, AfterViewInit {

    // Spinner
    pageLoaded: boolean;
    @Input() diameter = 64;
    @Input() strokeWidth = 7;

    // Icons
    faEdit = faEdit;

    dataSource;
    @ViewChild(MatPaginator) paginator: MatPaginator;

    constructor(private router: Router, private userService: UserService) { }

    ngOnInit() {
    this.pageLoaded = false;
    // Data table init
    this.getUsers();
    }

    ngAfterViewInit() {
    setTimeout(() => {
    this.pageLoaded = true;
    }, 500);
    }
    }

    Continue reading...

Compartilhe esta Página