paperless-ngx/src-ui/src/app/components/common/logo/logo.component.spec.ts

48 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-08-08 23:59:13 -07:00
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { LogoComponent } from './logo.component'
import { By } from '@angular/platform-browser'
2024-01-13 11:57:25 -08:00
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { SettingsService } from 'src/app/services/settings.service'
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
2023-08-08 23:59:13 -07:00
describe('LogoComponent', () => {
let component: LogoComponent
let fixture: ComponentFixture<LogoComponent>
2024-01-13 11:57:25 -08:00
let settingsService: SettingsService
2023-08-08 23:59:13 -07:00
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [LogoComponent],
2024-01-13 11:57:25 -08:00
imports: [HttpClientTestingModule],
2023-08-08 23:59:13 -07:00
})
2024-01-13 11:57:25 -08:00
settingsService = TestBed.inject(SettingsService)
2023-08-08 23:59:13 -07:00
fixture = TestBed.createComponent(LogoComponent)
component = fixture.componentInstance
fixture.detectChanges()
})
it('should support extra classes', () => {
expect(fixture.debugElement.queryAll(By.css('.foo'))).toHaveLength(0)
component.extra_classes = 'foo'
fixture.detectChanges()
expect(fixture.debugElement.queryAll(By.css('.foo'))).toHaveLength(1)
})
it('should support setting height', () => {
2023-12-05 09:00:06 -08:00
expect(fixture.debugElement.query(By.css('svg')).attributes.style).toEqual(
'height:6em'
2023-08-08 23:59:13 -07:00
)
component.height = '10em'
fixture.detectChanges()
2023-12-05 09:00:06 -08:00
expect(fixture.debugElement.query(By.css('svg')).attributes.style).toEqual(
'height:10em'
2023-08-08 23:59:13 -07:00
)
})
2024-01-13 11:57:25 -08:00
it('should support getting custom logo', () => {
settingsService.set(SETTINGS_KEYS.APP_LOGO, '/logo/test.png')
expect(component.customLogo).toEqual('http://localhost:8000/logo/test.png')
})
2023-08-08 23:59:13 -07:00
})