Return-Path: X-Original-To: apmail-aurora-commits-archive@minotaur.apache.org Delivered-To: apmail-aurora-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EB25610C17 for ; Wed, 28 May 2014 19:05:39 +0000 (UTC) Received: (qmail 65114 invoked by uid 500); 28 May 2014 19:05:39 -0000 Delivered-To: apmail-aurora-commits-archive@aurora.apache.org Received: (qmail 65082 invoked by uid 500); 28 May 2014 19:05:39 -0000 Mailing-List: contact commits-help@aurora.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aurora.incubator.apache.org Delivered-To: mailing list commits@aurora.incubator.apache.org Received: (qmail 65075 invoked by uid 99); 28 May 2014 19:05:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2014 19:05:39 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 28 May 2014 19:05:30 +0000 Received: (qmail 64736 invoked by uid 99); 28 May 2014 19:05:10 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 May 2014 19:05:10 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 783598C5E3B; Wed, 28 May 2014 19:05:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mansu@apache.org To: commits@aurora.incubator.apache.org Date: Wed, 28 May 2014 19:05:10 -0000 Message-Id: <73b073571760422d96358c8129905685@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/29] Upgrade Aurora UI to bootstrap3 X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-aurora Updated Branches: refs/heads/master 3d09a75bd -> 3a992e2cd http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/lib/angular/version.txt ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/lib/angular/version.txt b/3rdparty/javascript/bower_components/smart-table/test/lib/angular/version.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/lib/angular/version.txt @@ -0,0 +1 @@ + http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/unit/ColumnSpec.js ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/unit/ColumnSpec.js b/3rdparty/javascript/bower_components/smart-table/test/unit/ColumnSpec.js new file mode 100644 index 0000000..7b92569 --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/unit/ColumnSpec.js @@ -0,0 +1,27 @@ +describe('Column Module', function () { + beforeEach(module('smartTable.column', function ($provide) { + $provide.constant('DefaultColumnConfiguration', {defaultValue: 'default', value: 'defaultValue'}); + $provide.provider('Column', ColumnProvider); + })); + + + describe('Column factory', function () { + it('should always return an instance of Column', inject(function (Column) { + expect(typeof Column()).toBe('object'); + expect(Column() instanceof Column).toBe(true); + expect(typeof new Column()).toBe('object'); + expect(new Column() instanceof Column).toBe(true); + })); + + it('should overwrite default parameters if provided in config', inject(function (Column) { + var column = new Column(); + expect(column.defaultValue).toEqual('default'); + expect(column.value).toEqual('defaultValue'); + + column = new Column({value: 'value', otherValue: 'otherValue'}); + expect(column.defaultValue).toEqual('default'); + expect(column.value).toEqual('value'); + expect(column.otherValue).toEqual('otherValue'); + })); + }); +}); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/unit/TableSpec.js ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/unit/TableSpec.js b/3rdparty/javascript/bower_components/smart-table/test/unit/TableSpec.js new file mode 100644 index 0000000..7a1384e --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/unit/TableSpec.js @@ -0,0 +1,641 @@ +describe('Table module', function () { + + var + scope, + Column, + DefaultConfig, + filter, + ctrl, + defaultDisplayedCollection = [ + {prop: 'defaultValue'} + ], + ctrlMock = { + pipe: function () { + return defaultDisplayedCollection; + } + }; + + beforeEach(module('smartTable.table', function ($provide) { + $provide.constant('DefaultTableConfiguration', {defaultValue: 'defaultValue', value: 'defaultValue'}); + })); + + describe('Table Controller', function () { + + beforeEach(inject(function ($controller, $rootScope, $filter, $injector) { + scope = $rootScope.$new(); + Column = $injector.get('Column'); + DefaultConfig = $injector.get('DefaultTableConfiguration'); + filter = $filter; + ctrl = $controller('TableCtrl', {$scope: scope, Column: Column, DefaultTableConfig: DefaultConfig, $filter: filter + }); + })); + + it('should init the config', function () { + + expect(angular.isArray(scope.columns)).toBe(true); + expect(angular.isArray(scope.displayedCollection)).toBe(true); + expect(angular.isArray(scope.dataCollection)).toBe(true); + + ctrl.setGlobalConfig({value: 'overwritten'}); + expect(scope.defaultValue).toEqual('defaultValue'); + expect(scope.value).toEqual('overwritten'); + }); + + it('should set and override the config', function () { + ctrl.setGlobalConfig({value: 'overwritten'}); + expect(scope.defaultValue).toEqual('defaultValue'); + expect(scope.value).toEqual('overwritten'); + }); + + describe('change page', function () { + + beforeEach(function () { + var changePage = ctrl.changePage; + ctrl = ctrlMock; + ctrl.changePage = changePage; + }); + + it('should change the page and refresh the displayed items', function () { + spyOn(ctrlMock, 'pipe').andCallThrough(); + scope.currentPage = 1; + ctrl.changePage({page: 2}); + expect(scope.currentPage).toEqual(2); + expect(ctrlMock.pipe).toHaveBeenCalledWith(scope.dataCollection); + expect(scope.displayedCollection).toBe(defaultDisplayedCollection); + }); + + it('should not change the page if provided page parameter is not correct', function () { + scope.currentPage = 3; + spyOn(ctrlMock, 'pipe').andCallThrough(); + ctrl.changePage('whatever'); + expect(scope.currentPage).toEqual(3); + expect(ctrlMock.pipe).not.toHaveBeenCalled(); + }); + + it('should emit an event', inject(function ($rootScope) { + scope.currentPage = 3; + var eventHandler = { + listener: function (event, args) { + expect(args.oldValue).toEqual(3); + expect(args.newValue).toEqual(1); + } + }; + spyOn(eventHandler, 'listener'); + $rootScope.$on('changePage', eventHandler.listener); + ctrl.changePage({page: 1}); + expect(eventHandler.listener).toHaveBeenCalled(); + })); + }); + + describe('Column API', function () { + + beforeEach(function () { + scope.columns = [new Column({id: 0}), new Column({id: 1})]; + }); + + it('should add column at proper index or put it at the end', function () { + + expect(scope.columns.length).toEqual(2); + //insert at a given index + ctrl.insertColumn({id: 3}, 1); + expect(scope.columns.length).toBe(3); + expect(scope.columns[1].id).toBe(3); + }); + + it('should add Column at the end', function () { + expect(scope.columns.length).toEqual(2); + + ctrl.insertColumn({id: 666}, -1); + expect(scope.columns.length).toBe(3); + expect(scope.columns[2].id).toBe(666); + ctrl.insertColumn({id: 99}, 99); + expect(scope.columns.length).toBe(4); + expect(scope.columns[3].id).toBe(99); + }); + + it('should remove column at proper index or do nothing', function () { + + expect(scope.columns.length).toEqual(2); + + ctrl.removeColumn(0); + expect(scope.columns.length).toBe(1); + expect(scope.columns[0].id).toBe(1); + + ctrl.removeColumn(666); + expect(scope.columns.length).toBe(1); + ctrl.removeColumn(-1); + expect(scope.columns.length).toBe(1); + }); + + describe('move column', function () { + + beforeEach(function () { + //insert few columns + scope.columns = []; + + ctrl.insertColumn({id: 0}); + ctrl.insertColumn({id: 1}); + ctrl.insertColumn({id: 2}); + ctrl.insertColumn({id: 3}); + ctrl.insertColumn({id: 4}); + }); + + it('should move a column from a lower index to an higher one', function () { + ctrl.moveColumn(0, 3); + expect(scope.columns[0].id).toBe(1); + expect(scope.columns[3].id).toBe(0); + }); + + it('should move a column from a higher index to a lower one', function () { + ctrl.moveColumn(4, 1); + expect(scope.columns[4].id).toBe(3); + expect(scope.columns[1].id).toBe(4) + }); + + it('should not move any column', function () { + ctrl.moveColumn(-1, 3); + expect(scope.columns[3].id).toBe(3); + ctrl.moveColumn(3, 666); + expect(scope.columns[3].id).toBe(3); + }); + }); + + describe('clear columns', function () { + + beforeEach(function () { + //insert few columns + scope.columns = []; + + ctrl.insertColumn({id: 0}); + ctrl.insertColumn({id: 1}); + ctrl.insertColumn({id: 2}); + ctrl.insertColumn({id: 3}); + ctrl.insertColumn({id: 4}); + }); + + it('should remove all columns', function () { + expect(scope.columns.length).toBe(5); + ctrl.clearColumns(); + expect(scope.columns.length).toBe(0); + }); + + it('should have columns when adding after clear', function () { + ctrl.clearColumns(); + ctrl.insertColumn({id: 7}); + ctrl.insertColumn({id: 8}); + ctrl.insertColumn({id: 9}); + expect(scope.columns[0].id).toBe(7); + expect(scope.columns[1].id).toBe(8); + expect(scope.columns[2].id).toBe(9); + }); + + }); + }); + + describe('Row API', function () { + var refArray = [ + {id: 0}, + {id: 1}, + {id: 2} + ]; + beforeEach(function () { + scope.displayedCollection = scope.dataCollection = [ + {id: 0}, + {id: 1}, + {id: 2} + ]; + }); + + describe('Select dataRows', function () { + + describe('in single selection Mode', function () { + + beforeEach(function () { + scope.selectionMode = 'single'; + scope.displayedCollection = scope.dataCollection = [ + {id: 0, secondProperty: true, thirdProperty: 1}, + {id: 1, secondProperty: true, thirdProperty: 2}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]; + }); + + it('should only set isSelected=true to only one item at the time', function () { + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).toBe(true); + expect(scope.dataCollection[1].isSelected).not.toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + + ctrl.toggleSelection(scope.displayedCollection[1]); + expect(scope.dataCollection[0].isSelected).not.toBe(true); + expect(scope.dataCollection[1].isSelected).toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + }); + + it('should emit event when being selected', inject(function ($rootScope) { + var eventHanlder = { + listener: function (event, args) { + expect(args.item).toEqual(scope.displayedCollection[0]); + expect(args.item.isSelected).toBe(true); + } + }; + spyOn(eventHanlder, 'listener').andCallThrough(); + $rootScope.$on('selectionChange', eventHanlder.listener); + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(eventHanlder.listener).toHaveBeenCalled(); + })); + + it('should emit event when being unselected', inject(function ($rootScope) { + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.displayedCollection[0].isSelected).toBe(true); + + var callCounter = 0; + var eventHanlder = { + listener: function (event, args) { + + //first time call : unselect the previously selected + if (callCounter === 0) { + expect(args.item).toEqual(scope.displayedCollection[0]); + expect(args.item.isSelected).toBe(false); + callCounter++; + } else { + expect(args.item).toEqual(scope.displayedCollection[1]); + expect(args.item.isSelected).toBe(true); + } + } + }; + spyOn(eventHanlder, 'listener').andCallThrough(); + $rootScope.$on('selectionChange', eventHanlder.listener); + ctrl.toggleSelection(scope.displayedCollection[1]); + expect(eventHanlder.listener.callCount).toBe(2); + })); + + it('should unselect', function () { + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).toBe(true); + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).not.toBe(true); + }); + + it('should not select any row when calling toggleSelectAll', function () { + ctrl.toggleSelectionAll(true); + expect(scope.dataCollection[0].isSelected).not.toBe(true); + expect(scope.dataCollection[1].isSelected).not.toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + }); + }); + + describe('selection in selection mode multiple', function () { + + beforeEach(function () { + scope.selectionMode = 'multiple'; + + scope.displayedCollection = scope.dataCollection = [ + {id: 0, secondProperty: true, thirdProperty: 1}, + {id: 1, secondProperty: true, thirdProperty: 2}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]; + }); + + it('should set isSelected=true to any row', function () { + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).toBe(true); + expect(scope.dataCollection[1].isSelected).not.toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + + ctrl.toggleSelection(scope.displayedCollection[1]); + expect(scope.dataCollection[0].isSelected).toBe(true); + expect(scope.dataCollection[1].isSelected).toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + }); + + it('should unselect any row', function () { + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).toBe(true); + expect(scope.dataCollection[1].isSelected).not.toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(scope.dataCollection[0].isSelected).not.toBe(true); + expect(scope.dataCollection[1].isSelected).not.toBe(true); + expect(scope.dataCollection[2].isSelected).not.toBe(true); + }); + + it('should select all the displayed row when calling toggleSelectAll with true', function () { + ctrl.toggleSelectionAll(true); + expect(scope.displayedCollection[0].isSelected).toBe(true); + expect(scope.displayedCollection[1].isSelected).toBe(true); + expect(scope.displayedCollection[2].isSelected).toBe(true); + + scope.displayedCollection[0].isSelected = false; + ctrl.toggleSelectionAll(true); + expect(scope.displayedCollection[0].isSelected).toBe(true); + expect(scope.displayedCollection[1].isSelected).toBe(true); + expect(scope.displayedCollection[2].isSelected).toBe(true); + }); + + it('should unselect all the displayed row when calling toggleSelectAll with anything but true', function () { + scope.displayedCollection[0].isSelected = true; + scope.displayedCollection[1].isSelected = true; + ctrl.toggleSelectionAll('whatever'); + expect(scope.displayedCollection[0].isSelected).not.toBe(true); + expect(scope.displayedCollection[1].isSelected).not.toBe(true); + expect(scope.displayedCollection[2].isSelected).not.toBe(true); + + scope.displayedCollection[0].isSelected = true; + scope.displayedCollection[1].isSelected = true; + ctrl.toggleSelectionAll(false); + expect(scope.displayedCollection[0].isSelected).not.toBe(true); + expect(scope.displayedCollection[1].isSelected).not.toBe(true); + expect(scope.displayedCollection[2].isSelected).not.toBe(true); + }); + + it('should always emit an event', inject(function ($rootScope) { + var eventHanlder = { + listener: function (event, args) { + expect(args.item).toEqual(scope.displayedCollection[0]); + expect(args.item.isSelected).toEqual(scope.displayedCollection[0].isSelected); + } + }; + spyOn(eventHanlder, 'listener').andCallThrough(); + $rootScope.$on('selectionChange', eventHanlder.listener); + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(eventHanlder.listener).toHaveBeenCalled(); + ctrl.toggleSelection(scope.displayedCollection[0]); + expect(eventHanlder.listener).toHaveBeenCalled(); + })); + }); + }); + + it('should delete a row from displayed collection and from data collection', function () { + + ctrl.removeDataRow(0); + expect(scope.displayedCollection.length).toBe(2); + expect(scope.dataCollection.length).toBe(2); + expect(scope.displayedCollection).toEqual([ + {id: 1}, + {id: 2} + ]); + expect(scope.dataCollection).toEqual([ + {id: 1}, + {id: 2} + ]); + }); + + it('should not remove any dataRow as the index is wrong', function () { + ctrl.removeDataRow(-1); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.dataCollection.length).toBe(3); + ctrl.removeDataRow(5); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.dataCollection.length).toBe(3); + ctrl.removeDataRow('whatever'); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.dataCollection.length).toBe(3); + }); + + it('should move a row from a higher valid index to a lower valid index in the displayed Collection', function () { + ctrl.moveDataRow(2, 0); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.displayedCollection[0].id).toBe(2); + expect(scope.displayedCollection[2].id).toBe(1); + }); + + it('should move a row from a lower valid index to a higher valid index in the displayed Collection', function () { + ctrl.moveDataRow(0, 1); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.displayedCollection[1].id).toBe(0); + expect(scope.displayedCollection[0].id).toBe(1); + }); + + it('should not move any row with invalid index', function () { + ctrl.moveDataRow(-1, 1); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.displayedCollection).toEqual(refArray); + + ctrl.moveDataRow(1, 4); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.displayedCollection).toEqual(refArray); + + ctrl.moveDataRow(-666, 'whatever'); + expect(scope.displayedCollection.length).toBe(3); + expect(scope.displayedCollection).toEqual(refArray); + }); + }); + + describe('sort data rows', function () { + + var refArray = [ + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]; + + beforeEach(function () { + scope.displayedCollection = scope.dataCollection = [ + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]; + ctrl.insertColumn({map: 'id', isSortable: true}); + ctrl.insertColumn({map: 'secondProperty', isSortable: false}); + ctrl.insertColumn({map: 'thirdProperty', isSortable: true}); + }); + + it('should not sort the displayed collection when isSortable is false', function () { + ctrl.sortBy(scope.columns[1]); + expect(scope.displayedCollection).toEqual(refArray); + }); + + //not really unit test but more relevant here... + it('should sort by "map", first ascending then descending finally back to natural order', function () { + + ctrl.sortBy(scope.columns[2]); + expect(scope.displayedCollection).toEqual([ + {id: 2, secondProperty: true, thirdProperty: 1}, + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3} + ]); + + //switch to another column sortable + //by id + ctrl.sortBy(scope.columns[0]); + expect(scope.displayedCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]); + + //back to thirdProperty + ctrl.sortBy(scope.columns[2]); + expect(scope.displayedCollection).toEqual([ + {id: 2, secondProperty: true, thirdProperty: 1}, + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3} + ]); + + //descent + ctrl.sortBy(scope.columns[2]); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]); + + //natural order + ctrl.sortBy(scope.columns[2]); + expect(scope.displayedCollection).toEqual(refArray); + }); + }); + + describe('search data rows', function () { + + beforeEach(function () { + scope.itemsByPage = 10; + scope.displayedCollection = scope.dataCollection = [ + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]; + ctrl.insertColumn({map: 'id', isSortable: true}); + ctrl.insertColumn({map: 'secondProperty', isSortable: false}); + ctrl.insertColumn({map: 'thirdProperty', isSortable: true}); + }); + + it('should not filter items with a null property by default', function () { + scope.dataCollection.push({id: 4, secondProperty: true, thirdProperty: null}); + ctrl.search(''); + expect(scope.displayedCollection.length).toBe(4); + expect(scope.displayedCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2}, + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1}, + {id: 4, secondProperty: true, thirdProperty: null} + ]); + }); + + it('should search globally if we dont specify a proper cololumn', function () { + ctrl.search('1'); + expect(scope.displayedCollection.length).toBe(2); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]); + }); + + it('should search for only a given column if we provide proper column', function () { + ctrl.search('1', scope.columns[0]); + expect(scope.displayedCollection.length).toBe(1); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3} + ]); + }); + + it('should switch form one mode to another without any problem', function () { + ctrl.search('1'); + expect(scope.displayedCollection.length).toBe(2); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]); + + ctrl.search('1', scope.columns[0]); + expect(scope.displayedCollection.length).toBe(1); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3} + ]); + + ctrl.search('1'); + expect(scope.displayedCollection.length).toBe(2); + expect(scope.displayedCollection).toEqual([ + {id: 1, secondProperty: true, thirdProperty: 3}, + {id: 2, secondProperty: true, thirdProperty: 1} + ]); + }); + }); + + describe('update data row', function () { + beforeEach(function () { + scope.displayedCollection = scope.dataCollection = [ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'test'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]; + }); + + it('should update the proper data row with the proper value', function () { + ctrl.updateDataRow(scope.displayedCollection[0], 'id', 34); + expect(scope.displayedCollection).toEqual([ + {id: 34, secondProperty: true, thirdProperty: 2, more: {another: 'test'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + + expect(scope.dataCollection).toEqual([ + {id: 34, secondProperty: true, thirdProperty: 2, more: {another: 'test'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + }); + + it('should not update any data Row', function () { + ctrl.updateDataRow({id: 1, secondProperty: true, thirdProperty: 2}, 'id', 34); + expect(scope.displayedCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'test'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + + expect(scope.dataCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'test'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + }); + + it('should "create" a new property on the proper dataRow ', function () { + ctrl.updateDataRow(scope.displayedCollection[0], 'newProp', 'value'); + expect(scope.displayedCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'test'}, newProp: 'value'}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + + expect(scope.dataCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'test'}, newProp: 'value'}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + }); + + it('should work on multilevel object', function () { + ctrl.updateDataRow(scope.displayedCollection[0], 'more.another', 'validateTest'); + expect(scope.displayedCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'validateTest'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + + expect(scope.dataCollection).toEqual([ + {id: 0, secondProperty: true, thirdProperty: 2, more: {another: 'validateTest'}}, + {id: 1, secondProperty: true, thirdProperty: 3, more: {another: 'test'}}, + {id: 2, secondProperty: true, thirdProperty: 1, more: {another: 'test'}} + ]); + }); + + it('should emit an event', inject(function ($rootScope) { + var eventHandler = { + listener: function (event, args) { + expect(args.item).toEqual(scope.displayedCollection[0]); + } + }; + spyOn(eventHandler, 'listener'); + $rootScope.$on('updateDataRow', eventHandler.listener); + ctrl.updateDataRow(scope.displayedCollection[0], 'id', 2); + expect(eventHandler.listener).toHaveBeenCalled(); + })); + }); + }); +}); + + + http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/unit/UtilitiesSpec.js ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/unit/UtilitiesSpec.js b/3rdparty/javascript/bower_components/smart-table/test/unit/UtilitiesSpec.js new file mode 100644 index 0000000..b4cc66d --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/unit/UtilitiesSpec.js @@ -0,0 +1,219 @@ +describe('utilityModule Module', function () { + + var array; + + beforeEach(module('smartTable.utilities', function () { + + })); + + + describe('Array utilities', function () { + + beforeEach(function () { + array = [ + {id: 0}, + {id: 1}, + {id: 2} + ]; + }); + + it('should add item at proper index or put it at the end', inject(function (ArrayUtility) { + + var toInsert = {}; + //insert at index + ArrayUtility.insertAt(array, 1, toInsert); + expect(array.length).toBe(4); + expect(array[1]).toBe(toInsert); + + //at the end + ArrayUtility.insertAt(array, -4, toInsert); + expect(array.length).toBe(5); + expect(array[4]).toBe(toInsert); + + ArrayUtility.insertAt(array, 666, toInsert); + expect(array.length).toBe(6); + expect(array[5]).toBe(toInsert); + + ArrayUtility.insertAt(array, 'sfdsf', toInsert); + expect(array.length).toBe(7); + expect(array[6]).toBe(toInsert); + })); + + it('should remove item at proper index or do nothing', inject(function (ArrayUtility) { + + var removedElement = ArrayUtility.removeAt(array, 1); + expect(array.length).toBe(2); + expect(removedElement).toEqual({id: 1}); + + ArrayUtility.removeAt(array, -1); + expect(array.length).toBe(2); + + ArrayUtility.removeAt(array, 666); + expect(array.length).toBe(2); + + ArrayUtility.removeAt(array, '2323'); + expect(array.length).toBe(2); + })); + + it('should move an item from a lower index to an higher one', inject(function (ArrayUtility) { + ArrayUtility.moveAt(array, 0, 2); + expect(array.length).toBe(3); + expect(array[0].id).toBe(1); + expect(array[2].id).toBe(0); + })); + + it('should move an item from a higher index to an lower one', inject(function (ArrayUtility) { + ArrayUtility.moveAt(array, 2, 1); + expect(array.length).toBe(3); + expect(array[1].id).toBe(2); + expect(array[2].id).toBe(1); + })); + + it('should not move any item', inject(function (ArrayUtility) { + ArrayUtility.moveAt(array, -1, 2); + expect(array).toEqual([ + {id: 0}, + {id: 1}, + {id: 2} + ]); + ArrayUtility.moveAt(array, 1, 666); + expect(array).toEqual([ + {id: 0}, + {id: 1}, + {id: 2} + ]); + })); + + describe('sort array', function () { + var + predicate, + reverse; + + beforeEach(function () { + predicate = ''; + reverse = ''; + array = [ + {id: 0, name: 'laurent'}, + {id: 2, name: 'blandine'}, + {id: 1, name: 'francoise'} + ]; + }); + + + it('should return the array as it was if now algorithm is provided', inject(function (ArrayUtility) { + expect(ArrayUtility.sort(array, 'whaterver', predicate, reverse)).toEqual(array); + })); + + it('should sort array with provided algorithm', inject(function ($filter, ArrayUtility) { + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual($filter('orderBy')(array, predicate, false)); + expect(ArrayUtility.sort(array), $filter('orderBy'), predicate, reverse).toEqual(array); //(no predicate has been provided + + predicate = 'id'; + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual($filter('orderBy')(array, 'id', false)); + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual([ + {id: 0, name: 'laurent'}, + {id: 1, name: 'francoise'}, + {id: 2, name: 'blandine'} + ]); + + var sortMock = { + sortAlgo: function (array, predicate, reverse) { + return array; + } + }; + predicate = 'id'; + reverse = true; + spyOn(sortMock, 'sortAlgo'); + ArrayUtility.sort(array, sortMock.sortAlgo, predicate, reverse); + expect(sortMock.sortAlgo).toHaveBeenCalledWith(array, 'id', true); + + })); + + it('should sort with reverse =true only if it is explicit set', inject(function ($filter, ArrayUtility) { + predicate = 'id'; + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual($filter('orderBy')(array, 'id', false)); + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual([ + {id: 0, name: 'laurent'}, + {id: 1, name: 'francoise'}, + {id: 2, name: 'blandine'} + ]); + reverse = 'whatever'; + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual($filter('orderBy')(array, 'id', false)); + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual([ + {id: 0, name: 'laurent'}, + {id: 1, name: 'francoise'}, + {id: 2, name: 'blandine'} + ]); + reverse = true; + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual($filter('orderBy')(array, 'id', true)); + expect(ArrayUtility.sort(array, $filter('orderBy'), predicate, reverse)).toEqual([ + {id: 2, name: 'blandine'}, + {id: 1, name: 'francoise'}, + {id: 0, name: 'laurent'} + ]); + })); + }); + describe('filter utility', function () { + var predicate; + beforeEach(function () { + predicate = ''; + array = [ + {id: 0, name: 'laurent'}, + {id: 2, name: 'blandine'}, + {id: 1, name: 'francoise'} + ]; + }); + + it('should use provided algorithm or return input array', inject(function ($filter, ArrayUtility) { + expect(ArrayUtility.filter(array, 'whatever', predicate)).toEqual(array); + var filterMock = { + filterAlgo: function (array, predicate) { + return [array[0]]; + } + }; + spyOn(filterMock, 'filterAlgo').andCallThrough(); + predicate = 'whatever'; + var returnedArray = ArrayUtility.filter(array, filterMock.filterAlgo, predicate); + expect(filterMock.filterAlgo).toHaveBeenCalledWith(array, 'whatever'); + expect(returnedArray.length).toBe(1); + expect(returnedArray).toEqual([ + {id: 0, name: 'laurent'} + ]); + })); + }); + + describe('from/To', function () { + beforeEach(function () { + array = [ + {id: 0}, + {id: 1}, + {id: 2}, + {id: 3}, + {id: 4} + ]; + }); + + it('should return a part of the array', inject(function (ArrayUtility) { + var part = ArrayUtility.fromTo(array, 1, 3); + expect(part.length).toBe(3); + expect(part[0].id).toBe(1); + expect(part[1].id).toBe(2); + expect(part[2].id).toBe(3); + + part = ArrayUtility.fromTo(array, 3, 4); + expect(part.length).toBe(2); + expect(part[0].id).toBe(3); + expect(part[1].id).toBe(4); + + part = ArrayUtility.fromTo(array, -2, 2); + expect(part.length).toBe(2); + expect(part[0].id).toBe(0); + expect(part[1].id).toBe(1); + + part = ArrayUtility.fromTo(array, 1, -1); + expect(part.length).toBe(0); + })); + }); + + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/unit/directivesSpec.js ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/unit/directivesSpec.js b/3rdparty/javascript/bower_components/smart-table/test/unit/directivesSpec.js new file mode 100644 index 0000000..d5db5c2 --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/unit/directivesSpec.js @@ -0,0 +1,7 @@ +'use strict'; + +/* jasmine specs for directives go here */ + +describe('directives', function () { + +}); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/3rdparty/javascript/bower_components/smart-table/test/unit/filtersSpec.js ---------------------------------------------------------------------- diff --git a/3rdparty/javascript/bower_components/smart-table/test/unit/filtersSpec.js b/3rdparty/javascript/bower_components/smart-table/test/unit/filtersSpec.js new file mode 100644 index 0000000..8e9c271 --- /dev/null +++ b/3rdparty/javascript/bower_components/smart-table/test/unit/filtersSpec.js @@ -0,0 +1,78 @@ +describe('filter', function () { + + beforeEach(module('smartTable.filters')); + + describe('format filter', function () { + + var + filter, + format, + input, + parameter; + + beforeEach(inject(function ($injector) { + filter = $injector.get('$filter'); + format = filter('format'); + })); + + afterEach(function () { + input = ''; + parameter = ''; + }); + + it('should define format', function () { + expect(format).toBeDefined(); + }); + + it('should return the input value', function () { + input = 'input'; + expect(format(input)).toEqual(input); + }); + + it('should behave like date filter', function () { + input = new Date('2013/04/20'); + expect(format(input, 'date', parameter)).toEqual(filter('date')(input, parameter)); + parameter = 'MMMM'; + expect(format(input, 'date', parameter)).toEqual(filter('date')(input, parameter)); + }); + + it('should behave like currency filter', function () { + input = 2000; + expect(format(input, 'currency', parameter)).toEqual(filter('currency')(input, parameter)); + parameter = '$'; + expect(format(input, 'currency', parameter)).toEqual(filter('currency')(input), parameter); + }); + + it('should behave like json filter', function () { + input = {prop: 'value'}; + expect(format(input, 'json')).toEqual(filter('json')(input)); + }); + + it('should behave like lowercase filter', function () { + input = 'SldsrRS'; + expect(format(input, 'lowercase', parameter)).toEqual(filter('lowercase')(input, parameter)); + }); + + it('should behave like uppercase filter', function () { + input = 'SldsrRS'; + expect(format(input, 'uppercase', parameter)).toEqual(filter('uppercase')(input, parameter)); + }); + + it('should behave like number filter', function () { + input = 3434.34343; + expect(format(input, 'number', parameter)).toEqual(filter('number')(input, parameter)); + parameter = 2; + expect(format(input, 'number', parameter)).toEqual(filter('number')(input, parameter)); + }); + + it('should use the provided function', function () { + //will return the nth letter for example (dummy impl : no check on parameters etc) + var customFunction = function (value, parameter) { + return value[parameter - 1]; + }; + input = 'abcdefghij'; + expect(format(input, customFunction, 2)).toEqual('b'); + expect(format(input, customFunction, 3)).toEqual('c'); + }) + }); +}); http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java index 2ca89ff..5b25d52 100644 --- a/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java +++ b/src/main/java/org/apache/aurora/scheduler/http/ServletModule.java @@ -111,30 +111,26 @@ public class ServletModule extends AbstractModule { } private void registerJQueryAssets() { - registerAsset("bower_components/jquery/jquery.js", "/js/jquery.min.js", false); + registerAsset("bower_components/jquery/dist/jquery.js", "/js/jquery.min.js", false); } private void registerBootstrapAssets() { - final String BOOTSTRAP_PATH = "bower_components/bootstrap.css/"; + final String BOOTSTRAP_PATH = "bower_components/bootstrap/"; - registerAsset(BOOTSTRAP_PATH + "js/bootstrap.min.js", "/js/bootstrap.min.js", false); - registerAsset(BOOTSTRAP_PATH + "css/bootstrap.min.css", "/css/bootstrap.min.css", false); - registerAsset(BOOTSTRAP_PATH + "css/bootstrap-responsive.min.css", - "/css/bootstrap-responsive.min.css", + registerAsset(BOOTSTRAP_PATH + "dist/js/bootstrap.min.js", "/js/bootstrap.min.js", false); + registerAsset(BOOTSTRAP_PATH + "dist/css/bootstrap.min.css", "/css/bootstrap.min.css", false); + + registerAsset(BOOTSTRAP_PATH + "dist/fonts/glyphicons-halflings-regular.eot", + "/fonts/glyphicons-halflings-regular.eot", false); - registerAsset(BOOTSTRAP_PATH + "img/glyphicons-halflings-white.png", - "/img/glyphicons-halflings-white.png", + registerAsset(BOOTSTRAP_PATH + "dist/fonts/glyphicons-halflings-regular.svg", + "/fonts/glyphicons-halflings-regular.svg", false); - registerAsset(BOOTSTRAP_PATH + "img/glyphicons-halflings.png", - "/img/glyphicons-halflings.png", + registerAsset(BOOTSTRAP_PATH + "dist/fonts/glyphicons-halflings-regular.ttf", + "/fonts/glyphicons-halflings-regular.ttf", false); - - // Register a complete set of large glyphicons from bootstrap-glyphicons project at - // http://marcoceppi.github.io/bootstrap-glyphicons/ - // TODO(Suman Karumuri): Install the bootstrap-glyphicons via bower, once it is available. - registerAsset("bootstrap-glyphicons-master/glyphicons.png", "/img/glyphicons.png", false); - registerAsset("bootstrap-glyphicons-master/css/bootstrap.icon-large.min.css", - "/css/bootstrap.icon-large.min.css", + registerAsset(BOOTSTRAP_PATH + "dist/fonts/glyphicons-halflings-regular.woff", + "/fonts/glyphicons-halflings-regular.woff", false); } @@ -213,6 +209,15 @@ public class ServletModule extends AbstractModule { return MediaType.HTML_UTF_8; } else if (filePath.endsWith(".css")) { return MediaType.CSS_UTF_8; + } else if (filePath.endsWith(".svg")) { + return MediaType.SVG_UTF_8; + } else if (filePath.endsWith(".ttf") + || filePath.endsWith(".eot") + || filePath.endsWith(".woff")) { + + // MediaType doesn't have any mime types for fonts. Instead of magic strings, we let the + // browser interpret the mime type and modern browsers can do this well. + return MediaType.ANY_TYPE; } else { throw new IllegalArgumentException("Could not determine media type for " + filePath); } http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3a992e2c/src/main/resources/org/apache/aurora/scheduler/http/ui/breadcrumb.html ---------------------------------------------------------------------- diff --git a/src/main/resources/org/apache/aurora/scheduler/http/ui/breadcrumb.html b/src/main/resources/org/apache/aurora/scheduler/http/ui/breadcrumb.html index 23f0cdc..708ca37 100644 --- a/src/main/resources/org/apache/aurora/scheduler/http/ui/breadcrumb.html +++ b/src/main/resources/org/apache/aurora/scheduler/http/ui/breadcrumb.html @@ -1,15 +1,13 @@ -
+