diff --git a/client/core/src/drop-down/drop-down.spec.js b/client/core/src/drop-down/drop-down.spec.js index 40944b872..4e2b8d5b9 100644 --- a/client/core/src/drop-down/drop-down.spec.js +++ b/client/core/src/drop-down/drop-down.spec.js @@ -12,7 +12,7 @@ describe('Component vnDropDown', () => { beforeEach(angular.mock.inject((_$componentController_, _$timeout_, _$filter_) => { $componentController = _$componentController_; - $element = angular.element('
'); + $element = angular.element('
'); $timeout = _$timeout_; $filter = _$filter_; })); @@ -268,7 +268,7 @@ describe('Component vnDropDown', () => { expect(controller._activeOption).toEqual(0); }); - it(`should call clearSearch() Esc key is pressed and take off 1 from _activeOption`, () => { + it(`should call clearSearch() Esc key is pressed and add up 1 to _activeOption`, () => { let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); controller.items = [{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce'}, {id: 3, name: 'Logan'}, {id: 4, name: 'Wolverine'}]; spyOn(controller, 'setScrollPosition'); @@ -284,4 +284,77 @@ describe('Component vnDropDown', () => { expect(controller._activeOption).toEqual(2); }); }); + + describe('setScrollPosition()', () => { + it(`should call child.scrollIntoView if defined `, () => { + $element[0].firstChild.setAttribute('class', 'dropdown'); + let child = $element[0].firstChild.firstChild; + child.scrollIntoView = () => {}; + spyOn(child, 'scrollIntoView'); + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + controller._activeOption = 0; + controller.setScrollPosition(); + + expect(child.scrollIntoView).toHaveBeenCalledWith(); + }); + }); + + describe('selectItem()', () => { + it(`should pass item to selected and set controller._show to false`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + let item = {id: 1, name: 'Batman'}; + controller.selectItem(item); + + expect(controller.selected).toEqual(item); + expect(controller._show).toEqual(false); + }); + + it(`should pass item to selected and set controller._show to true if the controller.multiple is defined`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + let item = {id: 1, name: 'Batman'}; + controller.multiple = true; + controller.selectItem(item); + + expect(controller.selected).toEqual(item); + expect(controller._show).toEqual(true); + }); + }); + + describe('loadItems()', () => { + it(`should set controller._show to true`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + controller.loadItems(); + + expect(controller._show).toEqual(true); + }); + + it(`should call loadMore() and then set controller._show to true`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}, {showLoadMore: () => {}, loadMore: () => {}}); + spyOn(controller, 'loadMore'); + controller.loadItems(); + + expect(controller._show).toEqual(true); + expect(controller.loadMore).toHaveBeenCalledWith(); + }); + }); + + describe('$onInit()', () => { + it(`should add an event listener to the parent element`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + spyOn(controller.parent, 'addEventListener'); + controller.$onInit(); + + expect(controller.parent.addEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function)); + }); + }); + + describe('$onDestroy()', () => { + it(`should remove an event listener from the parent element`, () => { + let controller = $componentController('vnDropDown', {$element, $timeout, $filter}); + spyOn(controller.parent, 'removeEventListener'); + controller.$onDestroy(); + + expect(controller.parent.removeEventListener).toHaveBeenCalledWith('keydown', jasmine.any(Function)); + }); + }); }); diff --git a/client/core/src/grid-header/grid-header.spec.js b/client/core/src/grid-header/grid-header.spec.js new file mode 100644 index 000000000..4b9e20da0 --- /dev/null +++ b/client/core/src/grid-header/grid-header.spec.js @@ -0,0 +1,44 @@ +import './grid-header.js'; + +describe('Component vnGridHeader', () => { + let $componentController; + + beforeEach(() => { + angular.mock.module('client'); + }); + + beforeEach(angular.mock.inject(_$componentController_ => { + $componentController = _$componentController_; + })); + + describe('selectColum()', () => { + it(`should set controller currentColumn to equal the argument received`, () => { + let controller = $componentController('vnGridHeader', {}); + let col = {columnStuff: 'some stuff'}; + controller.selectColum(col); + + expect(controller.currentColumn).toEqual(col); + }); + + it(`should set controller currentColumn.order to undefined then set currentColumn to equal the argument received`, () => { + let controller = $componentController('vnGridHeader', {}); + controller.currentColumn = {field: 'some field', order: 'ordered'}; + let col = {columnStuff: 'some stuff'}; + controller.selectColum(col); + + expect(controller.currentColumn.order).not.toBeDefined(); + expect(controller.currentColumn).toEqual(col); + }); + + it(`should set controller currentColumn.order to undefined then call onOrder passing currentColumn as argument`, () => { + let controller = $componentController('vnGridHeader', {}); + controller.onOrder = () => {}; + spyOn(controller, 'onOrder'); + let col = {columnStuff: 'some stuff'}; + controller.selectColum(col); + + expect(controller.currentColumn).toEqual(col); + expect(controller.onOrder).toHaveBeenCalledWith(col); + }); + }); +}); diff --git a/services/db/.gitignore b/services/db/.gitignore new file mode 100644 index 000000000..48e029b16 --- /dev/null +++ b/services/db/.gitignore @@ -0,0 +1 @@ +*.sql \ No newline at end of file diff --git a/services/db/Dockerfile b/services/db/Dockerfile index 3803f590a..7452424bd 100644 --- a/services/db/Dockerfile +++ b/services/db/Dockerfile @@ -1,7 +1,12 @@ FROM mysql:5.6.37 +MAINTAINER Vicente Falco + ENV MYSQL_ALLOW_EMPTY_PASSWORD yes +COPY localDB01Structure.sql /docker-entrypoint-initdb.d +COPY localDB02Inserts.sql /docker-entrypoint-initdb.d + CMD ["mysqld"] EXPOSE 3306 \ No newline at end of file