Browse Source

Update localization keys and test setups

pull/23460/head
Fahri Gedik 8 months ago
parent
commit
e55b73aae8
  1. 4
      npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.ts
  2. 4
      npm/ng-packs/packages/theme-shared/src/lib/tests/breadcrumb.component.spec.ts
  3. 20
      npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts
  4. 10
      npm/ng-packs/packages/theme-shared/src/lib/tests/error.component.spec.ts
  5. 14
      npm/ng-packs/packages/theme-shared/src/lib/tests/modal.component.spec.ts
  6. 3
      npm/ng-packs/packages/theme-shared/src/test-setup.ts

4
npm/ng-packs/packages/theme-shared/src/lib/components/http-error-wrapper/http-error-wrapper.component.ts

@ -39,9 +39,9 @@ export class HttpErrorWrapperComponent implements OnInit, AfterViewInit, OnDestr
status: ErrorScreenErrorCodes = 0; status: ErrorScreenErrorCodes = 0;
title: LocalizationParam = 'Oops!'; title: LocalizationParam = '_::Oops!';
details: LocalizationParam = 'Sorry, an error has occured.'; details: LocalizationParam = '_::Sorry, an error has occured.';
customComponent: Type<any> | undefined = undefined; customComponent: Type<any> | undefined = undefined;

4
npm/ng-packs/packages/theme-shared/src/lib/tests/breadcrumb.component.spec.ts

@ -14,8 +14,8 @@ import { OTHERS_GROUP } from '@abp/ng.core';
import { SORT_COMPARE_FUNC } from '@abp/ng.core'; import { SORT_COMPARE_FUNC } from '@abp/ng.core';
const mockRoutes: ABP.Route[] = [ const mockRoutes: ABP.Route[] = [
{ name: 'Identity', path: '/identity' }, { name: '_::Identity', path: '/identity' },
{ name: 'Users', path: '/identity/users', parentName: 'Identity' }, { name: '_::Users', path: '/identity/users', parentName: '_::Identity' },
]; ];
// Simple compare function that doesn't use inject() // Simple compare function that doesn't use inject()

20
npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

