Skip to content
Snippets Groups Projects
Select Git revision
  • 13224fd2fb4a0ab60d7b27a8af00b822d2804ad7
  • master default protected
  • add-frequency-to-form
  • dev protected
  • ckan-2.11.0
  • add-package-custom-fields
  • fix-adding-datasets-for-users-and-editors
  • add-auth-subroute
  • 71-migrate-custom-fields-to-ckanext-scheming
  • add-author-maintainer-information
  • fix-inline-flex-btns
  • fix-known-spatial-uri-validation
  • py3
  • 47-aktuelle-resource-einer-collection-wird-nicht-mehr-gefunden
  • 10-eingabe-der-dct-accrualperiodicity-in-weboberflache
  • v1.3
  • 2.5.3
  • 2.5.2
  • 2.5.1
  • 2.5.0
  • 2.4.7
  • 2.4.6
  • 2.4.5
  • 2.4.4
  • 2.4.3
  • 2.4.2
  • 2.4.1
  • 2.4.0
  • 2.3.1
  • 2.3.0
  • 2.2.0
  • 2.1.0
  • 2.0.0
  • 1.4.3
  • 1.4.2
  • 1.4.1
36 results

setup.py

Blame
  • user-profile-button-container.component.spec.ts 2.52 KiB
    import {
      dispatchEventFromFixture,
      getElementFromFixture,
      mock,
      Mock,
    } from '@alfa-client/test-utils';
    import { ComponentFixture, TestBed } from '@angular/core/testing';
    import { RouterTestingModule } from '@angular/router/testing';
    import { LogoutIconComponent, PopupComponent, PopupListItemComponent } from '@ods/system';
    import { AuthenticationService } from 'authentication';
    import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
    import { MockComponent } from 'ng-mocks';
    import { UserProfileButtonContainerComponent } from './user-profile.button-container.component';
    
    describe('UserProfileButtonContainerComponent', () => {
      let component: UserProfileButtonContainerComponent;
      let fixture: ComponentFixture<UserProfileButtonContainerComponent>;
    
      const authenticationService: Mock<AuthenticationService> = mock(AuthenticationService);
    
      const popupButtonContent: string = getDataTestIdOf('popup-button-content');
      const popupLogoutButton: string = getDataTestIdOf('popup-logout-button');
    
      beforeEach(async () => {
        await TestBed.configureTestingModule({
          declarations: [UserProfileButtonContainerComponent],
          imports: [
            RouterTestingModule,
            MockComponent(PopupComponent),
            MockComponent(PopupListItemComponent),
            MockComponent(LogoutIconComponent),
          ],
          providers: [
            {
              provide: AuthenticationService,
              useValue: authenticationService,
            },
          ],
        }).compileComponents();
      });
    
      beforeEach(() => {
        fixture = TestBed.createComponent(UserProfileButtonContainerComponent);
        component = fixture.componentInstance;
        fixture.detectChanges();
      });
    
      it('should create', () => {
        expect(component).toBeTruthy();
      });
    
      describe('ngOnInit', () => {
        it('should call authService to get current user initials', () => {
          component.ngOnInit();
    
          expect(authenticationService.getCurrentUserInitials).toHaveBeenCalled();
        });
      });
    
      describe('popup button', () => {
        it('should show initials', () => {
          component.currentUserInitials = 'AV';
          fixture.detectChanges();
    
          const popupButtonContentElement: HTMLElement = getElementFromFixture(
            fixture,
            popupButtonContent,
          );
    
          expect(popupButtonContentElement.textContent.trim()).toEqual('AV');