|
| 1 | +/* eslint-disable @typescript-eslint/naming-convention */ |
| 2 | +import { Component, Inject, OnInit } from '@angular/core'; |
| 3 | +import { render, screen } from '@testing-library/angular'; |
| 4 | +import { createMock } from '@testing-library/angular/jest-utils'; |
| 5 | + |
| 6 | +interface Division { |
| 7 | + JobType: string; |
| 8 | + JobBullets: string[]; |
| 9 | + Description: string; |
| 10 | +} |
| 11 | + |
| 12 | +@Inject({ |
| 13 | + providedIn: 'root', |
| 14 | +}) |
| 15 | +class JobsService { |
| 16 | + divisions(): Promise<Division[]> { |
| 17 | + throw new Error('Method not implemented.'); |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +@Component({ |
| 22 | + selector: 'app-home-career-oportunities', |
| 23 | + template: ` <ul class="popu-category-bullets"> |
| 24 | + <li class="text-dark" *ngFor="let bullet of dedicated.JobBullets"> |
| 25 | + {{ bullet }} |
| 26 | + </li> |
| 27 | + </ul>`, |
| 28 | +}) |
| 29 | +class CareerOportunitiesComponent implements OnInit { |
| 30 | + dedicated = {} as Division; |
| 31 | + intermodal = {} as Division; |
| 32 | + noCdl = {} as Division; |
| 33 | + otr = {} as Division; |
| 34 | + |
| 35 | + constructor(private jobsService: JobsService) {} |
| 36 | + |
| 37 | + ngOnInit(): void { |
| 38 | + this.jobsService.divisions().then((apiDivisions) => { |
| 39 | + this.dedicated = apiDivisions.find((c) => c.JobType === 'DEDICATED'); |
| 40 | + this.intermodal = apiDivisions.find((c) => c.JobType === 'INTERMODAL'); |
| 41 | + this.noCdl = apiDivisions.find((c) => c.JobType === 'NO_CDL'); |
| 42 | + this.otr = apiDivisions.find((c) => c.JobType === 'OVER_THE_ROAD'); |
| 43 | + }); |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +test('Render Component', async () => { |
| 48 | + const divisions2: Division[] = [ |
| 49 | + { |
| 50 | + JobType: 'INTERMODAL', |
| 51 | + JobBullets: ['Local Routes', 'Flexible Schedules', 'Competitive Pay'], |
| 52 | + Description: '', |
| 53 | + }, |
| 54 | + { JobType: 'NO_CDL', JobBullets: ['We Train', 'We Hire', 'We Pay'], Description: '' }, |
| 55 | + { |
| 56 | + JobType: 'OVER_THE_ROAD', |
| 57 | + JobBullets: ['Great Miles', 'Competitive Pay', 'Explore the Country'], |
| 58 | + Description: '', |
| 59 | + }, |
| 60 | + { |
| 61 | + JobType: 'DEDICATED', |
| 62 | + JobBullets: ['Regular Routes', 'Consistent Miles', 'Great Pay'], |
| 63 | + Description: '', |
| 64 | + }, |
| 65 | + ]; |
| 66 | + const jobService = createMock(JobsService); |
| 67 | + jobService.divisions = jest.fn(() => Promise.resolve(divisions2)); |
| 68 | + |
| 69 | + await render(CareerOportunitiesComponent, { |
| 70 | + componentProviders: [ |
| 71 | + { |
| 72 | + provide: JobsService, |
| 73 | + useValue: jobService, |
| 74 | + }, |
| 75 | + ], |
| 76 | + }); |
| 77 | + await screen.findAllByRole('listitem'); |
| 78 | +}); |
0 commit comments