mirror of https://github.com/abpframework/abp.git
17 changed files with 283 additions and 277 deletions
@ -1,32 +0,0 @@ |
|||||
import { SpectatorDirective, createDirectiveFactory } from '@ngneat/spectator/jest'; |
|
||||
import { TableSortDirective } from '../directives/table-sort.directive'; |
|
||||
import { TableComponent } from '../components/table/table.component'; |
|
||||
import { DummyLocalizationPipe } from './table.component.spec'; |
|
||||
import { NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap'; |
|
||||
|
|
||||
describe('TableSortDirective', () => { |
|
||||
let spectator: SpectatorDirective<TableSortDirective>; |
|
||||
let directive: TableSortDirective; |
|
||||
const createDirective = createDirectiveFactory({ |
|
||||
directive: TableSortDirective, |
|
||||
declarations: [TableComponent, DummyLocalizationPipe], |
|
||||
imports: [NgbPaginationModule], |
|
||||
}); |
|
||||
|
|
||||
beforeEach(() => { |
|
||||
spectator = createDirective( |
|
||||
`<abp-table [value]="[1,4,2]" [abpTableSort]="{ order: 'asc' }"></abp-table>`, |
|
||||
); |
|
||||
directive = spectator.directive; |
|
||||
}); |
|
||||
|
|
||||
test('should be created', () => { |
|
||||
expect(directive).toBeTruthy(); |
|
||||
}); |
|
||||
|
|
||||
test('should change table value', () => { |
|
||||
expect(directive.value).toEqual([1, 4, 2]); |
|
||||
const table = spectator.query(TableComponent); |
|
||||
expect(table.value).toEqual([1, 2, 4]); |
|
||||
}); |
|
||||
}); |
|
||||
@ -1,75 +0,0 @@ |
|||||
import { Pipe, PipeTransform } from '@angular/core'; |
|
||||
import { NgbPaginationModule } from '@ng-bootstrap/ng-bootstrap'; |
|
||||
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest'; |
|
||||
import { TableComponent } from '../components'; |
|
||||
|
|
||||
@Pipe({ |
|
||||
name: 'abpLocalization', |
|
||||
}) |
|
||||
export class DummyLocalizationPipe implements PipeTransform { |
|
||||
transform(value: any, ...args: any[]): any { |
|
||||
return value; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
describe('TableComponent', () => { |
|
||||
let spectator: SpectatorHost<TableComponent>; |
|
||||
const createHost = createHostFactory({ |
|
||||
component: TableComponent, |
|
||||
declarations: [DummyLocalizationPipe], |
|
||||
imports: [NgbPaginationModule], |
|
||||
}); |
|
||||
|
|
||||
describe('without value', () => { |
|
||||
beforeEach(() => { |
|
||||
spectator = createHost( |
|
||||
`<abp-table
|
|
||||
[headerTemplate]="header" |
|
||||
[colgroupTemplate]="colgroup" |
|
||||
[value]="value"> |
|
||||
</abp-table> |
|
||||
<ng-template #colgroup><colgroup><col /></colgroup></ng-template> |
|
||||
<ng-template #header><th>name</th></ng-template>`, |
|
||||
{ |
|
||||
hostProps: { |
|
||||
value: [], |
|
||||
}, |
|
||||
}, |
|
||||
); |
|
||||
}); |
|
||||
|
|
||||
it('should display the empty message', () => { |
|
||||
expect(spectator.query('caption.ui-table-empty')).toHaveText( |
|
||||
'AbpAccount::NoDataAvailableInDatatable', |
|
||||
); |
|
||||
}); |
|
||||
|
|
||||
it('should display the header', () => { |
|
||||
expect(spectator.query('thead')).toBeTruthy(); |
|
||||
expect(spectator.query('th')).toHaveText('name'); |
|
||||
}); |
|
||||
|
|
||||
it('should place the colgroup template', () => { |
|
||||
expect(spectator.query('colgroup')).toBeTruthy(); |
|
||||
expect(spectator.query('col')).toBeTruthy(); |
|
||||
}); |
|
||||
}); |
|
||||
|
|
||||
describe('with value', () => { |
|
||||
// TODO
|
|
||||
beforeEach(() => { |
|
||||
spectator = createHost( |
|
||||
`<abp-table
|
|
||||
[headerTemplate]="header" |
|
||||
[value]="value"></abp-table> |
|
||||
<ng-template #header><th>name</th></ng-template> |
|
||||
`,
|
|
||||
{ |
|
||||
hostProps: { |
|
||||
value: [], |
|
||||
}, |
|
||||
}, |
|
||||
); |
|
||||
}); |
|
||||
}); |
|
||||
}); |
|
||||
@ -1 +1,2 @@ |
|||||
|
import 'jest-canvas-mock'; |
||||
import 'jest-preset-angular/setup-jest'; |
import 'jest-preset-angular/setup-jest'; |
||||
|
|||||
Loading…
Reference in new issue