@cauca-911/material 21.0.1-beta.4 → 21.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +79 -0
- package/README_PACKAGE.md +5 -0
- package/cauca-911-material-21.0.0.tgz +0 -0
- package/karma.conf.js +50 -0
- package/ng-package.json +7 -0
- package/package.json +23 -38
- package/src/assets/i18n/cauca/en-material.json +104 -0
- package/src/assets/i18n/cauca/es-material.json +104 -0
- package/src/assets/i18n/cauca/fr-material.json +106 -0
- package/src/assets/images/loading.gif +0 -0
- package/src/lib/cauca-material.component.html +1 -0
- package/src/lib/cauca-material.component.spec.ts +29 -0
- package/src/lib/cauca-material.component.ts +12 -0
- package/src/lib/cauca-material.service.spec.ts +16 -0
- package/src/lib/cauca-material.service.ts +7 -0
- package/src/lib/components/button/button.component.html +52 -0
- package/src/lib/components/button/button.component.scss +6 -0
- package/src/lib/components/button/button.component.spec.ts +142 -0
- package/src/lib/components/button/button.component.ts +22 -0
- package/src/lib/components/buttons/base-button.ts +35 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.html +5 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.scss +12 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/basic-button/basic-button.component.ts +17 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.html +3 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.scss +12 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.spec.ts +82 -0
- package/src/lib/components/buttons/fab-button/fab-button.component.ts +16 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.html +5 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.scss +12 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.spec.ts +106 -0
- package/src/lib/components/buttons/flat-button/flat-button.component.ts +17 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.html +3 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.scss +23 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.spec.ts +38 -0
- package/src/lib/components/buttons/icon-button/icon-button.component.ts +15 -0
- package/src/lib/components/buttons/link-button/link-button.component.html +1 -0
- package/src/lib/components/buttons/link-button/link-button.component.scss +3 -0
- package/src/lib/components/buttons/link-button/link-button.component.spec.ts +97 -0
- package/src/lib/components/buttons/link-button/link-button.component.ts +25 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.html +5 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.scss +6 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.spec.ts +66 -0
- package/src/lib/components/buttons/menu-item/menu-item.component.ts +19 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.html +5 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.scss +12 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.spec.ts +108 -0
- package/src/lib/components/buttons/raised-button/raised-button.component.ts +17 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.html +1 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.scss +0 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.spec.ts +81 -0
- package/src/lib/components/buttons/refresh-button/refresh-button.component.ts +19 -0
- package/src/lib/components/buttons/round-button/round-button.component.html +3 -0
- package/src/lib/components/buttons/round-button/round-button.component.scss +34 -0
- package/src/lib/components/buttons/round-button/round-button.component.spec.ts +26 -0
- package/src/lib/components/buttons/round-button/round-button.component.ts +14 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.html +5 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.scss +23 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.spec.ts +114 -0
- package/src/lib/components/buttons/stroked-button/stroked-button.component.ts +17 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.scss +7 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.spec.ts +68 -0
- package/src/lib/components/cauca-date-time-picker/cauca-date-time-picker.component.ts +155 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.html +6 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.scss +25 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.spec.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/desktop-time-picker/desktop-time-picker.component.ts +23 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.html +77 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.scss +124 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.spec.ts +96 -0
- package/src/lib/components/cauca-date-time-picker/components/dialog-date-time-picker/dialog-date-time-picker.component.ts +228 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.html +9 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.scss +15 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.spec.ts +105 -0
- package/src/lib/components/cauca-date-time-picker/components/mobile-time-picker/mobile-time-picker.component.ts +48 -0
- package/src/lib/components/cauca-date-time-picker/models/dialog-date-time-picker-data.ts +29 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.html +14 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-file/cauca-input-file.component.ts +87 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.html +12 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.scss +3 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.spec.ts +35 -0
- package/src/lib/components/deprecated-components/cauca-input-multiple-langue/cauca-input-multiple-langue.component.ts +57 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.html +49 -0
- package/src/lib/components/deprecated-components/cauca-menu-vertical/cauca-menu-vertical.component.ts +56 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.html +11 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.scss +4 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.spec.ts +39 -0
- package/src/lib/components/deprecated-components/cauca-simple-dialog/cauca-simple-dialog.component.ts +20 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.html +7 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.scss +41 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.spec.ts +24 -0
- package/src/lib/components/deprecated-components/cauca-slideshow/cauca-slideshow.component.ts +67 -0
- package/src/lib/components/deprecated-components/shared/models/menu-item.ts +11 -0
- package/src/lib/components/deprecated-components/shared/models/simple-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.html +10 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.spec.ts +90 -0
- package/src/lib/components/dialogs/alert-dialog/alert-dialog.component.ts +41 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.html +11 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.scss +29 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.spec.ts +137 -0
- package/src/lib/components/dialogs/confirm-dialog/confirm-dialog.component.ts +47 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.html +17 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.scss +14 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.spec.ts +96 -0
- package/src/lib/components/dialogs/delete-dialog/delete-dialog.component.ts +40 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.spec.ts +7 -0
- package/src/lib/components/dialogs/delete-dialog/models/delete-dialog-data.ts +5 -0
- package/src/lib/components/dialogs/dialog-styles.css +9 -0
- package/src/lib/components/dialogs/dialog-styles.scss +9 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.html +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.scss +10 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.spec.ts +91 -0
- package/src/lib/components/dialogs/error-dialog/error-dialog.component.ts +32 -0
- package/src/lib/components/dialogs/services/dialog.service.spec.ts +82 -0
- package/src/lib/components/dialogs/services/dialog.service.ts +107 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.html +24 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.scss +22 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.spec.ts +126 -0
- package/src/lib/components/dialogs/text-input-dialog/text-input-dialog.component.ts +66 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.html +9 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.scss +0 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.spec.ts +29 -0
- package/src/lib/components/inputs/color-picker/color-picker.component.ts +111 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.html +13 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.scss +0 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.spec.ts +80 -0
- package/src/lib/components/inputs/date-range-picker/date-range-picker.component.ts +46 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.html +40 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.scss +39 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.spec.ts +135 -0
- package/src/lib/components/inputs/dropdown-chip-autocomplete/dropdown-chip-autocomplete.component.ts +263 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.html +6 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.scss +27 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.spec.ts +90 -0
- package/src/lib/components/inputs/password/password-criteria/password-criteria.component.ts +17 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.html +5 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.scss +8 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.spec.ts +98 -0
- package/src/lib/components/inputs/password/password-criteria-viewer/password-criteria-viewer.component.ts +16 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.html +11 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.scss +12 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.spec.ts +141 -0
- package/src/lib/components/inputs/password/password-input/password-input.component.ts +67 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.html +15 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.scss +32 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.spec.ts +138 -0
- package/src/lib/components/inputs/password/password-selection/password-selection.component.ts +101 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.html +19 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.scss +0 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.spec.ts +215 -0
- package/src/lib/components/inputs/select-with-search/select-with-search.component.ts +108 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.html +14 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.scss +48 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.spec.ts +48 -0
- package/src/lib/components/layout/expandable-panel/expandable-panel.component.ts +19 -0
- package/src/lib/components/layout/group-container/group-container.component.html +6 -0
- package/src/lib/components/layout/group-container/group-container.component.scss +22 -0
- package/src/lib/components/layout/group-container/group-container.component.spec.ts +34 -0
- package/src/lib/components/layout/group-container/group-container.component.ts +14 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.html +13 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.scss +27 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.spec.ts +144 -0
- package/src/lib/components/layout/menu-expandable-panel/menu-expandable-panel.component.ts +52 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.html +4 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.scss +10 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.spec.ts +80 -0
- package/src/lib/components/layout/menu-expandable-panel-item/menu-expandable-panel-item.component.ts +28 -0
- package/src/lib/components/layout/page-title/page-title.component.html +28 -0
- package/src/lib/components/layout/page-title/page-title.component.scss +40 -0
- package/src/lib/components/layout/page-title/page-title.component.spec.ts +162 -0
- package/src/lib/components/layout/page-title/page-title.component.ts +28 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.html +6 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.scss +27 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.spec.ts +42 -0
- package/src/lib/components/layout/sections/main-section/main-section.component.ts +13 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.html +3 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.scss +18 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.spec.ts +35 -0
- package/src/lib/components/layout/sections/section-column/section-column.component.ts +12 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.html +21 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.scss +44 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.spec.ts +74 -0
- package/src/lib/components/layout/sections/section-field/section-field.component.ts +22 -0
- package/src/lib/components/list-paginator/list-paginator.component.html +16 -0
- package/src/lib/components/list-paginator/list-paginator.component.scss +46 -0
- package/src/lib/components/list-paginator/list-paginator.component.spec.ts +248 -0
- package/src/lib/components/list-paginator/list-paginator.component.ts +81 -0
- package/src/lib/components/misc/loading-error/loading-error.component.html +11 -0
- package/src/lib/components/misc/loading-error/loading-error.component.scss +0 -0
- package/src/lib/components/misc/loading-error/loading-error.component.spec.ts +75 -0
- package/src/lib/components/misc/loading-error/loading-error.component.ts +18 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.html +3 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.scss +0 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.spec.ts +43 -0
- package/src/lib/components/misc/loading-spinner-indicator/loading-spinner-indicator.component.ts +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.html +16 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.scss +84 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.spec.ts +136 -0
- package/src/lib/components/misc/snack-bar/snack-bar.component.ts +39 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.html +11 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.spec.ts +67 -0
- package/src/lib/components/notifications/saving-confirmed-box/saving-confirmed-box.component.ts +15 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.html +11 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.scss +0 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.spec.ts +77 -0
- package/src/lib/components/notifications/saving-error-box/saving-error-box.component.ts +17 -0
- package/src/lib/components/presenters/badge/badge.component.html +6 -0
- package/src/lib/components/presenters/badge/badge.component.scss +10 -0
- package/src/lib/components/presenters/badge/badge.component.spec.ts +41 -0
- package/src/lib/components/presenters/badge/badge.component.ts +18 -0
- package/src/lib/components/presenters/icon/icon.component.scss +9 -0
- package/src/lib/components/presenters/icon/icon.component.spec.ts +38 -0
- package/src/lib/components/presenters/icon/icon.component.ts +37 -0
- package/src/lib/core/breadcrumb.service.spec.ts +35 -0
- package/src/lib/core/breadcrumb.service.ts +24 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.spec.ts +22 -0
- package/src/lib/core/directives/auto-trim-and-lower.directive.ts +19 -0
- package/src/lib/core/directives/form-error/form-error.module.ts +21 -0
- package/src/lib/core/directives/form-error/has-error-root.directive.ts +31 -0
- package/src/lib/core/directives/form-error/has-error.directive.ts +95 -0
- package/src/lib/core/loading-state.service.spec.ts +57 -0
- package/src/lib/core/loading-state.service.ts +44 -0
- package/src/lib/core/models/breadcrumb-location.ts +6 -0
- package/src/lib/core/models/password-validation.ts +20 -0
- package/src/lib/core/validators/password/password-validator.spec.ts +155 -0
- package/src/lib/core/validators/password/password-validator.ts +30 -0
- package/src/lib/provide-cauca-material.ts +10 -0
- package/src/public-api.ts +70 -0
- package/src/test.ts +17 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +4 -0
- package/tsconfig.spec.json +17 -0
- package/fesm2022/cauca-911-material.mjs +0 -4323
- package/fesm2022/cauca-911-material.mjs.map +0 -1
- package/types/cauca-911-material.d.ts +0 -755
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { BadgeComponent } from './badge.component';
|
|
4
|
+
import { MockModule, MockPipe } from 'ng-mocks';
|
|
5
|
+
import { TranslateModule, TranslatePipe } from '@ngx-translate/core';
|
|
6
|
+
|
|
7
|
+
describe('BadgeComponent', () => {
|
|
8
|
+
let component: BadgeComponent;
|
|
9
|
+
let fixture: ComponentFixture<BadgeComponent>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await TestBed.configureTestingModule({
|
|
13
|
+
imports: [BadgeComponent, MockModule(TranslateModule)],
|
|
14
|
+
declarations: [MockPipe(TranslatePipe, value => value)],
|
|
15
|
+
})
|
|
16
|
+
.compileComponents();
|
|
17
|
+
|
|
18
|
+
fixture = TestBed.createComponent(BadgeComponent);
|
|
19
|
+
fixture.componentRef.setInput('color', 'primary');
|
|
20
|
+
fixture.componentRef.setInput('label', 'readOnly');
|
|
21
|
+
fixture.componentRef.setInput('icon', 'visibility');
|
|
22
|
+
component = fixture.componentInstance;
|
|
23
|
+
fixture.detectChanges();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should create', () => {
|
|
27
|
+
expect(component).toBeTruthy();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should set the badge color', async () => {
|
|
31
|
+
expect(component.color()).toBe('primary');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should set the badge label', async () => {
|
|
35
|
+
expect(fixture.nativeElement.querySelector('.chip-label').textContent).toBe('readOnly');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should set the badge icon', async () => {
|
|
39
|
+
expect(fixture.nativeElement.querySelector('.mat-icon').textContent).toBe('visibility');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
import { MatChipsModule } from '@angular/material/chips';
|
|
3
|
+
import { MatIcon } from '@angular/material/icon';
|
|
4
|
+
import { TranslateModule } from '@ngx-translate/core';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'cauca-badge',
|
|
8
|
+
standalone: true,
|
|
9
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
10
|
+
imports: [TranslateModule, MatChipsModule, MatIcon],
|
|
11
|
+
templateUrl: './badge.component.html',
|
|
12
|
+
styleUrl: './badge.component.scss'
|
|
13
|
+
})
|
|
14
|
+
export class BadgeComponent {
|
|
15
|
+
public icon = input.required<string>();
|
|
16
|
+
public label = input.required<string>();
|
|
17
|
+
public color = input<string>('primary');
|
|
18
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { IconComponent } from './icon.component';
|
|
4
|
+
|
|
5
|
+
describe('IconComponent', () => {
|
|
6
|
+
let component: IconComponent;
|
|
7
|
+
let fixture: ComponentFixture<IconComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ IconComponent ]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(IconComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should set faIcon when icon is fontawesome', () => {
|
|
25
|
+
component.icon = 'fas running';
|
|
26
|
+
|
|
27
|
+
expect(component.isFontAwesome).toBe(true);
|
|
28
|
+
expect(component.faIcon).toEqual(['fas','running']);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should set image when icon is not fontawesome', () => {
|
|
32
|
+
component.icon = 'aImage';
|
|
33
|
+
|
|
34
|
+
expect(component.isFontAwesome).toBe(false);
|
|
35
|
+
expect(component.image).toEqual('aImage');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component, Input } from '@angular/core';
|
|
2
|
+
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'cauca-icon',
|
|
6
|
+
standalone: true,
|
|
7
|
+
imports: [FontAwesomeModule],
|
|
8
|
+
template: `
|
|
9
|
+
@if (isFontAwesome && faIcon && faIcon.length > 0) {
|
|
10
|
+
<div class="icon">
|
|
11
|
+
<fa-icon [icon]="faIcon"></fa-icon>
|
|
12
|
+
</div>
|
|
13
|
+
}
|
|
14
|
+
@if (!isFontAwesome && image) {
|
|
15
|
+
<div class="icon">
|
|
16
|
+
<img [src]="image" alt="icon" />
|
|
17
|
+
</div>
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
styleUrls: ['./icon.component.scss']
|
|
21
|
+
})
|
|
22
|
+
export class IconComponent {
|
|
23
|
+
public isFontAwesome: boolean = false;
|
|
24
|
+
public faIcon: string[] = [];
|
|
25
|
+
public image: string = '';
|
|
26
|
+
|
|
27
|
+
@Input()
|
|
28
|
+
public set icon(value: string) {
|
|
29
|
+
if (value && value.indexOf(' ') > -1) {
|
|
30
|
+
this.isFontAwesome = true;
|
|
31
|
+
this.faIcon = value.split(' ');
|
|
32
|
+
} else {
|
|
33
|
+
this.isFontAwesome = false;
|
|
34
|
+
this.image = value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { BreadcrumbService } from './breadcrumb.service';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe('BreadcrumbService', () => {
|
|
6
|
+
let service: BreadcrumbService;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
TestBed.configureTestingModule({
|
|
10
|
+
providers: [BreadcrumbService]
|
|
11
|
+
});
|
|
12
|
+
service = TestBed.inject(BreadcrumbService);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should be created', () => {
|
|
16
|
+
expect(service).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should show breadcrumb with correct values', () => {
|
|
20
|
+
const breadcrumb = 'Home';
|
|
21
|
+
const location = [{ link: '/home', title: 'Home' }];
|
|
22
|
+
|
|
23
|
+
service.show(breadcrumb, location);
|
|
24
|
+
|
|
25
|
+
expect(service.showBreadcrumb()).toBe(true);
|
|
26
|
+
expect(service.breadcrumb()).toBe(breadcrumb);
|
|
27
|
+
expect(service.location()).toEqual(location);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should hide breadcrumb', () => {
|
|
31
|
+
service.hide();
|
|
32
|
+
|
|
33
|
+
expect(service.showBreadcrumb()).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { computed, Injectable, Signal, signal, WritableSignal } from '@angular/core';
|
|
2
|
+
import { BreadcrumbLocation } from './models/breadcrumb-location';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class BreadcrumbService {
|
|
6
|
+
public showBreadcrumb: Signal<boolean> = computed(() => this.isShown());
|
|
7
|
+
|
|
8
|
+
public location: WritableSignal<BreadcrumbLocation[]> = signal([]);
|
|
9
|
+
public breadcrumb: WritableSignal<string> = signal('');
|
|
10
|
+
public translateBreadcrumb = signal<boolean>(false);
|
|
11
|
+
|
|
12
|
+
private readonly isShown: WritableSignal<boolean> = signal(false);
|
|
13
|
+
|
|
14
|
+
public show(breadcrumb: string, location: BreadcrumbLocation[] = [], translateBreadcrumb: boolean = true): void {
|
|
15
|
+
this.isShown.set(true);
|
|
16
|
+
this.breadcrumb.set(breadcrumb);
|
|
17
|
+
this.location.set(location);
|
|
18
|
+
this.translateBreadcrumb.set(translateBreadcrumb);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public hide(): void {
|
|
22
|
+
this.isShown.set(false);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ElementRef } from '@angular/core';
|
|
2
|
+
import { AutoTrimAndLowerDirective } from './auto-trim-and-lower.directive';
|
|
3
|
+
|
|
4
|
+
describe('AutoTrimAndLowerDirective', () => {
|
|
5
|
+
it('should create an instance', () => {
|
|
6
|
+
const element = new ElementRef({});
|
|
7
|
+
const directive = new AutoTrimAndLowerDirective(element);
|
|
8
|
+
expect(directive).toBeTruthy();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should trim and lowercase text on blur', () => {
|
|
12
|
+
const element = new ElementRef({
|
|
13
|
+
value: ' My@Test.Ca '
|
|
14
|
+
});
|
|
15
|
+
const directive = new AutoTrimAndLowerDirective(element);
|
|
16
|
+
|
|
17
|
+
directive.onBlur(new KeyboardEvent(''));
|
|
18
|
+
|
|
19
|
+
expect(element.nativeElement.value).toBe('my@test.ca');
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Directive, ElementRef, HostListener } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: '[appAutoTrimAndLower]',
|
|
5
|
+
standalone: true
|
|
6
|
+
})
|
|
7
|
+
export class AutoTrimAndLowerDirective {
|
|
8
|
+
|
|
9
|
+
public constructor(private readonly el: ElementRef) {}
|
|
10
|
+
|
|
11
|
+
@HostListener('blur', ['$event'])
|
|
12
|
+
public onBlur(_: KeyboardEvent) {
|
|
13
|
+
this.trimText();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private trimText() {
|
|
17
|
+
this.el.nativeElement.value = this.el.nativeElement.value?.trim().toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import { HasErrorRootDirective } from './has-error-root.directive';
|
|
4
|
+
import { HasErrorDirective } from './has-error.directive';
|
|
5
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
6
|
+
|
|
7
|
+
@NgModule({
|
|
8
|
+
declarations: [
|
|
9
|
+
HasErrorDirective,
|
|
10
|
+
HasErrorRootDirective
|
|
11
|
+
],
|
|
12
|
+
imports: [
|
|
13
|
+
CommonModule,
|
|
14
|
+
ReactiveFormsModule
|
|
15
|
+
],
|
|
16
|
+
exports: [
|
|
17
|
+
HasErrorDirective,
|
|
18
|
+
HasErrorRootDirective
|
|
19
|
+
],
|
|
20
|
+
})
|
|
21
|
+
export class FormErrorModule { }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ContentChild, Directive } from '@angular/core';
|
|
2
|
+
import { FormControl, FormControlDirective, FormControlName } from '@angular/forms';
|
|
3
|
+
import { ReplaySubject } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
@Directive({
|
|
6
|
+
/* eslint-disable @angular-eslint/directive-selector */
|
|
7
|
+
selector: 'mat-form-field',
|
|
8
|
+
/* eslint-enable @angular-eslint/directive-selector */
|
|
9
|
+
standalone: false,
|
|
10
|
+
})
|
|
11
|
+
export class HasErrorRootDirective {
|
|
12
|
+
private readonly _formControl$ = new ReplaySubject<FormControl>(1);
|
|
13
|
+
|
|
14
|
+
@ContentChild(FormControlDirective)
|
|
15
|
+
public set formControl(formControlDirective: FormControlDirective) {
|
|
16
|
+
if (formControlDirective) {
|
|
17
|
+
this._formControl$.next(formControlDirective.control);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@ContentChild(FormControlName)
|
|
22
|
+
public set formControlName(formControlName: FormControlName) {
|
|
23
|
+
if (formControlName) {
|
|
24
|
+
this._formControl$.next(formControlName.control);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public get formControl$() {
|
|
29
|
+
return this._formControl$.asObservable();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterContentInit,
|
|
3
|
+
Directive,
|
|
4
|
+
EmbeddedViewRef,
|
|
5
|
+
Input,
|
|
6
|
+
OnDestroy,
|
|
7
|
+
TemplateRef,
|
|
8
|
+
ViewContainerRef,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import {
|
|
11
|
+
combineLatest,
|
|
12
|
+
distinctUntilChanged,
|
|
13
|
+
EMPTY,
|
|
14
|
+
map,
|
|
15
|
+
ReplaySubject,
|
|
16
|
+
startWith,
|
|
17
|
+
Subscription,
|
|
18
|
+
switchMap,
|
|
19
|
+
} from 'rxjs';
|
|
20
|
+
import { HasErrorRootDirective } from './has-error-root.directive';
|
|
21
|
+
|
|
22
|
+
export interface HasErrorContext {
|
|
23
|
+
$implicit: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Directive({
|
|
27
|
+
selector: '[hasError]',
|
|
28
|
+
standalone: false,
|
|
29
|
+
})
|
|
30
|
+
export class HasErrorDirective implements AfterContentInit, OnDestroy {
|
|
31
|
+
|
|
32
|
+
private readonly errorName$ = new ReplaySubject<string>(1);
|
|
33
|
+
private readonly ctrl$ = this.hasErrorRoot.formControl$;
|
|
34
|
+
private readonly status$ = this.ctrl$.pipe(
|
|
35
|
+
switchMap((ctrl) => (ctrl.statusChanges || EMPTY).pipe(startWith(null)))
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
private readonly error$ = combineLatest([
|
|
39
|
+
this.ctrl$,
|
|
40
|
+
this.errorName$,
|
|
41
|
+
this.status$,
|
|
42
|
+
]).pipe(
|
|
43
|
+
map(([ctrl, errorName]) => ({
|
|
44
|
+
hasError: ctrl.hasError(errorName),
|
|
45
|
+
value: ctrl.getError(errorName),
|
|
46
|
+
})),
|
|
47
|
+
distinctUntilChanged(
|
|
48
|
+
(x, y) => x.hasError === y.hasError && x.value === y.value
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
private view?: EmbeddedViewRef<HasErrorContext>;
|
|
53
|
+
private subscription?: Subscription;
|
|
54
|
+
|
|
55
|
+
@Input()
|
|
56
|
+
public set hasError(errorName: string) {
|
|
57
|
+
this.errorName$.next(errorName);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public constructor(
|
|
61
|
+
private readonly hasErrorRoot: HasErrorRootDirective,
|
|
62
|
+
private readonly templateRef: TemplateRef<HasErrorContext>,
|
|
63
|
+
private readonly vcr: ViewContainerRef
|
|
64
|
+
) {
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public static ngTemplateContextGuard(_dir: HasErrorDirective, ctx: unknown): ctx is HasErrorContext {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public ngAfterContentInit(): void {
|
|
72
|
+
setTimeout(() => {
|
|
73
|
+
this.subscription = this.error$.subscribe((error) => {
|
|
74
|
+
if (!error.hasError) {
|
|
75
|
+
this.view?.destroy();
|
|
76
|
+
this.view = undefined;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (this.view) {
|
|
81
|
+
this.view.context.$implicit = error.value;
|
|
82
|
+
this.view.markForCheck();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.view = this.vcr.createEmbeddedView(this.templateRef, {
|
|
86
|
+
$implicit: error.value,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}, 100);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public ngOnDestroy(): void {
|
|
93
|
+
this.subscription?.unsubscribe();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import { catchError, delay, mergeMap, of, throwError } from 'rxjs';
|
|
3
|
+
import { LoadingStateService } from './loading-state.service';
|
|
4
|
+
import { fakeAsync, tick } from '@angular/core/testing';
|
|
5
|
+
|
|
6
|
+
describe('LoadingStateService', () => {
|
|
7
|
+
let service: LoadingStateService;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
service = new LoadingStateService();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should be created', () => {
|
|
14
|
+
expect(service).toBeTruthy();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should change showLoadingIndicator to true when calling showLoading', () => {
|
|
18
|
+
service.showLoading();
|
|
19
|
+
|
|
20
|
+
expect(service.showLoadingIndicator()).toBeTrue();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should change showLoadingIndicator to true when calling showLoading', () => {
|
|
24
|
+
service.showLoading();
|
|
25
|
+
service.hideLoading();
|
|
26
|
+
|
|
27
|
+
expect(service.showLoadingIndicator()).toBeFalse();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should show indicator until observable has completed', fakeAsync(() => {
|
|
31
|
+
const mockResult = 'test complete!';
|
|
32
|
+
const observable$ = of(mockResult).pipe(delay(2));
|
|
33
|
+
|
|
34
|
+
service.withLoadingIndicator(observable$)
|
|
35
|
+
.subscribe(result => expect(result).toBe(mockResult));
|
|
36
|
+
|
|
37
|
+
tick(1);
|
|
38
|
+
expect(service.showLoadingIndicator()).toBeTrue();
|
|
39
|
+
tick(2000);
|
|
40
|
+
expect(service.showLoadingIndicator()).toBeFalse();
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
it('should set showError to true when an error occure while executing and observable', fakeAsync(() => {
|
|
44
|
+
const mockError = new Error('The bird hit the fan.');
|
|
45
|
+
const observableWithError$ = of('test')
|
|
46
|
+
.pipe(mergeMap(() => throwError(() => mockError)));
|
|
47
|
+
const spy = spyOn(window.console, 'error');
|
|
48
|
+
|
|
49
|
+
service.withLoadingIndicator(observableWithError$)
|
|
50
|
+
.pipe(catchError(() => 'test complete'))
|
|
51
|
+
.subscribe();
|
|
52
|
+
tick();
|
|
53
|
+
|
|
54
|
+
expect(service.showError()).toBeTrue();
|
|
55
|
+
expect(spy).toHaveBeenCalledOnceWith('Could not load data.', mockError);
|
|
56
|
+
}));
|
|
57
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Injectable, Signal, WritableSignal, computed, signal } from '@angular/core';
|
|
2
|
+
import { Observable, catchError, finalize, mergeMap, of, tap, throwError } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class LoadingStateService {
|
|
6
|
+
|
|
7
|
+
public showLoadingIndicator: Signal<boolean> = computed(() => this.isLoading());
|
|
8
|
+
public showError: Signal<boolean> = computed(() => this.hasError());
|
|
9
|
+
|
|
10
|
+
private readonly isLoading: WritableSignal<boolean> = signal(false);
|
|
11
|
+
private readonly hasError: WritableSignal<boolean> = signal(false);
|
|
12
|
+
|
|
13
|
+
public showLoading(): void {
|
|
14
|
+
this.isLoading.set(true);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public hideLoading(): void {
|
|
18
|
+
this.isLoading.set(false);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public withLoadingIndicator<T>(observable$: Observable<T>): Observable<T> {
|
|
22
|
+
return of(null).pipe(
|
|
23
|
+
tap(() => this.startLoading()),
|
|
24
|
+
mergeMap(() => observable$),
|
|
25
|
+
catchError((error) => this.handleError(error)),
|
|
26
|
+
finalize(() => this.hideLoading()),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public setAsInError(): void {
|
|
31
|
+
this.hasError.set(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private startLoading(): void {
|
|
35
|
+
this.hasError.set(false);
|
|
36
|
+
this.showLoading();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private handleError(error: any): Observable<never> {
|
|
40
|
+
console.error('Could not load data.', error);
|
|
41
|
+
this.hasError.set(true);
|
|
42
|
+
return throwError(() => error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class PasswordValidation {
|
|
2
|
+
public hasMinimumCharacters: boolean;
|
|
3
|
+
public hasMinimumNumeric: boolean;
|
|
4
|
+
public hasLowerAndUppercase: boolean;
|
|
5
|
+
public hasSpecialCharacter: boolean;
|
|
6
|
+
public hasIdenticalPassword: boolean;
|
|
7
|
+
|
|
8
|
+
public constructor(hasMinimumCharacters: boolean = false, hasMinimumNumeric: boolean = false, hasLowerAndUppercase: boolean = false, hasSpecialCharacter: boolean = false, hasIdenticalPassword: boolean = false) {
|
|
9
|
+
this.hasMinimumCharacters = hasMinimumCharacters;
|
|
10
|
+
this.hasMinimumNumeric = hasMinimumNumeric;
|
|
11
|
+
this.hasLowerAndUppercase = hasLowerAndUppercase;
|
|
12
|
+
this.hasSpecialCharacter = hasSpecialCharacter;
|
|
13
|
+
this.hasIdenticalPassword = hasIdenticalPassword;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public isValid(): boolean {
|
|
17
|
+
return this.hasMinimumCharacters && this.hasMinimumNumeric && this.hasLowerAndUppercase && this.hasSpecialCharacter && this.hasIdenticalPassword;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { PasswordValidator } from './password-validator';
|
|
2
|
+
import {UntypedFormControl, UntypedFormGroup} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
describe('PasswordValidator', () => {
|
|
5
|
+
it('should create an instance', () => {
|
|
6
|
+
expect(new PasswordValidator()).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('should return invalid password when password does not have upper case', () => {
|
|
10
|
+
const formGroup = new UntypedFormGroup({
|
|
11
|
+
password: new UntypedFormControl('apasswordwithoutuppercase'),
|
|
12
|
+
confirmation: new UntypedFormControl('')
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
16
|
+
|
|
17
|
+
expect(errors.hasLowerAndUppercase).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should return valid password when password have upper and lower case', () => {
|
|
21
|
+
const formGroup = new UntypedFormGroup({
|
|
22
|
+
password: new UntypedFormControl('Apassword'),
|
|
23
|
+
confirmation: new UntypedFormControl('')
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
27
|
+
|
|
28
|
+
expect(errors.hasLowerAndUppercase).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should return invalid password when password does not have lower case', () => {
|
|
32
|
+
const formGroup = new UntypedFormGroup({
|
|
33
|
+
password: new UntypedFormControl('APASSWORDWITHOUTLOWERCASE'),
|
|
34
|
+
confirmation: new UntypedFormControl('')
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
38
|
+
|
|
39
|
+
expect(errors.hasLowerAndUppercase).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should return valid password when password have numeric value', () => {
|
|
43
|
+
const formGroup = new UntypedFormGroup({
|
|
44
|
+
password: new UntypedFormControl('123'),
|
|
45
|
+
confirmation: new UntypedFormControl('')
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
49
|
+
|
|
50
|
+
expect(errors.hasMinimumNumeric).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should return invalid password when password does not have numeric value', () => {
|
|
54
|
+
const formGroup = new UntypedFormGroup({
|
|
55
|
+
password: new UntypedFormControl('apasswordwithoutuppercase'),
|
|
56
|
+
confirmation: new UntypedFormControl('')
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
60
|
+
|
|
61
|
+
expect(errors.hasMinimumNumeric).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return invalid password when password does not have special character', () => {
|
|
65
|
+
const formGroup = new UntypedFormGroup({
|
|
66
|
+
password: new UntypedFormControl('apasswordwithoutuppercase'),
|
|
67
|
+
confirmation: new UntypedFormControl('')
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
71
|
+
|
|
72
|
+
expect(errors.hasSpecialCharacter).toBe(false);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should return valid password when password have special character', () => {
|
|
76
|
+
const formGroup = new UntypedFormGroup({
|
|
77
|
+
password: new UntypedFormControl('&!aPassword'),
|
|
78
|
+
confirmation: new UntypedFormControl('')
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
82
|
+
|
|
83
|
+
expect(errors.hasSpecialCharacter).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should return invalid password when password does not enough characters', () => {
|
|
87
|
+
const formGroup = new UntypedFormGroup({
|
|
88
|
+
password: new UntypedFormControl('test1'),
|
|
89
|
+
confirmation: new UntypedFormControl('')
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
93
|
+
|
|
94
|
+
expect(errors.hasMinimumCharacters).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should return valid password when password has enough characters', () => {
|
|
98
|
+
const formGroup = new UntypedFormGroup({
|
|
99
|
+
password: new UntypedFormControl('aPasswordWithMoreThan8characters'),
|
|
100
|
+
confirmation: new UntypedFormControl('')
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
104
|
+
|
|
105
|
+
expect(errors.hasMinimumCharacters).toBe(true);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('should return valid password when password has exactly 13 characters', () => {
|
|
109
|
+
const formGroup = new UntypedFormGroup({
|
|
110
|
+
password: new UntypedFormControl('apasswordTest'),
|
|
111
|
+
confirmation: new UntypedFormControl('')
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
115
|
+
|
|
116
|
+
expect(errors.hasMinimumCharacters).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should return invalid password when passwords are not equal', () => {
|
|
120
|
+
const formGroup = new UntypedFormGroup({
|
|
121
|
+
password: new UntypedFormControl('test1'),
|
|
122
|
+
confirmation: new UntypedFormControl('')
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
126
|
+
|
|
127
|
+
expect(errors.hasIdenticalPassword).toBe(false);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should return valid password when passwords are equal', () => {
|
|
131
|
+
const formGroup = new UntypedFormGroup({
|
|
132
|
+
password: new UntypedFormControl('test1'),
|
|
133
|
+
confirmation: new UntypedFormControl('test1')
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
137
|
+
|
|
138
|
+
expect(errors.hasIdenticalPassword).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should return valid password when every criteria is valid', () => {
|
|
142
|
+
const formGroup = new UntypedFormGroup({
|
|
143
|
+
password: new UntypedFormControl('!TestCauca123'),
|
|
144
|
+
confirmation: new UntypedFormControl('!TestCauca123')
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const errors = PasswordValidator.validate(formGroup);
|
|
148
|
+
|
|
149
|
+
expect(errors.hasIdenticalPassword).toBe(true);
|
|
150
|
+
expect(errors.hasLowerAndUppercase).toBe(true);
|
|
151
|
+
expect(errors.hasMinimumNumeric).toBe(true);
|
|
152
|
+
expect(errors.hasSpecialCharacter).toBe(true);
|
|
153
|
+
expect(errors.hasMinimumCharacters).toBe(true);
|
|
154
|
+
});
|
|
155
|
+
});
|