Newer
Older
///
/// 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.
///
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PostfachMailListResource, PostfachNachrichtenCount } from '@goofy-client/postfach-shared';
import { getElementFromFixture } from '@goofy-client/test-utils';
import { ButtonWithSpinnerComponent } from '@goofy-client/ui';
import { createPostfachMailListResource } from 'libs/postfach-shared/test/postfach';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { MockComponent } from 'ng-mocks';
import { PostfachMailPdfButtonComponent } from './postfach-mail-pdf-button.component';
describe('PostfachMailPdfButtonComponent', () => {
let component: PostfachMailPdfButtonComponent;
let fixture: ComponentFixture<PostfachMailPdfButtonComponent>;
const pdfExportButton: string = getDataTestIdOf('postfach-pdf-export-button');
const pdfExportLabelButton: string = getDataTestIdOf('postfach-pdf-export-label-button');
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
PostfachMailPdfButtonComponent,
MockComponent(ButtonWithSpinnerComponent)
],
}).compileComponents();
fixture = TestBed.createComponent(PostfachMailPdfButtonComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('set postfachMailListResource', () => {
const postfachMailListResource: PostfachMailListResource = createPostfachMailListResource();
it('should set label', () => {
component.setLabel = jest.fn()
component.postfachMailListResource = postfachMailListResource;
expect(component.setLabel).toHaveBeenCalled();
})
it('should set postfachMailCount', () => {
component.setPostfachMailCount = jest.fn()
component.postfachMailListResource = postfachMailListResource
expect(component.setPostfachMailCount).toHaveBeenCalledWith(postfachMailListResource);
})
})
describe('setLabel', () => {
it('should not set if no mails exists', () => {
component.postfachMailCount = PostfachNachrichtenCount.NONE;
component.setLabel();
expect(component.label).toBeUndefined();
})
it('should set for single mail exists', () => {
component.postfachMailCount = PostfachNachrichtenCount.SINGLE;
component.setLabel();
expect(component.label).toBe('Nachricht exportieren');
})
it('should set for multiple mails exists', () => {
component.postfachMailCount = PostfachNachrichtenCount.MULTIPLE;
component.setLabel();
expect(component.label).toBe('Nachrichten exportieren');
})
})
describe('export button with label', () => {
it('should show on existing emails and showButtoWithLabel true', () => {
component.postfachMailCount = PostfachNachrichtenCount.SINGLE;
component.showButtonWithLabel = true;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportButton);
expect(element).toBeInTheDocument();
})
it('should hide on non existing emails', () => {
component.postfachMailCount = PostfachNachrichtenCount.NONE;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportButton);
expect(element).not.toBeInTheDocument();
})
it('should hide showButtonWithLabel false', () => {
component.postfachMailCount = PostfachNachrichtenCount.SINGLE;
component.showButtonWithLabel = false;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportButton);
expect(element).not.toBeInTheDocument();
})
})
describe('export button', () => {
it('should show on existing emails and showButtoWithLabel false', () => {
component.postfachMailCount = PostfachNachrichtenCount.SINGLE;
component.showButtonWithLabel = false;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportLabelButton);
expect(element).toBeInTheDocument();
})
it('should hide on non existing emails', () => {
component.postfachMailCount = PostfachNachrichtenCount.NONE;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportLabelButton);
expect(element).not.toBeInTheDocument();
})
it('should hide showButtonWithLabel true', () => {
component.postfachMailCount = PostfachNachrichtenCount.SINGLE;
component.showButtonWithLabel = true;
fixture.detectChanges();
const element = getElementFromFixture(fixture, pdfExportLabelButton);
expect(element).not.toBeInTheDocument();
})
})
});