Skip to content

Commit

Permalink
tests(theme-shared): add table.component.spec
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-erim committed Jan 9, 2020
1 parent 1cbb7bc commit 1b2476a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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: [],
},
},
);
});
});
});

0 comments on commit 1b2476a

Please sign in to comment.