|
| 1 | +import { ComponentFixture, TestBed } from '@angular/core/testing'; |
| 2 | +import { provideNoopAnimations } from '@angular/platform-browser/animations'; |
| 3 | + |
| 4 | +import { PreprintWarningBannerComponent } from './preprint-warning-banner.component'; |
| 5 | + |
| 6 | +import { OSFTestingModule } from '@testing/osf.testing.module'; |
| 7 | + |
| 8 | +describe('PreprintWarningBannerComponent', () => { |
| 9 | + let component: PreprintWarningBannerComponent; |
| 10 | + let fixture: ComponentFixture<PreprintWarningBannerComponent>; |
| 11 | + |
| 12 | + beforeEach(async () => { |
| 13 | + await TestBed.configureTestingModule({ |
| 14 | + imports: [PreprintWarningBannerComponent, OSFTestingModule], |
| 15 | + providers: [provideNoopAnimations()], |
| 16 | + }).compileComponents(); |
| 17 | + |
| 18 | + fixture = TestBed.createComponent(PreprintWarningBannerComponent); |
| 19 | + component = fixture.componentInstance; |
| 20 | + fixture.detectChanges(); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should create', () => { |
| 24 | + expect(component).toBeTruthy(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should show correct icon and text', () => { |
| 28 | + const banner: HTMLElement = fixture.nativeElement; |
| 29 | + const icon = banner.querySelector('i'); |
| 30 | + const text = banner.querySelector('span'); |
| 31 | + expect(icon).toBeDefined(); |
| 32 | + expect(text).toBeDefined(); |
| 33 | + expect(icon?.getAttribute('ng-reflect-ng-class')).toEqual('fas fa-triangle-exclamation'); |
| 34 | + expect(text?.textContent?.trim()).toEqual('preprints.details.warningBanner'); |
| 35 | + }); |
| 36 | +}); |
0 commit comments