tests(theme-shared): add table.component.spec

#2537
pull/2605/head
mehmet-erim 6 years ago
parent 1cbb7bc32b
commit 1b2476ad7b

@ -55,10 +55,10 @@ describe('LoadingDirective', () => {
});
it('should remove the loading component to the DOM', done => {
const spy = jest.spyOn(spectator.directive['renderer'], 'removeChild');
const rendererSpy = jest.spyOn(spectator.directive['renderer'], 'removeChild');
spectator.setHostInput({ status: false });
setTimeout(() => {
expect(spy).toHaveBeenCalled();
expect(rendererSpy).toHaveBeenCalled();
expect(spectator.directive.rootNode).toBeFalsy();
done();
}, 0);

@ -0,0 +1,74 @@
import { createHostFactory, SpectatorHost } from '@ngneat/spectator/jest';
import { PaginationComponent, TableComponent } from '../components';
import { Pipe, PipeTransform } from '@angular/core';
@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: [PaginationComponent, DummyLocalizationPipe],
});
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('tr.empty-row>div')).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: [],
},
},
);
});
});
});
Loading…
Cancel
Save