@ -34,7 +34,7 @@ describe('ConfirmationService', () => {
}); });
test('should display a confirmation popup', fakeAsync(() => { test('should display a confirmation popup', fakeAsync(() => {
service.show('MESSAGE', 'TITLE'); service.show('_::MESSAGE', '_::TITLE');
tick(); tick();
@ -44,12 +44,12 @@ describe('ConfirmationService', () => {
test('should display HTML string in title, message, and buttons', fakeAsync(() => { test('should display HTML string in title, message, and buttons', fakeAsync(() => {
service.show( service.show(
'<span class="custom-message">MESSAGE<span>', '_::<span class="custom-message">MESSAGE<span>',
'<span class="custom-title">TITLE<span>', '_::<span class="custom-title">TITLE<span>',
'neutral', 'neutral',
{ {
cancelText: '<span class="custom-cancel">CANCEL</span>', cancelText: '_::<span class="custom-cancel">CANCEL</span>',
yesText: '<span class="custom-yes">YES</span>', yesText: '_::<span class="custom-yes">YES</span>',
}, },
); );
@ -62,7 +62,7 @@ describe('ConfirmationService', () => {
})); }));
test('should display custom FA icon', fakeAsync(() => { test('should display custom FA icon', fakeAsync(() => {
service.show('MESSAGE', 'TITLE', undefined, { service.show('_::MESSAGE', '_::TITLE', undefined, {
icon: 'fa fa-info', icon: 'fa fa-info',
}); });
@ -74,7 +74,7 @@ describe('ConfirmationService', () => {
const className = 'custom-icon'; const className = 'custom-icon';
const selector = '.' + className; const selector = '.' + className;
service.show('MESSAGE', 'TITLE', undefined, { service.show('_::MESSAGE', '_::TITLE', undefined, {
iconTemplate: `<span class="${className}">I am icon</span>`, iconTemplate: `<span class="${className}">I am icon</span>`,
}); });
@ -91,7 +91,7 @@ describe('ConfirmationService', () => {
${'warn'} | ${'.warning'} | ${'.fa-exclamation-triangle'} ${'warn'} | ${'.warning'} | ${'.fa-exclamation-triangle'}
${'error'} | ${'.error'} | ${'.fa-times-circle'} ${'error'} | ${'.error'} | ${'.fa-times-circle'}
`('should display $type confirmation popup', async ({ type, selector, icon }) => { `('should display $type confirmation popup', async ({ type, selector, icon }) => {
service[type]('MESSAGE', 'TITLE'); service[type]('_::MESSAGE', '_::TITLE');
await timer(0).toPromise(); await timer(0).toPromise();
@ -115,7 +115,7 @@ describe('ConfirmationService', () => {
// }); // });
test('should close when click cancel button', done => { test('should close when click cancel button', done => {
service.info('', '', { yesText: 'Sure', cancelText: 'Exit' }).subscribe(status => { service.info('_::', '_::', { yesText: '_::Sure', cancelText: '_::Exit' }).subscribe(status => {
expect(status).toBe(Confirmation.Status.reject); expect(status).toBe(Confirmation.Status.reject);
done(); done();
}); });
@ -137,7 +137,7 @@ describe('ConfirmationService', () => {
({ dismissible, count }) => { ({ dismissible, count }) => {
const spy = jest.spyOn(service as any, 'listenToEscape'); const spy = jest.spyOn(service as any, 'listenToEscape');
service.info('', '', { dismissible }); service.info('_::', '_::', { dismissible });
expect(spy).toHaveBeenCalledTimes(count); expect(spy).toHaveBeenCalledTimes(count);
}, },

10
npm/ng-packs/packages/theme-shared/src/lib/tests/error.component.spec.ts

@ -22,10 +22,12 @@ describe('ErrorComponent', () => {
imports: [HttpClientModule, LocalizationPipe], imports: [HttpClientModule, LocalizationPipe],
}); });
beforeEach(() => { beforeEach(() => {
spectator = createHost('<abp-http-error-wrapper></abp-http-error-wrapper>'); spectator = createHost(
spectator.component.destroy$ = new Subject(); '<abp-http-error-wrapper title="_::Oops!" details="_::Sorry, an error has occured."></abp-http-error-wrapper>',
}); );
spectator.component.destroy$ = new Subject();
});
describe('#destroy', () => { describe('#destroy', () => {
it('should be call when pressed the esc key', done => { it('should be call when pressed the esc key', done => {

14
npm/ng-packs/packages/theme-shared/src/lib/tests/modal.component.spec.ts

@ -1,6 +1,6 @@
import { ConfirmationService } from '@abp/ng.theme.shared'; import { ConfirmationService } from '@abp/ng.theme.shared';
import { CoreTestingModule } from '@abp/ng.core/testing'; import { CoreTestingModule } from '@abp/ng.core/testing';
import { Component, Input } from '@angular/core'; import { Component, EventEmitter, Input } from '@angular/core';
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';
import { Confirmation } from '@abp/ng.theme.shared'; import { Confirmation } from '@abp/ng.theme.shared';
import { Subject, timer } from 'rxjs'; import { Subject, timer } from 'rxjs';
@ -11,7 +11,6 @@ import { ModalComponent } from '../components/modal/modal.component';
<abp-modal <abp-modal
[visible]="visible" [visible]="visible"
[busy]="busy" [busy]="busy"
[ngDirty]="ngDirty"
(visibleChange)="visibleChange.emit($event)" (visibleChange)="visibleChange.emit($event)"
> >
<ng-template #abpHeader>Header</ng-template> <ng-template #abpHeader>Header</ng-template>
@ -25,8 +24,7 @@ import { ModalComponent } from '../components/modal/modal.component';
class TestHostComponent { class TestHostComponent {
@Input() visible = false; @Input() visible = false;
@Input() busy = false; @Input() busy = false;
@Input() ngDirty = false; visibleChange = new EventEmitter<boolean>();
visibleChange = new Subject<boolean>();
} }
const mockConfirmation$ = new Subject<Confirmation.Status>(); const mockConfirmation$ = new Subject<Confirmation.Status>();
@ -69,13 +67,7 @@ describe('ModalComponent', () => {
expect(spectator.component.busy).toBe(true); expect(spectator.component.busy).toBe(true);
}); });
it('should handle ngDirty input', () => { it('should have visibleChange emitter', () => {
spectator.setInput('ngDirty', true);
spectator.detectChanges();
expect(spectator.component.ngDirty).toBe(true);
});
it('should have visibleChange subject', () => {
expect(spectator.component.visibleChange).toBeDefined(); expect(spectator.component.visibleChange).toBeDefined();
}); });
}); });

3
npm/ng-packs/packages/theme-shared/src/test-setup.ts

@ -1,4 +1,5 @@
import 'jest-preset-angular/setup-jest'; import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv();
import { getTestBed } from '@angular/core/testing'; import { getTestBed } from '@angular/core/testing';
import { import {

Loading…
Cancel
Save