test fixed
This commit is contained in:
parent
5a1aca198b
commit
ec0eb7f1d1
|
@ -1,8 +1,7 @@
|
|||
import {module} from '../module';
|
||||
|
||||
export default class ColumnHeader {
|
||||
constructor($attrs) {
|
||||
this.$attrs = $attrs;
|
||||
constructor() {
|
||||
this.order = undefined;
|
||||
this.mouseIsOver = false;
|
||||
}
|
||||
|
@ -23,20 +22,21 @@ export default class ColumnHeader {
|
|||
return showArrow;
|
||||
}
|
||||
$onInit() {
|
||||
if (this.$attrs.defaultOrder) {
|
||||
this.order = this.$attrs.defaultOrder;
|
||||
if (this.defaultOrder) {
|
||||
this.order = this.defaultOrder;
|
||||
this.onClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnHeader.$inject = ['$attrs'];
|
||||
ColumnHeader.$inject = [];
|
||||
|
||||
module.component('vnColumnHeader', {
|
||||
template: require('./column-header.html'),
|
||||
bindings: {
|
||||
field: '@?',
|
||||
text: '@?',
|
||||
className: '@?'
|
||||
className: '@?',
|
||||
defaultOrder: '@?'
|
||||
},
|
||||
require: {
|
||||
gridHeader: '^^vnGridHeader'
|
||||
|
|
|
@ -67,4 +67,22 @@ describe('Component vnColumnHeader', () => {
|
|||
expect(result).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('onInit()', () => {
|
||||
it(`should never call onClick()`, () => {
|
||||
spyOn(controller, 'onClick');
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.onClick).not.toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it(`should define controllers order as per defaultOrder then call onClick()`, () => {
|
||||
controller.defaultOrder = 'ASC';
|
||||
spyOn(controller, 'onClick');
|
||||
controller.$onInit();
|
||||
|
||||
expect(controller.order).toEqual('ASC');
|
||||
expect(controller.onClick).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue