2019-01-10 13:35:28 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2019-01-10 13:36:46 +00:00
|
|
|
describe('Component vnTable', () => {
|
2019-01-10 13:35:28 +00:00
|
|
|
let $scope;
|
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2019-01-10 13:35:28 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, $rootScope) => {
|
2019-01-10 13:35:28 +00:00
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$element = angular.element(`
|
|
|
|
<vn-table model="model">
|
|
|
|
<vn-thead class="ng-scope">
|
|
|
|
<vn-tr>
|
|
|
|
<vn-th field="id"></vn-th>
|
|
|
|
<vn-th field="salesPerson" class="active"></vn-th>
|
|
|
|
<vn-th field="shipped" class="active"></vn-th>
|
|
|
|
</vn-tr>
|
|
|
|
</vn-thead>
|
|
|
|
</vn-table>`);
|
|
|
|
controller = $componentController('vnTable', {$scope, $element, $transclude: () => {}});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('setActiveArrow()', () => {
|
|
|
|
it(`should remove the active class from all table headers and then add it to the one in field`, () => {
|
|
|
|
controller.field = 'id';
|
|
|
|
|
|
|
|
controller.setActiveArrow();
|
|
|
|
|
|
|
|
expect($element[0].getElementsByClassName('active')[0].getAttribute('field')).toEqual('id');
|
|
|
|
expect($element[0].getElementsByClassName('active').length).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|