for enums that tends to change or grow, we write unit tests that iterate over enum and make sure all values are included.
Example could be as simple as:
describe('TodoStateI18n',()=>{letcomponent:TodoStateI18n;letfixture:ComponentFixture<TodoStateI18n>;beforeEach(()=>{TestBed.configureTestingModule({declarations:[TodoStateI18n,],}).compileComponents();});beforeEach(()=>{fixture=TestBed.createComponent(TodoStateI18n);component=fixture.componentInstance;});// regular specsit('should display correct text for TODO',()=>{component.value=TodoState.TODO;fixture.detectChanges();expect(fixture.nativeElement.textContent).toBe('not started');});// checking if everything is translated// Cannot be `const enum`Object.values(TodoState).forEach((value)=>{it(`should translate ${value}`,()=>{component.value=value;fixture.detectChanges();expect(fixture.nativeElement.textContent).not.toBe('unknown');});});});
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
for enums that tends to change or grow, we write unit tests that iterate over enum and make sure all values are included.
Example could be as simple as: