Skip to content

Commit

Permalink
chore: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Nov 21, 2023
1 parent aebcce3 commit 58c57a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
23 changes: 11 additions & 12 deletions packages/abc/st/test/st-data-source.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DecimalPipe } from '@angular/common';
import { HttpParams } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import { firstValueFrom, of, throwError } from 'rxjs';

import { DatePipe, YNPipe } from '@delon/theme';
import { CurrencyService } from '@delon/util/format';
import { deepCopy } from '@delon/util/other';
import { NzSafeAny } from 'ng-zorro-antd/core/types';

Expand Down Expand Up @@ -39,7 +41,7 @@ describe('abc: table: data-souce', () => {
let datePipe: DatePipe;
let ynPipe: YNPipe;
let decimalPipe: DecimalPipe;
let currencySrv: MockCurrencyService;
let currencySrv: CurrencyService;
let httpResponse: any;
let mockDomSanitizer: MockDomSanitizer;

Expand All @@ -49,12 +51,6 @@ describe('abc: table: data-souce', () => {
}
}

class MockCurrencyService {
format(): string {
return '';
}
}

class MockDomSanitizer {
bypassSecurityTrustHtml(val: any): any {
return val;
Expand All @@ -73,13 +69,16 @@ describe('abc: table: data-souce', () => {
columns: [{ title: '', index: 'id' }] as _STColumn[],
paginator: true
};
TestBed.configureTestingModule({
providers: [DatePipe, YNPipe, DecimalPipe, CurrencyService]
});
mockDomSanitizer = new MockDomSanitizer() as any;
datePipe = new DatePipe();
ynPipe = new YNPipe(mockDomSanitizer as any);
decimalPipe = new DecimalPipe('zh-CN');
datePipe = TestBed.inject(DatePipe);
ynPipe = TestBed.inject(YNPipe);
decimalPipe = TestBed.inject(DecimalPipe);
http = new MockHttpClient();
currencySrv = new MockCurrencyService();
srv = new STDataSource(http as any, datePipe, ynPipe, decimalPipe, currencySrv as any, mockDomSanitizer as any);
currencySrv = TestBed.inject(CurrencyService);
srv = new STDataSource(http as any, datePipe, ynPipe, decimalPipe, currencySrv, mockDomSanitizer as any);
srv.setCog(ST_DEFAULT_CONFIG);
}

Expand Down
15 changes: 4 additions & 11 deletions packages/abc/st/test/st.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@ import { By } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { of, Subject, throwError } from 'rxjs';

import {
DatePipe,
DelonLocaleService,
DrawerHelper,
en_US,
ModalHelper,
_HttpClient,
AlainI18NService
} from '@delon/theme';
import { DelonLocaleService, DrawerHelper, en_US, ModalHelper, _HttpClient, AlainI18NService } from '@delon/theme';
import { formatDate } from '@delon/util/date-time';
import { deepCopy } from '@delon/util/other';
import { NzPaginationComponent } from 'ng-zorro-antd/pagination';
import { NzTooltipDirective } from 'ng-zorro-antd/tooltip';
Expand Down Expand Up @@ -258,7 +251,7 @@ describe('abc: st', () => {
it(`should be render date`, fakeAsync(() => {
page
.updateColumn([{ title: '', index: 'date', type: 'date' }])
.expectCell(new DatePipe().transform(MOCKDATE, 'yyyy-MM-dd HH:mm'))
.expectCell(formatDate(MOCKDATE, 'yyyy-MM-dd HH:mm'))
.asyncEnd();
}));
it(`should be custom render date format`, fakeAsync(() => {
Expand All @@ -271,7 +264,7 @@ describe('abc: st', () => {
dateFormat: 'yyyy-MM'
}
])
.expectCell(new DatePipe().transform(MOCKDATE, 'yyyy-MM'))
.expectCell(formatDate(MOCKDATE, 'yyyy-MM'))
.asyncEnd();
}));
it(`should be text center`, fakeAsync(() => {
Expand Down

0 comments on commit 58c57a1

Please sign in to comment.