Skip to content
Snippets Groups Projects
Select Git revision
  • e17cab6db63f2d27037f5954754624bd6087fa58
  • main default protected
  • OZG-8280-fitconnect
  • OZG-8217-AFM-InboxReference
  • release
  • OZG-8217-inbox-reference-identifier
  • develop
  • OZG-8075-NPE-wenn-der-Knoten-ORGID-leer-ist
  • OZG-7878-Resilienteres-Mapping-vom-AFM-Postfach-Address-Type
  • OZG-7144_extend_testfactory
  • OZG-7426-POC-DateitransferEingang
  • OZG-7144_orgid_lower_case
  • OZG-6922-reproduce-xdomea-bug
  • OZG-6710-Update-common-lib
  • OZG-6343-enable-dfoerdermittel-changes
  • OZG-6343-enable-dfoerdermittel
  • try-lasttests
  • formcycle-itcase-to-vorgangremoteservice
  • dfoerderfix
  • OZG-5156-Versammlungsanzeige-via-xta-adapter
  • OZG-5156-Anbindung-Versammlungsanzeige-2
  • 2.22.0
  • 2.21.0
  • 2.20.0
  • 2.19.0
  • 2.18.1
  • 2.18.0
  • 2.17.0
  • 2.16.0
  • 2.15.0
  • 2.14.0
  • 2.13.0
  • 2.12.0
  • 2.11.0
  • 2.10.0
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.0
  • 2.6.0
  • 2.5.0
41 results

EingangAspectPointcuts.java

Blame
  • snackbar.service.spec.ts 2.41 KiB
    import { MatSnackBar } from '@angular/material/snack-bar';
    import { CommandResource, CommandStatus } from '@goofy-client/command-shared';
    import { Mock, mock, useFromMock } from '@goofy-client/test-utils';
    import * as faker from 'faker';
    import { createCommandResource } from 'libs/command-shared/test/command';
    import { SnackbarErrorComponent } from './snackbar-error/snackbar-error.component';
    import { SnackbarComponent } from './snackbar.component';
    import { SnackBarService } from './snackbar.service';
    
    describe('SnackBarService', () => {
    	let service: SnackBarService;
    	let snackBar: Mock<MatSnackBar>;
    
    	const commandResource: CommandResource = createCommandResource();
    	const message: string = faker.lorem.words(5);
    
    	beforeEach(() => {
    		snackBar = mock(MatSnackBar);
    
    		service = new SnackBarService(useFromMock(snackBar));
    	})
    
    	it('should create', () => {
    		expect(service).toBeDefined();
    	})
    
    	describe('show', () => {
    
    		beforeEach(() => {
    			service.listenOnRevokeAction = jest.fn();
    			service.listenOnAfterDismissed = jest.fn();
    		})
    
    		it('should open from component', () => {
    			service.show(commandResource, message);
    
    			expect(snackBar.openFromComponent).toHaveBeenCalledWith(SnackbarComponent, {
    				data: { message, commandResource }, duration: 10000
    			});
    		})
    
    		it('should listen to snackbar revoke action', () => {
    			service.show(commandResource, message, null);
    
    			expect(service.listenOnRevokeAction).toHaveBeenCalledWith(null);
    		})
    
    		it('should listen to snackbar after dismissed', () => {
    			service.show(commandResource, message, null);
    
    			expect(service.listenOnAfterDismissed).toHaveBeenCalled();
    		})
    
    		it('should open error snackbar when status is ERROR', () => {
    			const commandWithError = { ...commandResource, status: CommandStatus.ERROR}
    			service.show(commandWithError, message, null);
    
    			expect(snackBar.openFromComponent).toHaveBeenCalledWith(SnackbarErrorComponent, {
    				data: { message }, duration: 10000
    			});
    		});
    	})
    
    	describe('show error', () => {
    
    		beforeEach(() => {
    			service.listenOnAfterDismissed = jest.fn();
    		})
    
    		it('should open from component', () => {
    			service.showError(message);
    
    			expect(snackBar.openFromComponent).toHaveBeenCalledWith(SnackbarErrorComponent, {
    				data: { message }, duration: 10000
    			});
    		})
    
    		it('should listen to snackbar after dismissed', () => {
    			service.showError(message);
    
    			expect(service.listenOnAfterDismissed).toHaveBeenCalled();
    		})
    	})
    })