|
3 | 3 | import { ACLService } from '@delon/acl';
|
4 | 4 | import { AlainI18NService, AlainI18NServiceFake } from '@delon/theme';
|
5 | 5 | import { deepGet } from '@delon/util/other';
|
6 |
| -import { NzSafeAny } from 'ng-zorro-antd/core/types'; |
| 6 | +import { NgClassInterface, NzSafeAny } from 'ng-zorro-antd/core/types'; |
7 | 7 |
|
8 | 8 | import { STColumnSource, STColumnSourceProcessOptions } from '../st-column-source';
|
9 | 9 | import { STRowSource } from '../st-row.directive';
|
@@ -217,16 +217,32 @@ describe('st: column-source', () => {
|
217 | 217 | });
|
218 | 218 | describe('[className]', () => {
|
219 | 219 | it('should be custom class name', () => {
|
220 |
| - page.expectValue([{ title: '', type: 'number', className: 'aa' }], 'aa', 'className'); |
| 220 | + page.expectValue([{ title: '', className: 'aa' }], 'aa', '_className', true); |
221 | 221 | });
|
222 | 222 | it('should be auto text-right when type is number', () => {
|
223 |
| - page.expectValue([{ title: '', type: 'number' }], 'text-right', 'className'); |
| 223 | + page.expectValue([{ title: '', type: 'number' }], 'text-right', '_className', true); |
224 | 224 | });
|
225 | 225 | it('should be auto text-right when type is currency', () => {
|
226 |
| - page.expectValue([{ title: '', type: 'currency' }], 'text-right', 'className'); |
| 226 | + page.expectValue([{ title: '', type: 'currency' }], 'text-right', '_className', true); |
227 | 227 | });
|
228 | 228 | it('should be auto text-center when type is date', () => {
|
229 |
| - page.expectValue([{ title: '', type: 'date' }], 'text-center', 'className'); |
| 229 | + page.expectValue([{ title: '', type: 'date' }], 'text-center', '_className', true); |
| 230 | + }); |
| 231 | + it('should be working when className is object', () => { |
| 232 | + const res = srv.process([{ title: '', width: 10, type: 'number', className: { a: true, b: false } }], { |
| 233 | + widthMode: { strictBehavior: 'truncate' }, |
| 234 | + safeType: 'html' |
| 235 | + }).columns; |
| 236 | + const obj = res[0]._className as NgClassInterface; |
| 237 | + expect(obj['text-truncate']).toBe(true); |
| 238 | + }); |
| 239 | + it('should be remove duplicates', () => { |
| 240 | + const res = srv.process( |
| 241 | + [{ title: '', type: 'date', className: ['text-center', 'text-center'] }], |
| 242 | + options |
| 243 | + ).columns; |
| 244 | + expect((res[0]._className as string[]).length).toBe(1); |
| 245 | + expect(res[0]._className).toContain('text-center'); |
230 | 246 | });
|
231 | 247 | });
|
232 | 248 | describe('[iif]', () => {
|
@@ -729,10 +745,14 @@ describe('st: column-source', () => {
|
729 | 745 | });
|
730 | 746 |
|
731 | 747 | class PageObject {
|
732 |
| - expectValue(columns: STColumn[], value: any, path: string = 'indexKey'): this { |
| 748 | + expectValue(columns: STColumn[], value: any, path: string = 'indexKey', contain: boolean = false): this { |
733 | 749 | const newColumns = srv.process(columns, options).columns;
|
734 | 750 | expect(newColumns.length).toBeGreaterThan(0);
|
735 |
| - expect(deepGet(newColumns[0], path)).toBe(value); |
| 751 | + if (contain) { |
| 752 | + expect(deepGet(newColumns[0], path)).toContain(value); |
| 753 | + } else { |
| 754 | + expect(deepGet(newColumns[0], path)).toBe(value); |
| 755 | + } |
736 | 756 | return this;
|
737 | 757 | }
|
738 | 758 | expectBtnValue(columns: STColumn[], value: any, path: string = 'indexKey'): this {
|
|
0 commit comments