Skip to content
Snippets Groups Projects
Select Git revision
  • 0e7c7fc5a06770fedc185455b922e7833eaa5038
  • 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

odsh_form.js

Blame
  • build-info.component.spec.ts 3.64 KiB
    /*
     * Copyright (C) 2022 Das Land Schleswig-Holstein vertreten durch den
     * Ministerpräsidenten des Landes Schleswig-Holstein
     * Staatskanzlei
     * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
     *
     * Lizenziert unter der EUPL, Version 1.2 oder - sobald
     * diese von der Europäischen Kommission genehmigt wurden -
     * Folgeversionen der EUPL ("Lizenz");
     * Sie dürfen dieses Werk ausschließlich gemäß
     * dieser Lizenz nutzen.
     * Eine Kopie der Lizenz finden Sie hier:
     *
     * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
     *
     * Sofern nicht durch anwendbare Rechtsvorschriften
     * gefordert oder in schriftlicher Form vereinbart, wird
     * die unter der Lizenz verbreitete Software "so wie sie
     * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
     * ausdrücklich oder stillschweigend - verbreitet.
     * Die sprachspezifischen Genehmigungen und Beschränkungen
     * unter der Lizenz sind dem Lizenztext zu entnehmen.
     */
    import { FormatDateWithTimePipe } from '@alfa-client/tech-shared';
    import { registerLocaleData } from '@angular/common';
    import localeDe from '@angular/common/locales/de';
    import { ComponentFixture, TestBed } from '@angular/core/testing';
    import { createApiRootResource } from 'libs/api-root-shared/test/api-root';
    import { BuildInfoComponent } from './build-info.component';
    
    import * as DateUtil from '@alfa-client/tech-shared';
    
    registerLocaleData(localeDe);
    
    jest.mock('@alfa-client/tech-shared', () => mockAsEsModule('@alfa-client/tech-shared'));
    
    function mockAsEsModule(module: string) {
      return {
        __esModule: true,
        ...jest.requireActual(module),
      };
    }
    
    describe('BuildInfoComponent', () => {
      let component: BuildInfoComponent;
      let fixture: ComponentFixture<BuildInfoComponent>;
    
      beforeEach(async () => {
        await TestBed.configureTestingModule({
          imports: [BuildInfoComponent],
          declarations: [FormatDateWithTimePipe],
        }).compileComponents();
      });
    
      beforeEach(() => {
        fixture = TestBed.createComponent(BuildInfoComponent);
        component = fixture.componentInstance;
        component.apiRoot = createApiRootResource();
        fixture.detectChanges();
      });
    
      it('should create', () => {
        fixture.detectChanges();
        expect(component).toBeTruthy();
      });
    
      describe('isNotProduction', () => {
        it('should return true at non-production environment', () => {
          component.apiRoot.production = false;
    
          expect(component.isNotProduction).toBeTruthy();
        });
    
        it('should return false at production environment', () => {
          component.apiRoot.production = true;
    
          expect(component.isNotProduction).toBeFalsy();
        });
      });
    
      describe('isProduction', () => {
        it('should return false at non-production environment', () => {
          component.apiRoot.production = false;
    
          expect(component.isProduction).toBeFalsy();
        });
    
        it('should return true at production environment', () => {
          component.apiRoot.production = true;
    
          expect(component.isProduction).toBeTruthy();
        });
      });
    
      describe('version', () => {
        it('should return version fragment', () => {
          component.apiRoot.version = '1.12.0-SNAPSHOT';
    
          expect(component.version).toBe('1.12.0-SNAPSHOT');
        });
      });
    
      describe('buildDate', () => {
        it('should call formatFullDate', () => {
          const formatFullDate = jest.spyOn(DateUtil, 'formatFullDate');
    
          component.buildDate;
    
          expect(formatFullDate).toHaveBeenCalled();
        });
      });
    
      describe('buildTime', () => {
        it('should call formatHourMinute', () => {
          const formatHourMinute = jest.spyOn(DateUtil, 'formatHourMinute');
    
          component.buildTime;
    
          expect(formatHourMinute).toHaveBeenCalled();
        });
      });
    });