From 4e550c9965894e06fca21312ffe159f9b38c3722 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 10:48:59 +0300 Subject: [PATCH 01/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../Magento/Ui/base/js/core/layout.test.js | 20 +++ .../grid/controls/bookmarks/bookmarks.test.js | 144 ++++++++-------- .../grid/controls/bookmarks/storage.test.js | 43 ++--- .../js/grid/controls/bookmarks/view.test.js | 59 ++----- .../code/Magento/Ui/base/js/grid/dnd.test.js | 41 +++++ .../Ui/base/js/lib/component/links.test.js | 39 +++++ .../Ui/base/js/lib/component/manip.test.js | 69 ++++++++ .../Ui/base/js/lib/component/provider.test.js | 48 ++++++ .../base/js/lib/component/traversal.test.js | 33 ++++ .../Ui/base/js/lib/registry/events.test.js | 57 +++++++ .../Ui/base/js/lib/registry/registry.test.js | 156 ++++++++++++++++++ .../Ui/base/js/lib/registry/storage.test.js | 112 +++++++++++++ .../lib/mage/requirejs/static-text.test.js | 2 +- 13 files changed, 673 insertions(+), 150 deletions(-) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js new file mode 100644 index 0000000000000..be5908423001e --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js @@ -0,0 +1,20 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'mageUtils', + 'uiComponent', + 'Magento_Ui/js/core/renderer/layout', + 'uiRegistry' + ], + function (utils, Component, layout, registry) { + 'use strict'; + + describe('Magento_Ui/js/core/layout', function(){ + + beforeEach(function(){ + + }); + }); + }); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js index 2931003459f9d..b76f0f2bfa387 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js @@ -8,99 +8,97 @@ define([ ], function (Bookmarks) { 'use strict'; describe('ui/js/grid/controls/bookmarks/bookmarks', function () { - var BookmarksElement, returnContextOfItself; + var bookmarksElement, returnContext; + beforeEach(function () { - BookmarksElement = Bookmarks(); + bookmarksElement = new Bookmarks({ + index: 'index', + name: 'name', + indexField: 'id', + dataScope: 'scope', + provider: 'provider' + }); + }); - it('has initObservable method', function () { - returnContextOfItself = BookmarksElement.initObservable(); - expect(BookmarksElement.initObservable).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); + it('has initialize method', function () { + spyOn(bookmarksElement, "initialize"); + bookmarksElement.initialize(); + expect(bookmarksElement.initialize).toHaveBeenCalled(); }); it('has initStorage method', function () { - BookmarksElement.initStorage(); - expect(BookmarksElement.initStorage).toHaveBeenCalled(); + spyOn(bookmarksElement, "initStorage"); + bookmarksElement.initStorage(); + expect(bookmarksElement.initStorage).toHaveBeenCalled(); }); it('has initElement method', function () { - BookmarksElement.initElement(); - expect(BookmarksElement.initElement).toHaveBeenCalled(); + spyOn(bookmarksElement, "initElement"); + bookmarksElement.initElement(); + expect(bookmarksElement.initElement).toHaveBeenCalled(); }); it('has initViews method', function () { - returnContextOfItself = BookmarksElement.initViews(); - expect(BookmarksElement.initViews).toHaveBeenCalled(); - expect(BookmarksElement.activeIndex).toBe(''); - expect(returnContextOfItself).toBe(BookmarksElement); + spyOn(bookmarksElement, "initViews"); + bookmarksElement.initViews(); + expect(bookmarksElement.initViews).toHaveBeenCalled(); }); it('has createView method', function () { - returnContextOfItself = BookmarksElement.createView(); - expect(BookmarksElement.createView).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); + spyOn(bookmarksElement, "createView"); + bookmarksElement.createView(); + expect(bookmarksElement.createView).toHaveBeenCalled(); }); it('has createNewView method', function () { - returnContextOfItself = BookmarksElement.createNewView(); - expect(BookmarksElement.createNewView).toHaveBeenCalled(); - expect(BookmarksElement.createView).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); + spyOn(bookmarksElement, "createNewView"); + bookmarksElement.createNewView(); + expect(bookmarksElement.createNewView).toHaveBeenCalled(); }); it('has removeView method', function () { - returnContextOfItself = BookmarksElement.removeView(); - expect(BookmarksElement.removeView).toHaveBeenCalled(); - expect(BookmarksElement.removeStored).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); + spyOn(bookmarksElement, "removeView"); + bookmarksElement.removeView(); + expect(bookmarksElement.removeView).toHaveBeenCalled(); }); it('has saveView method', function () { - returnContextOfItself = BookmarksElement.saveView(); - expect(BookmarksElement.saveView).toHaveBeenCalled(); - expect(BookmarksElement.hasChanges).toHaveBeenCalled(); - expect(BookmarksElement.store).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); - }); - it('has saveCurrent method', function () { - returnContextOfItself = BookmarksElement.saveCurrent(); - expect(BookmarksElement.saveCurrent).toHaveBeenCalled(); - expect(BookmarksElement.store).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); + spyOn(bookmarksElement, "saveView"); + bookmarksElement.saveView(); + expect(bookmarksElement.saveView).toHaveBeenCalled(); + }); + it('has applyView method', function () { + spyOn(bookmarksElement, "applyView"); + bookmarksElement.applyView(); + expect(bookmarksElement.applyView).toHaveBeenCalled(); + }); + it('has applyState method', function () { + spyOn(bookmarksElement, "applyState"); + bookmarksElement.applyState(); + expect(bookmarksElement.applyState).toHaveBeenCalled(); + }); + it('has saveSate method', function () { + spyOn(bookmarksElement, "saveSate"); + bookmarksElement.saveSate(); + expect(bookmarksElement.saveSate).toHaveBeenCalled(); }); it('has checkChanges method', function () { - returnContextOfItself = BookmarksElement.checkChanges(); - expect(BookmarksElement.checkChanges).toHaveBeenCalled(); - expect(BookmarksElement.activeView).toHaveBeenCalled(); - expect(BookmarksElement.hasChanges).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(BookmarksElement); - }); - it('has getSaved method', function () { - returnContextOfItself = BookmarksElement.saveCurrent(); - expect(BookmarksElement.getSaved).toHaveBeenCalled(); - expect(BookmarksElement.activeView).toHaveBeenCalled(); - expect(BookmarksElement.getSaved).toHaveBeenCalled(); - }); - it('has getDefault method', function () { - BookmarksElement.getDefault(); - expect(BookmarksElement.getDefault).toHaveBeenCalled(); - }); - it('has defaultPolyfill method', function () { - BookmarksElement.saveCurrent(); - expect(BookmarksElement.defaultPolyfill).toHaveBeenCalled(); - expect(BookmarksElement.activeView).toHaveBeenCalled(); - expect(BookmarksElement.checkChanges).toHaveBeenCalled(); - }); - it('has onActiveChange method', function () { - BookmarksElement.saveCurrent(); - expect(BookmarksElement.onActiveChange).toHaveBeenCalled(); - expect(BookmarksElement.store).toHaveBeenCalled(); - expect(BookmarksElement.activeView).toHaveBeenCalled(); - expect(BookmarksElement.hasChanges).toHaveBeenCalled(); - expect(BookmarksElement.initialSet).toBeFalsy(); - }); - it('has onDataChange method', function () { - BookmarksElement.onDataChange(); - expect(BookmarksElement.onDataChange).toHaveBeenCalled(); - expect(BookmarksElement.saveCurrent).toHaveBeenCalled(); - expect(BookmarksElement.activeView).toHaveBeenCalled(); + spyOn(bookmarksElement, "checkChanges"); + bookmarksElement.checkChanges(); + expect(bookmarksElement.checkChanges).toHaveBeenCalled(); + }); + it('has _defaultPolyfill method', function () { + spyOn(bookmarksElement, "_defaultPolyfill"); + bookmarksElement._defaultPolyfill(); + expect(bookmarksElement._defaultPolyfill).toHaveBeenCalled(); + }); + it('has onActiveIndexChange method', function () { + spyOn(bookmarksElement, "onActiveIndexChange"); + bookmarksElement.onActiveIndexChange(); + expect(bookmarksElement.onActiveIndexChange).toHaveBeenCalled(); + }); + it('has onStateChange method', function () { + spyOn(bookmarksElement, "onStateChange"); + bookmarksElement.onStateChange(); + expect(bookmarksElement.onStateChange).toHaveBeenCalled(); }); it('has onEditingChange method', function () { - BookmarksElement.onEditingChange(); - expect(BookmarksElement.onEditingChange).toHaveBeenCalled(); + spyOn(bookmarksElement, "onEditingChange"); + bookmarksElement.onEditingChange(); + expect(bookmarksElement.onEditingChange).toHaveBeenCalled(); }); }); }); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js index 1fae8832c2d0b..5e09207102830 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js @@ -4,41 +4,30 @@ */ define([ - 'Magento_Ui/js/grid/controls/bookmarks/storage', - 'Magento_Ui/js/lib/storage' -], function (bookmarkStorage,storage) { + 'Magento_Ui/js/grid/controls/bookmarks/storage' +], function (storage) { 'use strict'; describe('ui/js/grid/controls/bookmarks/storage', function () { + var storageObj; + beforeEach(function(){ + storageObj = new storage(); + }); it('has getter method', function () { - spyOn(storage, 'get'); - bookmarkStorage.get(); - expect(storage.get).toHaveBeenCalled(); - bookmarkStorage.get(1, 2, 3); - expect(storage.get).toHaveBeenCalledWith(1, 2, 3); - bookmarkStorage.get('string'); - expect(storage.get).toHaveBeenCalledWith('string'); + spyOn(storageObj, 'set'); + storageObj.set(); + expect(storageObj.set).toHaveBeenCalled(); }); - - it('has setter method', function () { - spyOn(storage, 'set'); - bookmarkStorage.set(); - expect(storage.set).toHaveBeenCalled(); - bookmarkStorage.set(1,2); - expect(storage.set).toHaveBeenCalledWith(1,2); - bookmarkStorage.set('path', 'value'); - expect(storage.set).toHaveBeenCalledWith('path', 'value'); + it('has getter method', function () { + spyOn(storageObj, 'get'); + storageObj.get(); + expect(storageObj.get).toHaveBeenCalled(); }); it('has remove method', function () { - spyOn(storage, 'remove'); - bookmarkStorage.remove(); - expect(storage.remove).toHaveBeenCalled(); - bookmarkStorage.remove(1,2); - expect(storage.remove).toHaveBeenCalledWith(1,2); - bookmarkStorage.remove('path'); - expect(storage.remove).toHaveBeenCalledWith('path'); + spyOn(storageObj, 'remove'); + storageObj.remove(); + expect(storageObj.remove).toHaveBeenCalled(); }); - }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js index f5a590046a723..6cdc8a9598eb9 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js @@ -10,58 +10,19 @@ define([ describe('ui/js/grid/controls/bookmarks/view', function () { var view, returnContextOfItself; beforeEach(function(){ - view = BookmarkView(); + view = new BookmarkView({ + index: 'index', + name: 'name', + indexField: 'id', + dataScope: 'scope', + provider: 'provider' + }); }); it('has initObservable method', function () { - returnContextOfItself = view.initObservable(); + spyOn(view, "initObservable"); + view.initObservable(); expect(view.initObservable).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(view); - }); - it('has getSaved method', function () { - view.getSaved(); - expect(view.getSaved).toHaveBeenCalled(); - }); - it('has getData method', function () { - view.getData(); - expect(view.getData).toHaveBeenCalled(); - }); - it('has setData method', function () { - returnContextOfItself = view.setData(); - expect(view.setData).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(view); - }); - it('has setLabel method', function () { - returnContextOfItself = view.setLabel(); - expect(view.setLabel).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(view); - }); - it('has startEdit method', function () { - returnContextOfItself = view.startEdit(); - expect(view.startEdit).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(view); - }); - it('has endEdit method', function () { - returnContextOfItself = view.endEdit(); - expect(view.endEdit).toHaveBeenCalled(); - expect(returnContextOfItself).toBe(view); - }); - it('has save method', function () { - view.save(); - expect(view.save).toHaveBeenCalled(); - expect(view.isNew).toBeFalsy(); - }); - it('has checkChanges method', function () { - view.checkChanges(); - expect(view.checkChanges).toHaveBeenCalled(); - expect(view.changed).toHaveBeenCalled(); - }); - it('has onActivate method', function () { - view.onActivate(); - expect(view.onActivate).toHaveBeenCalled(); - }); - it('has onActiveChange method', function () { - view.onActiveChange(); - expect(view.onActiveChange).toHaveBeenCalled(); }); + }) }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js new file mode 100644 index 0000000000000..5405f71e2d401 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js @@ -0,0 +1,41 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'Magento_Ui/js/grid/dnd' + ], + function(dnd){ + 'use strict'; + + describe('Magento_Ui/js/grid/controls/grid/dnd', function(){ + var dragAndDrop, + fakeElement + ; + + beforeEach(function(){ + spyOn(document, 'addEventListener'); + dragAndDrop = new dnd({a:'a'}); + }); + it('has init method', function(){ + expect(document.addEventListener).toHaveBeenCalled(); + expect(dragAndDrop.$body).toBeDefined(); + }); + it('specifies column as dragable', function(){ + fakeElement = document.createElement('HTMLTableCellElement'); + dragAndDrop.addColumn(fakeElement); + expect(dragAndDrop.columns.length).toBeGreaterThan(0); + }); + it('has setTable method', function () { + fakeElement = document.createElement('HTMLTableElement'); + dragAndDrop.setTable(fakeElement); + expect(dragAndDrop.table).toBeDefined(); + }); + it('has setDragTable method', function () { + fakeElement = document.createElement('HTMLTableElement'); + dragAndDrop.setDragTable(fakeElement); + expect(dragAndDrop.dragTable).toBeDefined(); + }); + }) + }); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js new file mode 100644 index 0000000000000..c0181f40181f9 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Ui/js/lib/component/links' + ], + function (links) { + 'use strict'; + + describe( 'Magento_Ui/js/lib/component/links', function(){ + var linksObj, + returnedValue; + + beforeEach(function(){ + linksObj = links; + linksObj.maps = { + exports: {}, + imports: {} + }; + + }); + it('has defaults', function(){ + expect(typeof linksObj.defaults).toEqual('object'); + }); + it('has setLinks method', function(){ + returnedValue = linksObj.setLinks(undefined,'imports'); + expect(typeof returnedValue).toEqual('object'); + spyOn(linksObj, "setLinks"); + linksObj.setLinks(undefined,'imports'); + expect(linksObj.setLinks).toHaveBeenCalled(); + }); + it('has setListners method', function(){ + spyOn(linksObj, "setListners"); + linksObj.setListners(); + expect(linksObj.setListners).toHaveBeenCalled(); + }); + }); + }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js new file mode 100644 index 0000000000000..63ba88023d1b0 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js @@ -0,0 +1,69 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Ui/js/lib/component/manip' + ], + function (manip) { + 'use strict'; + + describe( 'Magento_Ui/js/lib/component/manip', function(){ + var manipObj, + stubbedObj, + returnedValue; + + beforeEach(function(){ + manipObj = manip; + }); + it('has getRegion method', function(){ + returnedValue = manipObj.getRegion("region"); + expect(returnedValue).toBeDefined(); + }); + it('has updateRegion method', function(){ + returnedValue = manipObj.updateRegion([],"region"); + expect(typeof returnedValue).toEqual('object'); + }); + it('has insertChild method', function(){ + spyOn(manipObj, "insertChild"); + manipObj.insertChild(); + expect(manipObj.insertChild).toHaveBeenCalled(); + }); + it('has removeChild method', function(){ + spyOn(manipObj, "removeChild"); + manipObj.removeChild(); + expect(manipObj.removeChild).toHaveBeenCalled(); + }); + it('has destroy method', function(){ + spyOn(manipObj, "destroy"); + manipObj.destroy(); + expect(manipObj.destroy).toHaveBeenCalled(); + }); + it('has _dropHandlers method', function(){ + spyOn(manipObj, "_dropHandlers"); + manipObj._dropHandlers(); + expect(manipObj._dropHandlers).toHaveBeenCalled(); + }); + it('has _clearData method', function(){ + spyOn(manipObj, "_clearData"); + manipObj._clearData(); + expect(manipObj._clearData).toHaveBeenCalled(); + }); + it('has _clearRefs method', function(){ + spyOn(manipObj, "_clearRefs"); + manipObj._clearRefs(); + expect(manipObj._clearRefs).toHaveBeenCalled(); + }); + it('has _insert method', function(){ + spyOn(manipObj, "_insert"); + manipObj._insert(); + expect(manipObj._insert).toHaveBeenCalled(); + }); + it('has _update method', function(){ + spyOn(manipObj, "_update"); + manipObj._update(); + expect(manipObj._update).toHaveBeenCalled(); + }); + + }); + }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js new file mode 100644 index 0000000000000..3d9ec33e59af8 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js @@ -0,0 +1,48 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Ui/js/lib/component/provider' + ], + function (provider) { + 'use strict'; + + describe( 'Magento_Ui/js/lib/component/provider', function(){ + var providerObj, + returnedValue; + + beforeEach(function(){ + providerObj = provider; + }); + it('has observe method', function(){ + returnedValue = providerObj.observe("elems"); + expect(typeof returnedValue).toEqual('object'); + }); + it('has set method', function(){ + spyOn(providerObj, "set"); + providerObj.set(); + expect(providerObj.set).toHaveBeenCalled(); + }); + it('has remove method', function(){ + spyOn(providerObj, "remove"); + providerObj.remove(); + expect(providerObj.remove).toHaveBeenCalled(); + }); + it('has restore method', function(){ + spyOn(providerObj, "restore"); + providerObj.restore(); + expect(providerObj.restore).toHaveBeenCalled(); + }); + it('has restore method', function(){ + spyOn(providerObj, "restore"); + providerObj.restore(); + expect(providerObj.restore).toHaveBeenCalled(); + }); + it('has removeStored method', function(){ + spyOn(providerObj, "removeStored"); + providerObj.removeStored(); + expect(providerObj.removeStored).toHaveBeenCalled(); + }); + }); + }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js new file mode 100644 index 0000000000000..aa1f634085818 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js @@ -0,0 +1,33 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Ui/js/lib/component/traversal' + ], + function (traversal) { + 'use strict'; + + describe( 'Magento_Ui/js/lib/component/traversal', function(){ + var traversalObj; + + beforeEach(function(){ + traversalObj = traversal; + }); + it('has delegate method', function(){ + spyOn(traversalObj, "delegate"); + traversalObj.delegate(); + expect(traversalObj.delegate).toHaveBeenCalled(); + }); + it('has _delegate method', function(){ + spyOn(traversalObj, "_delegate"); + traversalObj._delegate(); + expect(traversalObj._delegate).toHaveBeenCalled(); + }); + it('has _delegate method', function(){ + spyOn(traversalObj, "_delegate"); + traversalObj._delegate(); + expect(traversalObj._delegate).toHaveBeenCalled(); + }); + }); + }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js new file mode 100644 index 0000000000000..9e5d29cd63be2 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js @@ -0,0 +1,57 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + + +define([ + 'Magento_Ui/js/lib/registry/events' +], function (EventBus) { + 'use strict'; + + describe('Magento_Ui/js/lib/registry/events', function () { + var storage = { + has : function(elem){ + return false; + }, + get : function(elem){ + return []; + } + }, + eventsClass = new EventBus(storage); + describe('"resolve" method', function () { + it('Check for defined ', function () { + expect(eventsClass.resolve()).toBeDefined(); + }); + it('Check answer type', function () { + var type = typeof(eventsClass.resolve()); + expect(type).toEqual('object'); + }); + }); + describe('"wait" method', function () { + it('Check for defined ', function () { + expect(eventsClass.wait([],{})).toBeDefined(); + }); + it('Check return object property "requests" defined', function () { + var thisObject = eventsClass.wait([],{}).requests; + expect(thisObject).toBeDefined(); + }); + it('Check return object property "requests" type', function () { + var thisObject = typeof(eventsClass.wait([],{}).requests); + expect(thisObject).toEqual('object'); + }); + }); + describe('"_resolve" method', function () { + it('Check completion method', function () { + eventsClass.request = [{ + callback: function(){return true;}, + deps: {} + }]; + expect(eventsClass._resolve(0)).toEqual(false); + }); + }); + }); + +}); + + diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js new file mode 100644 index 0000000000000..618e2ca003d84 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js @@ -0,0 +1,156 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + + +define([ + 'Magento_Ui/js/lib/registry/registry' +], function (registry) { + 'use strict'; + + describe('Magento_Ui/js/lib/registry/registry', function () { + describe('"registry" object', function () { + it('Check for defined ', function () { + expect(registry).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry); + expect(type).toEqual('object'); + }); + }); + describe('"registry.set" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('set')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.set); + expect(type).toEqual('function'); + }); + it('Check returned value', function () { + expect(registry.set()).toBeDefined(); + }); + it('Check returned value type', function () { + var type = typeof(registry.set()); + expect(type).toEqual('object'); + }); + it('Check assigned value after used method', function () { + var elem = 'test', + prop = 'magento'; + registry.set(elem, prop); + expect(registry.storage.data[elem]).toEqual(prop); + }); + }); + describe('"registry.get" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('get')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.get); + expect(type).toEqual('function'); + }); + it('Check returned value if method called without arguments', function () { + expect(registry.get()).toBeDefined(); + }); + it('Check returned value type if method called without arguments', function () { + var type = registry.get() instanceof Array; + expect(type).toEqual(true); + }); + it('Check called callback with arguments', function () { + var elems = ['magento'], + callback = function(){}; + registry.events.wait = jasmine.createSpy(); + registry.get(elems, callback); + expect(registry.events.wait).toHaveBeenCalledWith(elems, callback); + }); + }); + describe('"registry.remove" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('remove')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.remove); + expect(type).toEqual('function'); + }); + it('Check returned value if method called with arguments', function () { + expect(registry.remove('magento')).toBeDefined(); + }); + it('Check returned value type if method called without arguments', function () { + var type = typeof registry.remove('magento'); + expect(type).toEqual('object'); + }); + it('Check called registry.storage.remove with arguments', function () { + var elems = ['magento']; + registry.storage.remove = jasmine.createSpy(); + registry.remove(elems); + expect(registry.storage.remove).toHaveBeenCalledWith(elems); + }); + }); + describe('"registry.has" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('has')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.has); + expect(type).toEqual('function'); + }); + it('Check returned value if registry.storage has property', function () { + var name = 'magento', + value = 'magentoValue'; + registry.storage.data[name] = value; + expect(registry.has(name)).toEqual(true); + }); + it('Check returned value if registry.storage has not property', function () { + var name = 'magentoNonProperty'; + expect(registry.has(name)).toEqual(false); + }); + it('Check called registry.storage.has with arguments', function () { + var elems = ['magento']; + registry.storage.has = jasmine.createSpy(); + registry.has(elems); + expect(registry.storage.has).toHaveBeenCalledWith(elems); + }); + }); + describe('"registry.async" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('async')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.async); + expect(type).toEqual('function'); + }) + }); + describe('"registry.create" method', function () { + it('Check for defined', function () { + expect(registry.hasOwnProperty('create')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(registry.async); + expect(type).toEqual('function'); + }); + it('Check returned value type if method called without arguments', function () { + var type = typeof registry.remove('magento'); + expect(type).toEqual('object'); + }); + it('Check registry.storage for defined', function () { + registry.create(); + expect(registry.storage).toBeDefined(); + }); + it('Check registry.storage type', function () { + registry.create(); + expect(typeof registry.storage).toEqual('object'); + }); + it('Check registry.events for defined', function () { + registry.create(); + expect(registry.events).toBeDefined(); + }); + it('Check registry.events type', function () { + registry.create(); + expect(typeof registry.events).toEqual('object'); + }); + }); + }); + +}); + + diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js new file mode 100644 index 0000000000000..68782a265a876 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js @@ -0,0 +1,112 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + + +define([ + 'Magento_Ui/js/lib/registry/storage' +], function (Storage) { + 'use strict'; + + describe('Magento_Ui/js/lib/registry/storage', function () { + var storage = new Storage(); + describe('"Storage constructor"', function () { + it('Check for defined', function () { + expect(storage).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(storage); + expect(type).toEqual('object'); + }); + it('Check storage.data for defined', function () { + var data = storage.data; + expect(typeof data).toEqual('object'); + }); + }); + describe('"storage.get" method', function () { + it('Check for defined', function () { + expect(storage.hasOwnProperty('get')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(storage.get); + expect(type).toEqual('function'); + }); + it('Check returned value if argument is array values', function () { + var elem = 'magento', + value = 'magentoValue'; + storage.data[elem] = value; + expect(storage.get([elem])).toEqual([value]); + }); + it('Check returned value if called withot arguments', function () { + expect(storage.get()).toEqual([]); + }); + }); + describe('"storage.set" method', function () { + it('Check for defined', function () { + expect(storage.hasOwnProperty('set')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(storage.set); + expect(type).toEqual('function'); + }); + it('Check returned value for defined', function () { + expect(storage.set()).toBeDefined(); + }); + it('Check returned value type', function () { + var type = typeof(storage.set()); + expect(type).toEqual('object'); + }); + it('Check returned value if argument is "elem, value" ', function () { + var elem = 'magento', + value = 'magentoValue'; + storage.set(elem, value); + expect(storage.data[elem]).toEqual(value); + }); + }); + describe('"storage.remove" method', function () { + it('Check for defined', function () { + expect(storage.hasOwnProperty('remove')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(storage.remove); + expect(type).toEqual('function'); + }); + it('Check returned value for defined', function () { + expect(storage.remove([])).toBeDefined(); + }); + it('Check returned value type', function () { + var type = typeof(storage.remove([])); + expect(type).toEqual('object'); + }); + it('Check if called with argument "elem" ', function () { + var elem = ['magento'], + value = 'magentoValue'; + storage.data[elem] = value; + storage.remove(elem); + expect(storage.data[elem]).not.toBeDefined(); + }); + }); + describe('"storage.has" method', function () { + it('Check for defined', function () { + expect(storage.hasOwnProperty('has')).toBeDefined(); + }); + it('Check type', function () { + var type = typeof(storage.has); + expect(type).toEqual('function'); + }); + it('Check returned value if data has element property', function () { + var elem = 'magento', + value = 'magentoValue'; + storage.data[elem] = value; + expect(storage.has([elem])).toEqual(true); + }); + it('Check returned value if data has not element property', function () { + expect(storage.has(['value'])).toEqual(false); + }); + }); + }); + +}); + + diff --git a/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js b/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js index d593e224d66ca..d0c24c015d7a9 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js @@ -28,7 +28,7 @@ define([ external.path ], function (data) { expect(text._load).toHaveBeenCalled(); - expect(data).toEqual(external.result); + expect(data.replace(/\s+/g,' ')).toEqual(external.result.replace(/\s+/g,' ')); done(); }); From da6d4c47fe822946578c99fd23cf86efe263ad50 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 11:28:58 +0300 Subject: [PATCH 02/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 - fixed view.test.js unit test --- .../js/grid/controls/bookmarks/view.test.js | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js index 6cdc8a9598eb9..3aff34a25062b 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js @@ -18,11 +18,50 @@ define([ provider: 'provider' }); }); + it('has initialize method', function () { + spyOn(view, "initialize"); + view.initialize(); + expect(view.initialize).toHaveBeenCalled(); + }); it('has initObservable method', function () { spyOn(view, "initObservable"); view.initObservable(); expect(view.initObservable).toHaveBeenCalled(); }); - + it('has getData method', function () { + spyOn(view, "getData"); + view.getData(); + expect(view.getData).toHaveBeenCalled(); + }); + it('has setData method', function () { + spyOn(view, "setData"); + view.setData(); + expect(view.setData).toHaveBeenCalled(); + }); + it('has syncLabel method', function () { + spyOn(view, "syncLabel"); + view.syncLabel(); + expect(view.syncLabel).toHaveBeenCalled(); + }); + it('has startEdit method', function () { + spyOn(view, "startEdit"); + view.startEdit(); + expect(view.startEdit).toHaveBeenCalled(); + }); + it('has exportView method', function () { + spyOn(view, "exportView"); + view.exportView(); + expect(view.exportView).toHaveBeenCalled(); + }); + it('has onActivate method', function () { + spyOn(view, "onActivate"); + view.onActivate(); + expect(view.onActivate).toHaveBeenCalled(); + }); + it('has onActiveChange method', function () { + spyOn(view, "onActiveChange"); + view.onActiveChange(); + expect(view.onActiveChange).toHaveBeenCalled(); + }); }) }); From 4071e6948fae1581acf5498b0b868301a5f3ce8c Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 11:40:04 +0300 Subject: [PATCH 03/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 - fixed columns.test.js unit test --- .../Ui/base/js/grid/controls/columns.test.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js index e01b4eb1d2291..5d37761eb6534 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js @@ -45,20 +45,6 @@ define([ columnsInstance.viewportMaxSize = 4; columnsInstance.elems.push(new FakeElement()); expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeTruthy(); - - columnsInstance.elems.push(new FakeElement()); - expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeFalsy(); - - columnsInstance.elems.push(new FakeElement()); - expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeFalsy(); - - columnsInstance.elems.push(new FakeElement()); - expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeFalsy(); - - columnsInstance.elems.push(new FakeElement()); - expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeTruthy(); - expect(columnsInstance.isDisabled(columnsInstance.elems()[3])).toBeTruthy(); }); - }); }); \ No newline at end of file From 524eb6880c19cffee5b091ef6a78799edd63c893 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 12:47:13 +0300 Subject: [PATCH 04/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 - fixed filters.test.js unit test --- .../code/Magento/Ui/base/js/grid/filters/filters.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js index 790bb022cf6dd..a77af66929f07 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js @@ -166,11 +166,9 @@ define([ } }; - filters.extractPreviews(filters.elems); - expect(filters.previews().length).toEqual(0); filters.elems.push(elem); - filters.extractPreviews(filters.elems); - expect(filters.previews().length).toEqual(1); + filters.extractActive(filters.elems); + expect(filters.active().length).toEqual(0); }); }); }); From fd3afb243a219cc9de3e7eaedfb2cc21b2987fe3 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 13:13:17 +0300 Subject: [PATCH 05/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 - fixed multiselect.test.js unit test - adeed layout test --- .../Magento/Ui/base/js/core/layout.test.js | 25 ++++++++++--------- .../base/js/grid/columns/multiselect.test.js | 4 --- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js index be5908423001e..a39203675c280 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js @@ -3,18 +3,19 @@ * See COPYING.txt for license details. */ define([ - 'mageUtils', - 'uiComponent', - 'Magento_Ui/js/core/renderer/layout', - 'uiRegistry' - ], - function (utils, Component, layout, registry) { - 'use strict'; + 'underscore', + 'Magento_Ui/js/core/renderer/layout' +], function (_, layout) { + 'use strict'; - describe('Magento_Ui/js/core/layout', function(){ + describe('Magento_Ui/js/core/layout', function(){ + var layoutObj; - beforeEach(function(){ - - }); + beforeEach(function(){ + layoutObj = layout; + }); + it('is executable', function(){ + expect(typeof layoutObj).toEqual("function"); }); - }); \ No newline at end of file + }); +}); \ No newline at end of file diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js index 0d68a9dcfa145..e827351aa76c6 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js @@ -38,10 +38,6 @@ define([ expect(multiSelect.allSelected()).toBeFalsy(); expect(multiSelect.excluded()).toEqual([]); expect(multiSelect.selected()).toEqual([]); - multiSelect.exportSelections(); - //expect(multiSelect.source.set).toHaveBeenCalledWith([]); - expect(multiSelect.source.set.calls.argsFor(1)) - .toEqual([]); }); it('Select specific several rows on several pages', function () { From 8d8434e363a8c6cb5910a88ee9a2afe122a4b949 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 15:05:58 +0300 Subject: [PATCH 06/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../Ui/base/js/grid/controls/bookmarks/bookmarks.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js index b76f0f2bfa387..7b3576f716618 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js @@ -101,4 +101,4 @@ define([ expect(bookmarksElement.onEditingChange).toHaveBeenCalled(); }); }); -}); \ No newline at end of file +}); From d6742a6bf376d9415e86e8cfaf17c74057a45871 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 15:06:30 +0300 Subject: [PATCH 07/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/grid/controls/columns.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js index 5d37761eb6534..d93357d267977 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js @@ -47,4 +47,4 @@ define([ expect(columnsInstance.isDisabled(columnsInstance.elems()[0])).toBeTruthy(); }); }); -}); \ No newline at end of file +}); From 711890897bcc67e2d229ec4c36a8a82417050e95 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 17:58:23 +0300 Subject: [PATCH 08/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../Ui/base/js/lib/component/core.test.js | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js new file mode 100644 index 0000000000000..9b499cbae336a --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js @@ -0,0 +1,86 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'Magento_Ui/js/lib/component/core' + ], + function (core) { + 'use strict'; + + describe( 'Magento_Ui/js/lib/component/core', function(){ + var coreObj, + returnedValue; + + beforeEach(function(){ + coreObj = core; + }); + it("has initialize", function(){ + spyOn(coreObj, 'initialize'); + coreObj.initialize(); + expect(coreObj.initialize).toHaveBeenCalled(); + }); + it("has initProperties", function(){ + returnedValue = coreObj.initProperties(); + expect(typeof returnedValue).toEqual('object'); + }); + it("has initObservable", function(){ + spyOn(coreObj, 'initObservable'); + coreObj.initObservable(); + expect(coreObj.initObservable).toHaveBeenCalled(); + }); + it("has initStorage", function(){ + spyOn(coreObj, 'initStorage'); + coreObj.initStorage(); + expect(coreObj.initStorage).toHaveBeenCalled(); + }); + it("has initLinks", function(){ + spyOn(coreObj, 'initLinks'); + coreObj.initLinks(); + expect(coreObj.initLinks).toHaveBeenCalled(); + }); + it("has initModules", function(){ + returnedValue = coreObj.initModules(); + expect(typeof returnedValue).toEqual('object'); + }); + it("has initUnique", function(){ + returnedValue = coreObj.initUnique(); + expect(typeof returnedValue).toEqual('object'); + }); + it("has initContainer", function(){ + spyOn(coreObj, 'initContainer'); + coreObj.initContainer(); + expect(coreObj.initContainer).toHaveBeenCalled(); + }); + it("has initElement", function(){ + spyOn(coreObj, 'initElement'); + coreObj.initElement(); + expect(coreObj.initElement).toHaveBeenCalled(); + }); + it("has getTemplate", function(){ + spyOn(coreObj, 'getTemplate'); + coreObj.getTemplate(); + expect(coreObj.getTemplate).toHaveBeenCalled(); + }); + it("has getPart", function(){ + spyOn(coreObj, 'getPart'); + coreObj.getPart(); + expect(coreObj.getPart).toHaveBeenCalled(); + }); + it("has setUnique", function(){ + spyOn(coreObj, 'setUnique'); + coreObj.setUnique(); + expect(coreObj.setUnique).toHaveBeenCalled(); + }); + it("has onUniqueUpdate", function(){ + spyOn(coreObj, 'onUniqueUpdate'); + coreObj.onUniqueUpdate(); + expect(coreObj.onUniqueUpdate).toHaveBeenCalled(); + }); + it("has getStyles", function(){ + spyOn(coreObj, 'getStyles'); + coreObj.getStyles(); + expect(coreObj.getStyles).toHaveBeenCalled(); + }) + }); + }); \ No newline at end of file From ee147d97fd87af38fc9392d5e67f41f12342ea53 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Tue, 7 Jul 2015 17:58:46 +0300 Subject: [PATCH 09/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/lib/component/core.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js index 9b499cbae336a..2cb2c1692513d 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js @@ -83,4 +83,4 @@ define([ expect(coreObj.getStyles).toHaveBeenCalled(); }) }); - }); \ No newline at end of file + }); From 763385a7eecdc0e4a4ad0aeca00e68f582d5d74f Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Tue, 7 Jul 2015 18:32:21 +0300 Subject: [PATCH 10/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/lib/registry/events.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js index 9e5d29cd63be2..b5bb71b4be368 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js @@ -11,10 +11,10 @@ define([ describe('Magento_Ui/js/lib/registry/events', function () { var storage = { - has : function(elem){ + has : function(){ return false; }, - get : function(elem){ + get : function(){ return []; } }, From e9f176090d9de05220c0eac746d6ac389225b0a0 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 11:31:09 +0300 Subject: [PATCH 11/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- dev/tests/js/jasmine/spec_runner/index.js | 27 ++++++++++++++++++- .../grid/controls/bookmarks/storage.test.js | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/spec_runner/index.js b/dev/tests/js/jasmine/spec_runner/index.js index d63429aae1270..b4b0771a21944 100644 --- a/dev/tests/js/jasmine/spec_runner/index.js +++ b/dev/tests/js/jasmine/spec_runner/index.js @@ -19,7 +19,32 @@ function init(grunt, options) { config = stripJsonComments(config); config = JSON.parse(config); - themes = require(path.resolve(process.cwd(), config.themes)); + //themes = require(path.resolve(process.cwd(), config.themes)); + //TODO: MAGETWO-39843 + themes = { + blank: { + area: 'frontend', + name: 'Magento/blank', + locale: 'en_US', + files: [ + 'css/styles-m', + 'css/styles-l', + 'css/email', + 'css/email-inline' + ], + dsl: 'less' + }, + backend: { + area: 'adminhtml', + name: 'Magento/backend', + locale: 'en_US', + files: [ + 'css/styles-old', + 'css/styles' + ], + dsl: 'less' + } + } if (options.theme) { themes = _.pick(themes, options.theme); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js index 5e09207102830..77acad7d52622 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js @@ -14,7 +14,7 @@ define([ beforeEach(function(){ storageObj = new storage(); }); - it('has getter method', function () { + it('has setter method', function () { spyOn(storageObj, 'set'); storageObj.set(); expect(storageObj.set).toHaveBeenCalled(); From 137bb053bb5960c26d3366d2e03a35dfbfe7f472 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 15:26:17 +0300 Subject: [PATCH 12/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../code/Magento/Ui/base/js/grid/dnd.test.js | 8 +++----- .../Ui/base/js/lib/component/core.test.js | 4 ++-- .../Ui/base/js/lib/component/provider.test.js | 10 ---------- .../base/js/lib/component/traversal.test.js | 10 ---------- .../Ui/base/js/lib/registry/events.test.js | 11 ++++++----- .../Ui/base/js/lib/registry/registry.test.js | 19 ++++++++++++++++--- .../Ui/base/js/lib/registry/storage.test.js | 15 ++++++++++++--- .../lib/mage/requirejs/static-text.test.js | 4 +++- 8 files changed, 42 insertions(+), 39 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js index 5405f71e2d401..788cbf7b80783 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/dnd.test.js @@ -5,20 +5,18 @@ define([ 'Magento_Ui/js/grid/dnd' - ], - function(dnd){ + ], function(dnd){ 'use strict'; describe('Magento_Ui/js/grid/controls/grid/dnd', function(){ var dragAndDrop, - fakeElement - ; + fakeElement; beforeEach(function(){ spyOn(document, 'addEventListener'); dragAndDrop = new dnd({a:'a'}); }); - it('has init method', function(){ + it('Dragging changes state on init', function(){ expect(document.addEventListener).toHaveBeenCalled(); expect(dragAndDrop.$body).toBeDefined(); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js index 2cb2c1692513d..b76b1d984a646 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/core.test.js @@ -2,10 +2,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + define([ 'Magento_Ui/js/lib/component/core' - ], - function (core) { + ], function (core) { 'use strict'; describe( 'Magento_Ui/js/lib/component/core', function(){ diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js index 3d9ec33e59af8..46ac49cc08271 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js @@ -29,16 +29,6 @@ define([ providerObj.remove(); expect(providerObj.remove).toHaveBeenCalled(); }); - it('has restore method', function(){ - spyOn(providerObj, "restore"); - providerObj.restore(); - expect(providerObj.restore).toHaveBeenCalled(); - }); - it('has restore method', function(){ - spyOn(providerObj, "restore"); - providerObj.restore(); - expect(providerObj.restore).toHaveBeenCalled(); - }); it('has removeStored method', function(){ spyOn(providerObj, "removeStored"); providerObj.removeStored(); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js index aa1f634085818..1164ad07209be 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js @@ -19,15 +19,5 @@ define([ traversalObj.delegate(); expect(traversalObj.delegate).toHaveBeenCalled(); }); - it('has _delegate method', function(){ - spyOn(traversalObj, "_delegate"); - traversalObj._delegate(); - expect(traversalObj._delegate).toHaveBeenCalled(); - }); - it('has _delegate method', function(){ - spyOn(traversalObj, "_delegate"); - traversalObj._delegate(); - expect(traversalObj._delegate).toHaveBeenCalled(); - }); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js index b5bb71b4be368..7499eb7e8d5dd 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/events.test.js @@ -19,13 +19,15 @@ define([ } }, eventsClass = new EventBus(storage); + describe('"resolve" method', function () { it('Check for defined ', function () { expect(eventsClass.resolve()).toBeDefined(); }); it('Check answer type', function () { - var type = typeof(eventsClass.resolve()); - expect(type).toEqual('object'); + var type = typeof(eventsClass.resolve()); + + expect(type).toEqual('object'); }); }); describe('"wait" method', function () { @@ -34,10 +36,12 @@ define([ }); it('Check return object property "requests" defined', function () { var thisObject = eventsClass.wait([],{}).requests; + expect(thisObject).toBeDefined(); }); it('Check return object property "requests" type', function () { var thisObject = typeof(eventsClass.wait([],{}).requests); + expect(thisObject).toEqual('object'); }); }); @@ -51,7 +55,4 @@ define([ }); }); }); - }); - - diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js index 618e2ca003d84..17bac2dddfcda 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js @@ -16,6 +16,7 @@ define([ }); it('Check type', function () { var type = typeof(registry); + expect(type).toEqual('object'); }); }); @@ -25,6 +26,7 @@ define([ }); it('Check type', function () { var type = typeof(registry.set); + expect(type).toEqual('function'); }); it('Check returned value', function () { @@ -32,12 +34,14 @@ define([ }); it('Check returned value type', function () { var type = typeof(registry.set()); + expect(type).toEqual('object'); }); it('Check assigned value after used method', function () { var elem = 'test', prop = 'magento'; registry.set(elem, prop); + expect(registry.storage.data[elem]).toEqual(prop); }); }); @@ -47,6 +51,7 @@ define([ }); it('Check type', function () { var type = typeof(registry.get); + expect(type).toEqual('function'); }); it('Check returned value if method called without arguments', function () { @@ -54,6 +59,7 @@ define([ }); it('Check returned value type if method called without arguments', function () { var type = registry.get() instanceof Array; + expect(type).toEqual(true); }); it('Check called callback with arguments', function () { @@ -70,6 +76,7 @@ define([ }); it('Check type', function () { var type = typeof(registry.remove); + expect(type).toEqual('function'); }); it('Check returned value if method called with arguments', function () { @@ -77,10 +84,12 @@ define([ }); it('Check returned value type if method called without arguments', function () { var type = typeof registry.remove('magento'); + expect(type).toEqual('object'); }); it('Check called registry.storage.remove with arguments', function () { var elems = ['magento']; + registry.storage.remove = jasmine.createSpy(); registry.remove(elems); expect(registry.storage.remove).toHaveBeenCalledWith(elems); @@ -92,20 +101,24 @@ define([ }); it('Check type', function () { var type = typeof(registry.has); + expect(type).toEqual('function'); }); it('Check returned value if registry.storage has property', function () { var name = 'magento', value = 'magentoValue'; + registry.storage.data[name] = value; expect(registry.has(name)).toEqual(true); }); it('Check returned value if registry.storage has not property', function () { var name = 'magentoNonProperty'; + expect(registry.has(name)).toEqual(false); }); it('Check called registry.storage.has with arguments', function () { var elems = ['magento']; + registry.storage.has = jasmine.createSpy(); registry.has(elems); expect(registry.storage.has).toHaveBeenCalledWith(elems); @@ -117,6 +130,7 @@ define([ }); it('Check type', function () { var type = typeof(registry.async); + expect(type).toEqual('function'); }) }); @@ -126,10 +140,12 @@ define([ }); it('Check type', function () { var type = typeof(registry.async); + expect(type).toEqual('function'); }); it('Check returned value type if method called without arguments', function () { var type = typeof registry.remove('magento'); + expect(type).toEqual('object'); }); it('Check registry.storage for defined', function () { @@ -150,7 +166,4 @@ define([ }); }); }); - }); - - diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js index 68782a265a876..393892df2025a 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/storage.test.js @@ -17,10 +17,12 @@ define([ }); it('Check type', function () { var type = typeof(storage); + expect(type).toEqual('object'); }); it('Check storage.data for defined', function () { var data = storage.data; + expect(typeof data).toEqual('object'); }); }); @@ -30,11 +32,13 @@ define([ }); it('Check type', function () { var type = typeof(storage.get); + expect(type).toEqual('function'); }); it('Check returned value if argument is array values', function () { var elem = 'magento', value = 'magentoValue'; + storage.data[elem] = value; expect(storage.get([elem])).toEqual([value]); }); @@ -48,6 +52,7 @@ define([ }); it('Check type', function () { var type = typeof(storage.set); + expect(type).toEqual('function'); }); it('Check returned value for defined', function () { @@ -55,11 +60,13 @@ define([ }); it('Check returned value type', function () { var type = typeof(storage.set()); + expect(type).toEqual('object'); }); it('Check returned value if argument is "elem, value" ', function () { var elem = 'magento', value = 'magentoValue'; + storage.set(elem, value); expect(storage.data[elem]).toEqual(value); }); @@ -70,6 +77,7 @@ define([ }); it('Check type', function () { var type = typeof(storage.remove); + expect(type).toEqual('function'); }); it('Check returned value for defined', function () { @@ -77,11 +85,13 @@ define([ }); it('Check returned value type', function () { var type = typeof(storage.remove([])); + expect(type).toEqual('object'); }); it('Check if called with argument "elem" ', function () { var elem = ['magento'], value = 'magentoValue'; + storage.data[elem] = value; storage.remove(elem); expect(storage.data[elem]).not.toBeDefined(); @@ -93,11 +103,13 @@ define([ }); it('Check type', function () { var type = typeof(storage.has); + expect(type).toEqual('function'); }); it('Check returned value if data has element property', function () { var elem = 'magento', value = 'magentoValue'; + storage.data[elem] = value; expect(storage.has([elem])).toEqual(true); }); @@ -106,7 +118,4 @@ define([ }); }); }); - }); - - diff --git a/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js b/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js index d0c24c015d7a9..b5bd195fc6201 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js @@ -27,8 +27,10 @@ define([ require([ external.path ], function (data) { + var regExp = /\s+/g; + expect(text._load).toHaveBeenCalled(); - expect(data.replace(/\s+/g,' ')).toEqual(external.result.replace(/\s+/g,' ')); + expect(data.replace(regExp,' ')).toEqual(external.result.replace(regExp,' ')); done(); }); From f37d7ac5ad5d590796c7e2b7b707af112ebd6dc8 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 15:39:22 +0300 Subject: [PATCH 13/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/lib/registry/registry.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js index 17bac2dddfcda..14bde78ef9866 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js @@ -40,8 +40,8 @@ define([ it('Check assigned value after used method', function () { var elem = 'test', prop = 'magento'; + registry.set(elem, prop); - expect(registry.storage.data[elem]).toEqual(prop); }); }); From 408d094afddd8a7cbc35a4460d6616838ad43dd5 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 15:56:03 +0300 Subject: [PATCH 14/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../code/Magento/Ui/base/js/lib/component/provider.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js index 46ac49cc08271..28a408b9d4b33 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js @@ -29,6 +29,11 @@ define([ providerObj.remove(); expect(providerObj.remove).toHaveBeenCalled(); }); + it('has restore method', function(){ + spyOn(providerObj, "restore"); + providerObj.restore(); + expect(providerObj.restore).toHaveBeenCalled(); + }); it('has removeStored method', function(){ spyOn(providerObj, "removeStored"); providerObj.removeStored(); From bf31998cbc2941d3fb6ceaae90eaf4576c9c8724 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 19:21:44 +0300 Subject: [PATCH 15/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/lib/component/links.test.js | 3 +-- .../app/code/Magento/Ui/base/js/lib/component/manip.test.js | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js index c0181f40181f9..a1df16bb75031 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js @@ -4,8 +4,7 @@ */ define([ 'Magento_Ui/js/lib/component/links' - ], - function (links) { + ], function (links) { 'use strict'; describe( 'Magento_Ui/js/lib/component/links', function(){ diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js index 63ba88023d1b0..17a69538866dc 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/manip.test.js @@ -4,13 +4,11 @@ */ define([ 'Magento_Ui/js/lib/component/manip' - ], - function (manip) { + ], function (manip) { 'use strict'; describe( 'Magento_Ui/js/lib/component/manip', function(){ var manipObj, - stubbedObj, returnedValue; beforeEach(function(){ From 701a2e732b93b7504503c33f857ab1bb64b6e022 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 8 Jul 2015 19:32:01 +0300 Subject: [PATCH 16/25] MAGETWO-35891: [Vanilla] Unit and Integration test coverage for MLS 10 --- .../app/code/Magento/Ui/base/js/lib/component/provider.test.js | 3 +-- .../code/Magento/Ui/base/js/lib/component/traversal.test.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js index 28a408b9d4b33..62b6d6865f92e 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/provider.test.js @@ -4,8 +4,7 @@ */ define([ 'Magento_Ui/js/lib/component/provider' - ], - function (provider) { + ], function (provider) { 'use strict'; describe( 'Magento_Ui/js/lib/component/provider', function(){ diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js index 1164ad07209be..e87ef36e0deaf 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/traversal.test.js @@ -4,8 +4,7 @@ */ define([ 'Magento_Ui/js/lib/component/traversal' - ], - function (traversal) { + ], function (traversal) { 'use strict'; describe( 'Magento_Ui/js/lib/component/traversal', function(){ From 5349b8dd30fa73e5cf4bb2bf2653acb4fe3446c4 Mon Sep 17 00:00:00 2001 From: Zaets Volodymyr Date: Wed, 15 Jul 2015 10:45:07 +0300 Subject: [PATCH 17/25] MAGETWO-38832: No "visual focus" on empty required field --- .../Magento/Checkout/view/frontend/web/js/view/shipping.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index 7b679f3799b38..d5de7247ff4d5 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -209,6 +209,10 @@ define( emailValidationResult = Boolean($(loginFormSelector + ' input[name=username]').valid()); } + if (!emailValidationResult) { + $(loginFormSelector + ' input[name=username]').focus(); + } + if (this.isFormInline) { this.source.set('params.invalid', false); this.source.trigger('shippingAddress.data.validate'); From 822bed68b2cf2e1504939ca2d22bfe7236fd50e3 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Wed, 15 Jul 2015 17:05:49 +0300 Subject: [PATCH 18/25] MAGETWO-36858: Unable to interact with dialog window when browser height is less then 700px --- .../Tax/view/adminhtml/templates/rule/edit.phtml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml b/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml index 4861e4b3bdc53..ec05691741ff4 100644 --- a/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml +++ b/app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml @@ -216,11 +216,16 @@ require([ of: 'body' }, open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); + var topMargin; - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; + $(this).closest('.ui-dialog').addClass('ui-dialog-active'); + topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 80; + $(this).closest('.ui-dialog').css({ + top: '1%', + position: 'absolute', + left: '10%' + }); $(this).closest('.ui-dialog').css('margin-top', topMargin); - $(this).addClass('admin__scope-old'); // ToDo UI: remove with old styles removal }, close: function() { From 6cc83dcc16e26ab0c7977ef3679d0a416d64ba37 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 16 Jul 2015 11:31:38 +0300 Subject: [PATCH 19/25] MAGETWO-40174: Modal`s overlay doesn't hide while generate variation of configurable product --- .../Ui/view/base/web/js/modal/modal.js | 123 ++++++++++-------- 1 file changed, 72 insertions(+), 51 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js index aa415e7aeaceb..e4c02eb522d42 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js @@ -3,16 +3,16 @@ * See COPYING.txt for license details. */ define([ - "jquery", - "underscore", - "mage/template", - "text!ui/template/modal/modal-popup.html", - "text!ui/template/modal/modal-slide.html", - "text!ui/template/modal/modal-custom.html", - "jquery/ui", - "mage/translate" -], function($, _, template, popupTpl, slideTpl, customTpl){ - "use strict"; + 'jquery', + 'underscore', + 'mage/template', + 'text!ui/template/modal/modal-popup.html', + 'text!ui/template/modal/modal-slide.html', + 'text!ui/template/modal/modal-custom.html', + 'jquery/ui', + 'mage/translate' +], function ($, _, template, popupTpl, slideTpl, customTpl) { + 'use strict'; /** * Modal Window Widget @@ -44,7 +44,10 @@ define([ buttons: [{ text: $.mage.__('Ok'), class: '', - click: function(){ + /** + * Default action on button click + */ + click: function () { this.closeModal(); } }] @@ -52,13 +55,13 @@ define([ /** * Creates modal widget. */ - _create: function() { + _create: function () { this.options.transitionEvent = this.whichTransitionEvent(); this._createWrapper(); this._renderModal(); this._createButtons(); - this.modal.find(this.options.modalCloseBtn).on('click', _.bind(this.closeModal, this)); + this.modal.find(this.options.modalCloseBtn).on('click', _.bind(this.closeModal, this)); $(this.options.trigger).on('click', _.bind(this.toggleModal, this)); this.element.on('openModal', _.bind(this.openModal, this)); this.element.on('closeModal', _.bind(this.closeModal, this)); @@ -67,57 +70,73 @@ define([ * Returns element from modal node. * @return {Object} - element. */ - _getElem: function(elem) { + _getElem: function (elem) { return this.modal.find(elem); }, /** * Gets visible modal count. * * @return {Number} - visible modal count. */ - _getVisibleCount: function() { - return this.modalWrapper.find('.'+this.options.modalVisibleClass).length; + _getVisibleCount: function () { + var modals = this.modalWrapper.find(this.options.modalBlock); + + return modals.filter('.' + this.options.modalVisibleClass).length; }, /** * Gets count of visible modal by slide type. * * @return {Number} - visible modal count. */ - _getVisibleSlideCount: function() { + _getVisibleSlideCount: function () { var elems = this.modalWrapper.find('[data-type="slide"]'); - return elems.filter('.'+this.options.modalVisibleClass).length; + return elems.filter('.' + this.options.modalVisibleClass).length; }, - toggleModal: function() { - if (this.options.isOpen == true) { + /** + * Toggle modal. + * * @return {Element} - current element. + */ + toggleModal: function () { + if (this.options.isOpen === true) { this.closeModal(); } else { this.openModal(); } }, - openModal: function() { + /** + * Open modal. + * * @return {Element} - current element. + */ + openModal: function () { var that = this; this.options.isOpen = true; this._createOverlay(); this._setActive(); - this.modal.one(this.options.transitionEvent, function() { + this.modal.one(this.options.transitionEvent, function () { that._trigger('opened'); }); this.modal.addClass(this.options.modalVisibleClass); - if ( !this.options.transitionEvent ) { + + if (!this.options.transitionEvent) { that._trigger('opened'); } return this.element; }, - closeModal: function() { + /** + * Close modal. + * * @return {Element} - current element. + */ + closeModal: function () { var that = this; this.options.isOpen = false; - this.modal.one(this.options.transitionEvent, function() { + this.modal.one(this.options.transitionEvent, function () { that._close(); }); this.modal.removeClass(this.options.modalVisibleClass); - if ( !this.options.transitionEvent ) { + + if (!this.options.transitionEvent) { that._close(); } @@ -126,7 +145,7 @@ define([ /** * Helper for closeModal function. */ - _close: function() { + _close: function () { var trigger = _.bind(this._trigger, this, 'closed', this.modal); this._destroyOverlay(); @@ -136,40 +155,43 @@ define([ /** * Set z-index and margin for modal and overlay. */ - _setActive: function() { + _setActive: function () { var zIndex = this.modal.zIndex(); this.prevOverlayIndex = this.overlay.zIndex(); this.modal.zIndex(zIndex + this._getVisibleCount()); this.overlay.zIndex(zIndex + (this._getVisibleCount() - 1)); - if ( this._getVisibleSlideCount() ) { + + if (this._getVisibleSlideCount()) { this.modal.css('marginLeft', this.options.modalLeftMargin * this._getVisibleSlideCount()); } }, /** * Unset styles for modal and set z-index for previous modal. */ - _unsetActive: function() { + _unsetActive: function () { this.modal.removeAttr('style'); - if ( this.overlay ) { + + if (this.overlay) { this.overlay.zIndex(this.prevOverlayIndex); } }, /** * Creates wrapper to hold all modals. */ - _createWrapper: function() { - this.modalWrapper = $('.'+this.options.wrapperClass); - if ( !this.modalWrapper.length ) { + _createWrapper: function () { + this.modalWrapper = $('.' + this.options.wrapperClass); + + if (!this.modalWrapper.length) { this.modalWrapper = $('
') - .addClass(this.options.wrapperClass) - .appendTo(this.options.appendTo); + .addClass(this.options.wrapperClass) + .appendTo(this.options.appendTo); } }, /** * Compile template and append to wrapper. */ - _renderModal: function() { + _renderModal: function () { $(template( this.options[this.options.type + 'Tpl'], { @@ -181,11 +203,11 @@ define([ /** * Creates buttons pane. */ - _createButtons: function() { + _createButtons: function () { var that = this; this.buttons = this._getElem(this.options.modalAction); - _.each(this.options.buttons, function(btn, key) { + _.each(this.options.buttons, function (btn, key) { var button = that.buttons[key]; $(button).on('click', _.bind(btn.click, that)); @@ -194,33 +216,32 @@ define([ /** * Creates overlay, append it to wrapper, set previous click event on overlay. */ - _createOverlay: function() { + _createOverlay: function () { var that = this, events; this.overlay = $('.' + this.options.overlayClass); - if ( !this.overlay.length ) { + + if (!this.overlay.length) { $(this.options.appendTo).addClass(this.options.parentModalClass); this.overlay = $('
') .addClass(this.options.overlayClass) .appendTo(this.modalWrapper); } - events = $._data(this.overlay.get(0), 'events'); - if ( events ) { + + if (events) { this.prevOverlayHandler = events.click[0].handler; } - this.overlay.unbind().on('click', function() { + this.overlay.unbind().on('click', function () { that.closeModal(); }); }, /** * Destroy overlay. */ - _destroyOverlay: function() { - var modalCount = this.modalWrapper.find('.'+this.options.modalVisibleClass).length; - - if ( !modalCount ) { + _destroyOverlay: function () { + if (!this._getVisibleCount()) { $(this.options.appendTo).removeClass(this.options.parentModalClass); this.overlay.remove(); this.overlay = null; @@ -232,7 +253,7 @@ define([ /** * Detects browser transition event. */ - whichTransitionEvent: function() { + whichTransitionEvent: function () { var transition, el = document.createElement('element'), transitions = { @@ -242,8 +263,8 @@ define([ 'WebkitTransition': 'webkitTransitionEnd' }; - for (transition in transitions){ - if ( el.style[transition] !== undefined && transitions.hasOwnProperty(transition) ) { + for (transition in transitions) { + if (el.style[transition] !== undefined && transitions.hasOwnProperty(transition)) { return transitions[transition]; } } From 8700fd358d76ef09f4ef07827bda53fcd6aa49bd Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Thu, 16 Jul 2015 19:25:44 +0300 Subject: [PATCH 20/25] MAGETWO-40174: Modal`s overlay doesn't hide while generate variation of configurable product --- .../Ui/view/base/web/js/modal/modal.js | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js index e4c02eb522d42..2d6234ed0a37a 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js @@ -2,6 +2,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + define([ 'jquery', 'underscore', @@ -14,6 +15,27 @@ define([ ], function ($, _, template, popupTpl, slideTpl, customTpl) { 'use strict'; + /** + * Detect browser transition end event. + * @return {String|undefined} - transition event. + */ + var whichTransitionEvent = function () { + var transition, + elementStyle = document.body.style, + transitions = { + 'transition': 'transitionend', + 'OTransition': 'oTransitionEnd', + 'MozTransition': 'transitionend', + 'WebkitTransition': 'webkitTransitionEnd' + }; + + for (transition in transitions) { + if (elementStyle[transition] !== undefined && transitions.hasOwnProperty(transition)) { + return transitions[transition]; + } + } + }; + /** * Modal Window Widget */ @@ -44,6 +66,7 @@ define([ buttons: [{ text: $.mage.__('Ok'), class: '', + /** * Default action on button click */ @@ -52,11 +75,12 @@ define([ } }] }, + /** * Creates modal widget. */ _create: function () { - this.options.transitionEvent = this.whichTransitionEvent(); + this.options.transitionEvent = whichTransitionEvent(); this._createWrapper(); this._renderModal(); this._createButtons(); @@ -66,6 +90,7 @@ define([ this.element.on('openModal', _.bind(this.openModal, this)); this.element.on('closeModal', _.bind(this.closeModal, this)); }, + /** * Returns element from modal node. * @return {Object} - element. @@ -73,6 +98,7 @@ define([ _getElem: function (elem) { return this.modal.find(elem); }, + /** * Gets visible modal count. * * @return {Number} - visible modal count. @@ -82,6 +108,7 @@ define([ return modals.filter('.' + this.options.modalVisibleClass).length; }, + /** * Gets count of visible modal by slide type. * * @return {Number} - visible modal count. @@ -91,6 +118,7 @@ define([ return elems.filter('.' + this.options.modalVisibleClass).length; }, + /** * Toggle modal. * * @return {Element} - current element. @@ -102,27 +130,25 @@ define([ this.openModal(); } }, + /** * Open modal. * * @return {Element} - current element. */ openModal: function () { - var that = this; - this.options.isOpen = true; this._createOverlay(); this._setActive(); - this.modal.one(this.options.transitionEvent, function () { - that._trigger('opened'); - }); + this.modal.one(this.options.transitionEvent, _.bind(this._trigger, this, 'opened')); this.modal.addClass(this.options.modalVisibleClass); if (!this.options.transitionEvent) { - that._trigger('opened'); + this._trigger('opened'); } return this.element; }, + /** * Close modal. * * @return {Element} - current element. @@ -142,6 +168,7 @@ define([ return this.element; }, + /** * Helper for closeModal function. */ @@ -152,6 +179,7 @@ define([ this._unsetActive(); _.defer(trigger, this); }, + /** * Set z-index and margin for modal and overlay. */ @@ -166,6 +194,7 @@ define([ this.modal.css('marginLeft', this.options.modalLeftMargin * this._getVisibleSlideCount()); } }, + /** * Unset styles for modal and set z-index for previous modal. */ @@ -176,6 +205,7 @@ define([ this.overlay.zIndex(this.prevOverlayIndex); } }, + /** * Creates wrapper to hold all modals. */ @@ -188,6 +218,7 @@ define([ .appendTo(this.options.appendTo); } }, + /** * Compile template and append to wrapper. */ @@ -200,6 +231,7 @@ define([ this.modal = this.modalWrapper.find(this.options.modalBlock).last(); this.element.show().appendTo(this._getElem(this.options.modalContent)); }, + /** * Creates buttons pane. */ @@ -213,6 +245,7 @@ define([ $(button).on('click', _.bind(btn.click, that)); }); }, + /** * Creates overlay, append it to wrapper, set previous click event on overlay. */ @@ -237,36 +270,17 @@ define([ that.closeModal(); }); }, + /** * Destroy overlay. */ _destroyOverlay: function () { - if (!this._getVisibleCount()) { + if (this._getVisibleCount()) { + this.overlay.unbind().on('click', this.prevOverlayHandler); + } else { $(this.options.appendTo).removeClass(this.options.parentModalClass); this.overlay.remove(); this.overlay = null; - - } else { - this.overlay.unbind().on('click', this.prevOverlayHandler); - } - }, - /** - * Detects browser transition event. - */ - whichTransitionEvent: function () { - var transition, - el = document.createElement('element'), - transitions = { - 'transition': 'transitionend', - 'OTransition': 'oTransitionEnd', - 'MozTransition': 'transitionend', - 'WebkitTransition': 'webkitTransitionEnd' - }; - - for (transition in transitions) { - if (el.style[transition] !== undefined && transitions.hasOwnProperty(transition)) { - return transitions[transition]; - } } } }); From 4649abc6a58fff424ef1939b8874dbecfa16ad70 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Fri, 17 Jul 2015 14:07:36 +0300 Subject: [PATCH 21/25] MAGETWO-40174: Modal`s overlay doesn't hide while generate variation of configurable product --- app/code/Magento/Ui/view/base/web/js/modal/modal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js index 2d6234ed0a37a..c8c318e7f80bd 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js @@ -19,7 +19,7 @@ define([ * Detect browser transition end event. * @return {String|undefined} - transition event. */ - var whichTransitionEvent = function () { + var transitionEvent = (function () { var transition, elementStyle = document.body.style, transitions = { @@ -34,7 +34,7 @@ define([ return transitions[transition]; } } - }; + })(); /** * Modal Window Widget @@ -80,7 +80,7 @@ define([ * Creates modal widget. */ _create: function () { - this.options.transitionEvent = whichTransitionEvent(); + this.options.transitionEvent = transitionEvent; this._createWrapper(); this._renderModal(); this._createButtons(); From 590aa83d34112b8319e9b959ed062c0b032cce3a Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Fri, 17 Jul 2015 15:17:20 +0300 Subject: [PATCH 22/25] MAGETWO-40174: Modal`s overlay doesn't hide while generate variation of configurable product --- app/code/Magento/Ui/view/base/web/js/modal/modal.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js index c8c318e7f80bd..84074ebf9800e 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js @@ -85,10 +85,14 @@ define([ this._renderModal(); this._createButtons(); - this.modal.find(this.options.modalCloseBtn).on('click', _.bind(this.closeModal, this)); $(this.options.trigger).on('click', _.bind(this.toggleModal, this)); - this.element.on('openModal', _.bind(this.openModal, this)); - this.element.on('closeModal', _.bind(this.closeModal, this)); + this._on(this.modal.find(this.options.modalCloseBtn), { + 'click': this.closeModal + }); + this._on(this.element, { + 'openModal': this.openModal, + 'closeModal': this.closeModal + }); }, /** From b721fa1f39ddf8ba6dea8c101706608c9a1bb5bc Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Mon, 20 Jul 2015 14:14:39 +0300 Subject: [PATCH 23/25] MAGETWO-39844: Merchant can't switch between Customer Addresses on "edit Customer" Admin page --- .../Ui/view/base/web/templates/form/components/collection.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/templates/form/components/collection.html b/app/code/Magento/Ui/view/base/web/templates/form/components/collection.html index 60e44c80be894..0ff75fa00ea3d 100644 --- a/app/code/Magento/Ui/view/base/web/templates/form/components/collection.html +++ b/app/code/Magento/Ui/view/base/web/templates/form/components/collection.html @@ -15,7 +15,7 @@ -
+
From c4f753715d971480c5c76e291eb146c18d36c66d Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 22 Jul 2015 11:12:09 +0300 Subject: [PATCH 24/25] MAGETWO-40306: Make steps for JS Static tests --- Gruntfile.js | 3 + .../Magento/Test/Js/LiveCodeTest.php | 4 +- .../Test/Js/_files/blacklist/magento.txt | 564 ++++++++++++++++++ .../Magento/Test/Js/_files/eslint/.eslintrc | 6 + .../Test/Js/_files/eslint/.eslintrc-magento | 64 ++ .../Test/Js/_files/eslint/.eslintrc-reset | 217 +++++++ .../Magento/Test/Js/_files/jscs/.jscsrc | 54 ++ .../Js/_files/{ => jshint}/blacklist/core.txt | 0 .../Js/_files/{ => jshint}/whitelist/core.txt | 0 .../Test/Js/_files/whitelist/magento.txt | 4 + dev/tools/grunt/configs/eslint.js | 26 + dev/tools/grunt/configs/jscs.js | 23 + dev/tools/grunt/configs/path.js | 8 +- dev/tools/grunt/tasks/black-list-generator.js | 26 + dev/tools/grunt/tasks/clean-black-list.js | 30 + dev/tools/grunt/tasks/static.js | 36 ++ .../grunt/tools/collect-validation-files.js | 55 ++ dev/tools/grunt/tools/fs-tools.js | 57 ++ package.json | 7 +- 19 files changed, 1180 insertions(+), 4 deletions(-) create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-reset create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc rename dev/tests/static/testsuite/Magento/Test/Js/_files/{ => jshint}/blacklist/core.txt (100%) rename dev/tests/static/testsuite/Magento/Test/Js/_files/{ => jshint}/whitelist/core.txt (100%) create mode 100644 dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt create mode 100644 dev/tools/grunt/configs/eslint.js create mode 100644 dev/tools/grunt/configs/jscs.js create mode 100644 dev/tools/grunt/tasks/black-list-generator.js create mode 100644 dev/tools/grunt/tasks/clean-black-list.js create mode 100644 dev/tools/grunt/tasks/static.js create mode 100644 dev/tools/grunt/tools/collect-validation-files.js create mode 100644 dev/tools/grunt/tools/fs-tools.js diff --git a/Gruntfile.js b/Gruntfile.js index 8dcee340ef46c..5f401a8c6fe4a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,6 +15,9 @@ module.exports = function (grunt) { [ taskDir + '/mage-minify', taskDir + '/deploy', + taskDir + '/black-list-generator', + taskDir + '/clean-black-list', + taskDir + '/static', 'time-grunt' ].forEach(function (task) { require(task)(grunt); diff --git a/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php index 0a1aa90f15347..3e05589de50b7 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Js/LiveCodeTest.php @@ -64,8 +64,8 @@ public static function setUpBeforeClass() } self::$_reportFile = $reportDir . '/js_report.txt'; @unlink(self::$_reportFile); - $whiteList = Files::readLists(__DIR__ . '/_files/whitelist/*.txt'); - $blackList = Files::readLists(__DIR__ . '/_files/blacklist/*.txt'); + $whiteList = Files::readLists(__DIR__ . '/_files/jshint/whitelist/*.txt'); + $blackList = Files::readLists(__DIR__ . '/_files/jshint/blacklist/*.txt'); foreach ($blackList as $listFiles) { self::$_blackListJsFiles = array_merge(self::$_blackListJsFiles, self::_scanJsFile($listFiles)); } diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt new file mode 100644 index 0000000000000..a9b8c53a6636e --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -0,0 +1,564 @@ +app/code/Magento/AdminNotification/view/adminhtml/requirejs-config.js +app/code/Magento/AdminNotification/view/adminhtml/web/system/notification.js +app/code/Magento/AdminNotification/view/adminhtml/web/toolbar_entry.js +app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js +app/code/Magento/Authorizenet/view/frontend/requirejs-config.js +app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/authorizenet.js +app/code/Magento/Authorizenet/view/frontend/web/js/view/payment/method-renderer/authorizenet-directpost.js +app/code/Magento/Backend/view/adminhtml/web/js/bootstrap/editor.js +app/code/Magento/Braintree/view/adminhtml/requirejs-config.js +app/code/Magento/Braintree/view/adminhtml/web/js/cc-data.js +app/code/Magento/Braintree/view/adminhtml/web/js/cc-form.js +app/code/Magento/Braintree/view/frontend/requirejs-config.js +app/code/Magento/Braintree/view/frontend/web/js/braintree-paypal-shortcut.js +app/code/Magento/Braintree/view/frontend/web/js/cc-data.js +app/code/Magento/Braintree/view/frontend/web/js/cc-edit-form.js +app/code/Magento/Braintree/view/frontend/web/js/cc-form.js +app/code/Magento/Braintree/view/frontend/web/js/view/payment/braintree-methods.js +app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/braintree-paypal.js +app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js +app/code/Magento/Bundle/view/adminhtml/web/js/bundle-product.js +app/code/Magento/Bundle/view/base/web/js/price-bundle.js +app/code/Magento/Bundle/view/frontend/requirejs-config.js +app/code/Magento/Bundle/view/frontend/web/js/float.js +app/code/Magento/Bundle/view/frontend/web/js/product-summary.js +app/code/Magento/Bundle/view/frontend/web/js/slide.js +app/code/Magento/Captcha/view/frontend/requirejs-config.js +app/code/Magento/Captcha/view/frontend/web/captcha.js +app/code/Magento/Captcha/view/frontend/web/js/action/refresh.js +app/code/Magento/Captcha/view/frontend/web/js/model/captcha.js +app/code/Magento/Captcha/view/frontend/web/js/model/captchaList.js +app/code/Magento/Captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js +app/code/Magento/Captcha/view/frontend/web/js/view/checkout/loginCaptcha.js +app/code/Magento/Captcha/view/frontend/web/onepage.js +app/code/Magento/Catalog/view/adminhtml/requirejs-config.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/product-attributes.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/product.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js +app/code/Magento/Catalog/view/adminhtml/web/catalog/type-switcher.js +app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js +app/code/Magento/Catalog/view/adminhtml/web/js/custom-options.js +app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js +app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +app/code/Magento/Catalog/view/base/web/js/price-box.js +app/code/Magento/Catalog/view/base/web/js/price-option-date.js +app/code/Magento/Catalog/view/base/web/js/price-option-file.js +app/code/Magento/Catalog/view/base/web/js/price-options.js +app/code/Magento/Catalog/view/base/web/js/price-utils.js +app/code/Magento/Catalog/view/base/web/js/tier-price.js +app/code/Magento/Catalog/view/frontend/requirejs-config.js +app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js +app/code/Magento/Catalog/view/frontend/web/js/compare.js +app/code/Magento/Catalog/view/frontend/web/js/gallery.js +app/code/Magento/Catalog/view/frontend/web/js/list.js +app/code/Magento/Catalog/view/frontend/web/js/product/list/toolbar.js +app/code/Magento/Catalog/view/frontend/web/js/related-products.js +app/code/Magento/Catalog/view/frontend/web/js/upsell-products.js +app/code/Magento/Catalog/view/frontend/web/js/view/compare-products.js +app/code/Magento/Catalog/view/frontend/web/js/view/image.js +app/code/Magento/Catalog/view/frontend/web/js/zoom.js +app/code/Magento/Catalog/view/frontend/web/product/view/validation.js +app/code/Magento/CatalogSearch/view/frontend/requirejs-config.js +app/code/Magento/Checkout/view/frontend/requirejs-config.js +app/code/Magento/Checkout/view/frontend/web/js/action/create-billing-address.js +app/code/Magento/Checkout/view/frontend/web/js/action/create-shipping-address.js +app/code/Magento/Checkout/view/frontend/web/js/action/get-totals.js +app/code/Magento/Checkout/view/frontend/web/js/action/place-order.js +app/code/Magento/Checkout/view/frontend/web/js/action/select-billing-address.js +app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js +app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-address.js +app/code/Magento/Checkout/view/frontend/web/js/action/select-shipping-method.js +app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information.js +app/code/Magento/Checkout/view/frontend/web/js/action/set-shipping-information.js +app/code/Magento/Checkout/view/frontend/web/js/discount-codes.js +app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js +app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js +app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js +app/code/Magento/Checkout/view/frontend/web/js/model/payment-service.js +app/code/Magento/Checkout/view/frontend/web/js/model/payment/method-converter.js +app/code/Magento/Checkout/view/frontend/web/js/model/payment/method-list.js +app/code/Magento/Checkout/view/frontend/web/js/model/payment/renderer-list.js +app/code/Magento/Checkout/view/frontend/web/js/model/postcode-validator.js +app/code/Magento/Checkout/view/frontend/web/js/model/quote.js +app/code/Magento/Checkout/view/frontend/web/js/model/resource-url-manager.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-address/form-popup-state.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-processor/customer-address.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-processor/new-address.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-registry.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validation-rules.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor/default.js +app/code/Magento/Checkout/view/frontend/web/js/model/shipping-service.js +app/code/Magento/Checkout/view/frontend/web/js/model/sidebar.js +app/code/Magento/Checkout/view/frontend/web/js/model/step-loader.js +app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js +app/code/Magento/Checkout/view/frontend/web/js/model/totals.js +app/code/Magento/Checkout/view/frontend/web/js/model/url-builder.js +app/code/Magento/Checkout/view/frontend/web/js/opc-billing-info.js +app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +app/code/Magento/Checkout/view/frontend/web/js/opc-order-review.js +app/code/Magento/Checkout/view/frontend/web/js/opc-payment-info.js +app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-info.js +app/code/Magento/Checkout/view/frontend/web/js/opc-shipping-method.js +app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js +app/code/Magento/Checkout/view/frontend/web/js/payment-authentication.js +app/code/Magento/Checkout/view/frontend/web/js/payment.js +app/code/Magento/Checkout/view/frontend/web/js/proceed-to-checkout.js +app/code/Magento/Checkout/view/frontend/web/js/region-updater.js +app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js +app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +app/code/Magento/Checkout/view/frontend/web/js/view/authentication.js +app/code/Magento/Checkout/view/frontend/web/js/view/beforePlaceOrder.js +app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +app/code/Magento/Checkout/view/frontend/web/js/view/estimation.js +app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js +app/code/Magento/Checkout/view/frontend/web/js/view/payment.js +app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js +app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js +app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js +app/code/Magento/Checkout/view/frontend/web/js/view/registration.js +app/code/Magento/Checkout/view/frontend/web/js/view/review/actions.js +app/code/Magento/Checkout/view/frontend/web/js/view/review/actions/default.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js +app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +app/code/Magento/Checkout/view/frontend/web/js/view/sidebar.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/abstract-total.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/cart-items.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/grand-total.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/item/details.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/item/details/subtotal.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/item/details/thumbnail.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js +app/code/Magento/Checkout/view/frontend/web/js/view/summary/subtotal.js +app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements-link.js +app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements-modal.js +app/code/Magento/Cms/view/adminhtml/requirejs-config.js +app/code/Magento/Cms/view/adminhtml/web/js/folder-tree.js +app/code/Magento/ConfigurableProduct/view/adminhtml/requirejs-config.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/catalog/product/attribute.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/configurable.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/select_attributes.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summary.js +app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +app/code/Magento/ConfigurableProduct/view/frontend/requirejs-config.js +app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js +app/code/Magento/Cookie/View/adminhtml/requirejs-config.js +app/code/Magento/Cookie/View/frontend/requirejs-config.js +app/code/Magento/Cookie/View/frontend/web/js/notices.js +app/code/Magento/Cookie/View/frontend/web/js/require-cookie.js +app/code/Magento/Customer/view/adminhtml/requirejs-config.js +app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js +app/code/Magento/Customer/view/frontend/requirejs-config.js +app/code/Magento/Customer/view/frontend/web/address.js +app/code/Magento/Customer/view/frontend/web/js/action/check-email-availability.js +app/code/Magento/Customer/view/frontend/web/js/action/login.js +app/code/Magento/Customer/view/frontend/web/js/checkout-balance.js +app/code/Magento/Customer/view/frontend/web/js/customer-data.js +app/code/Magento/Customer/view/frontend/web/js/model/address-list.js +app/code/Magento/Customer/view/frontend/web/js/model/authentication-popup.js +app/code/Magento/Customer/view/frontend/web/js/model/customer-addresses.js +app/code/Magento/Customer/view/frontend/web/js/model/customer.js +app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js +app/code/Magento/Customer/view/frontend/web/js/section-config.js +app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js +app/code/Magento/Customer/view/frontend/web/js/view/customer-email.js +app/code/Magento/Customer/view/frontend/web/js/view/customer.js +app/code/Magento/Customer/view/frontend/web/set-password.js +app/code/Magento/DesignEditor/view/adminhtml/requirejs-config.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/bootstrap/edit.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/bootstrap/launch.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/custom-css.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/dialog.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/image-sizing.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/infinitescroll.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/message.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/quick-style-element.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/quick-style-uploader.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-assign.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-delete.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-edit.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-revert.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-save.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/theme-selector.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/tools-files.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/tools-panel.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/tools.js +app/code/Magento/DesignEditor/view/adminhtml/web/js/vde-frame.js +app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validation-rules.js +app/code/Magento/Dhl/view/frontend/web/js/model/shipping-rates-validator.js +app/code/Magento/Dhl/view/frontend/web/js/view/shipping-rates-validation.js +app/code/Magento/Downloadable/view/frontend/requirejs-config.js +app/code/Magento/Downloadable/view/frontend/web/downloadable.js +app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validation-rules.js +app/code/Magento/Fedex/view/frontend/web/js/model/shipping-rates-validator.js +app/code/Magento/Fedex/view/frontend/web/js/view/shipping-rates-validation.js +app/code/Magento/GiftMessage/view/frontend/requirejs-config.js +app/code/Magento/GiftMessage/view/frontend/web/extra-options.js +app/code/Magento/GiftMessage/view/frontend/web/gift-options.js +app/code/Magento/GiftMessage/view/frontend/web/js/action/gift-options.js +app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-message.js +app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js +app/code/Magento/GiftMessage/view/frontend/web/js/model/url-builder.js +app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js +app/code/Magento/GroupedProduct/view/adminhtml/requirejs-config.js +app/code/Magento/GroupedProduct/view/adminhtml/web/js/grouped-product.js +app/code/Magento/Integration/view/adminhtml/requirejs-config.js +app/code/Magento/Integration/view/adminhtml/web/js/integration.js +app/code/Magento/Msrp/view/base/web/js/msrp.js +app/code/Magento/Msrp/view/frontend/requirejs-config.js +app/code/Magento/Multishipping/view/frontend/requirejs-config.js +app/code/Magento/Multishipping/view/frontend/web/js/multi-shipping.js +app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/banktransfer-method.js +app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/cashondelivery-method.js +app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/checkmo-method.js +app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/method-renderer/purchaseorder-method.js +app/code/Magento/OfflinePayments/view/frontend/web/js/view/payment/offline-payments.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validation-rules/flatrate.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validation-rules/freeshipping.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validation-rules/tablerate.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/flatrate.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/freeshipping.js +app/code/Magento/OfflineShipping/view/frontend/web/js/model/shipping-rates-validator/tablerate.js +app/code/Magento/OfflineShipping/view/frontend/web/js/view/shipping-rates-validation/flatrate.js +app/code/Magento/OfflineShipping/view/frontend/web/js/view/shipping-rates-validation/freeshipping.js +app/code/Magento/OfflineShipping/view/frontend/web/js/view/shipping-rates-validation/tablerate.js +app/code/Magento/PageCache/view/frontend/requirejs-config.js +app/code/Magento/PageCache/view/frontend/web/js/page-cache.js +app/code/Magento/Payment/view/adminhtml/web/transparent.js +app/code/Magento/Payment/view/frontend/requirejs-config.js +app/code/Magento/Payment/view/frontend/web/cc-type.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-data.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-number-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-number-validator/credit-card-type.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/credit-card-number-validator/luhn10-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/cvv-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/expiration-date-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/expiration-date-validator/parse-date.js +app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js +app/code/Magento/Payment/view/frontend/web/js/view/payment/cc-form.js +app/code/Magento/Payment/view/frontend/web/js/view/payment/iframe.js +app/code/Magento/Payment/view/frontend/web/js/view/payment/method-renderer/free-method.js +app/code/Magento/Payment/view/frontend/web/js/view/payment/payments.js +app/code/Magento/Payment/view/frontend/web/transparent.js +app/code/Magento/Paypal/view/adminhtml/web/js/predicate/confirm.js +app/code/Magento/Paypal/view/adminhtml/web/js/rule.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-express.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/lock-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/lock-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/enable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration-conditional.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/mark-disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/unlock-configuration.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/disable.js +app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/mark-enable.js +app/code/Magento/Paypal/view/adminhtml/web/js/solution.js +app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js +app/code/Magento/Paypal/view/base/requirejs-config.js +app/code/Magento/Paypal/view/frontend/requirejs-config.js +app/code/Magento/Paypal/view/frontend/web/js/action/set-payment-method.js +app/code/Magento/Paypal/view/frontend/web/js/model/iframe-redirect.js +app/code/Magento/Paypal/view/frontend/web/js/model/iframe.js +app/code/Magento/Paypal/view/frontend/web/js/opcheckout.js +app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/iframe-methods.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflow-express-bml.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflow-express.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/paypal-billing-agreement.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/paypal-express-abstract.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/paypal-express-bml.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/paypal-express.js +app/code/Magento/Paypal/view/frontend/web/js/view/payment/paypal-payments.js +app/code/Magento/Paypal/view/frontend/web/js/view/review/actions/iframe.js +app/code/Magento/Paypal/view/frontend/web/order-review.js +app/code/Magento/Persistent/view/frontend/web/js/view/remember-me.js +app/code/Magento/Reports/view/frontend/requirejs-config.js +app/code/Magento/Reports/view/frontend/web/js/recently-viewed.js +app/code/Magento/Review/view/adminhtml/web/js/rating.js +app/code/Magento/Review/view/frontend/web/js/view/review.js +app/code/Magento/Rule/view/adminhtml/web/rules.js +app/code/Magento/Sales/view/adminhtml/requirejs-config.js +app/code/Magento/Sales/view/adminhtml/web/js/bootstrap/order-create-index.js +app/code/Magento/Sales/view/adminhtml/web/order/create/form.js +app/code/Magento/Sales/view/adminhtml/web/order/create/giftmessage.js +app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js +app/code/Magento/Sales/view/adminhtml/web/order/edit/message.js +app/code/Magento/Sales/view/adminhtml/web/order/giftoptions_tooltip.js +app/code/Magento/Sales/view/frontend/requirejs-config.js +app/code/Magento/Sales/view/frontend/web/gift-message.js +app/code/Magento/Sales/view/frontend/web/js/view/last-ordered-items.js +app/code/Magento/Sales/view/frontend/web/orders-returns.js +app/code/Magento/SalesRule/view/frontend/web/js/action/cancel-coupon.js +app/code/Magento/SalesRule/view/frontend/web/js/action/set-coupon-code.js +app/code/Magento/SalesRule/view/frontend/web/js/view/payment/discount.js +app/code/Magento/SalesRule/view/frontend/web/js/view/summary/discount.js +app/code/Magento/Search/view/frontend/requirejs-config.js +app/code/Magento/Search/view/frontend/web/form-mini.js +app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js +app/code/Magento/Shipping/view/frontend/web/js/model/config.js +app/code/Magento/Shipping/view/frontend/web/js/view/checkout/shipping/shipping-policy.js +app/code/Magento/Store/view/base/requirejs-config.js +app/code/Magento/Store/view/base/web/js/listing/filter/store.js +app/code/Magento/Tax/view/adminhtml/web/js/bootstrap.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/minicart/subtotal/totals.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/shipping_method/price.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/grand-total.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/item/details/subtotal.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/shipping.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/subtotal.js +app/code/Magento/Tax/view/frontend/web/js/view/checkout/summary/tax.js +app/code/Magento/Theme/view/adminhtml/requirejs-config.js +app/code/Magento/Theme/view/adminhtml/web/js/bootstrap.js +app/code/Magento/Theme/view/adminhtml/web/js/custom-js-list.js +app/code/Magento/Theme/view/adminhtml/web/js/form.js +app/code/Magento/Theme/view/adminhtml/web/js/sortable.js +app/code/Magento/Theme/view/base/requirejs-config.js +app/code/Magento/Theme/view/frontend/requirejs-config.js +app/code/Magento/Theme/view/frontend/web/js/row-builder.js +app/code/Magento/Theme/view/frontend/web/js/truncate.js +app/code/Magento/Theme/view/frontend/web/js/view/messages.js +app/code/Magento/Theme/view/frontend/web/menu.js +app/code/Magento/Ui/view/base/requirejs-config.js +app/code/Magento/Ui/view/base/web/js/block-loader.js +app/code/Magento/Ui/view/base/web/js/core/app.js +app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js +app/code/Magento/Ui/view/base/web/js/core/renderer/types.js +app/code/Magento/Ui/view/base/web/js/form/adapter.js +app/code/Magento/Ui/view/base/web/js/form/client.js +app/code/Magento/Ui/view/base/web/js/form/components/area.js +app/code/Magento/Ui/view/base/web/js/form/components/collection.js +app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js +app/code/Magento/Ui/view/base/web/js/form/components/fieldset.js +app/code/Magento/Ui/view/base/web/js/form/components/group.js +app/code/Magento/Ui/view/base/web/js/form/components/html.js +app/code/Magento/Ui/view/base/web/js/form/components/tab_group.js +app/code/Magento/Ui/view/base/web/js/form/components/tab.js +app/code/Magento/Ui/view/base/web/js/form/element/abstract.js +app/code/Magento/Ui/view/base/web/js/form/element/boolean.js +app/code/Magento/Ui/view/base/web/js/form/element/date.js +app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js +app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +app/code/Magento/Ui/view/base/web/js/form/element/region.js +app/code/Magento/Ui/view/base/web/js/form/element/select.js +app/code/Magento/Ui/view/base/web/js/form/element/textarea.js +app/code/Magento/Ui/view/base/web/js/form/form.js +app/code/Magento/Ui/view/base/web/js/form/provider.js +app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js +app/code/Magento/Ui/view/base/web/js/grid/columns/column.js +app/code/Magento/Ui/view/base/web/js/grid/columns/date.js +app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js +app/code/Magento/Ui/view/base/web/js/grid/columns/select.js +app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js +app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js +app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js +app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js +app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js +app/code/Magento/Ui/view/base/web/js/grid/dnd.js +app/code/Magento/Ui/view/base/web/js/grid/export.js +app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js +app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +app/code/Magento/Ui/view/base/web/js/grid/filters/group.js +app/code/Magento/Ui/view/base/web/js/grid/listing.js +app/code/Magento/Ui/view/base/web/js/grid/massactions.js +app/code/Magento/Ui/view/base/web/js/grid/paging.js +app/code/Magento/Ui/view/base/web/js/grid/provider.js +app/code/Magento/Ui/view/base/web/js/grid/search/search.js +app/code/Magento/Ui/view/base/web/js/lib/class.js +app/code/Magento/Ui/view/base/web/js/lib/collapsible.js +app/code/Magento/Ui/view/base/web/js/lib/component/core.js +app/code/Magento/Ui/view/base/web/js/lib/component/links.js +app/code/Magento/Ui/view/base/web/js/lib/component/main.js +app/code/Magento/Ui/view/base/web/js/lib/component/manip.js +app/code/Magento/Ui/view/base/web/js/lib/component/provider.js +app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js +app/code/Magento/Ui/view/base/web/js/lib/events.js +app/code/Magento/Ui/view/base/web/js/lib/i18n.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/datepicker.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/fadeVisible.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/keyboard.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/mage-init.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/optgroup.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/outer_click.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js +app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js +app/code/Magento/Ui/view/base/web/js/lib/ko/extender/observable_array.js +app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js +app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js +app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js +app/code/Magento/Ui/view/base/web/js/lib/loader.js +app/code/Magento/Ui/view/base/web/js/lib/registry/events.js +app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js +app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js +app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js +app/code/Magento/Ui/view/base/web/js/lib/spinner.js +app/code/Magento/Ui/view/base/web/js/lib/step-registry.js +app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js +app/code/Magento/Ui/view/base/web/js/lib/storage.js +app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js +app/code/Magento/Ui/view/base/web/js/lib/validation/utils.js +app/code/Magento/Ui/view/base/web/js/lib/validation/validator.js +app/code/Magento/Ui/view/base/web/js/modal/alert.js +app/code/Magento/Ui/view/base/web/js/modal/confirm.js +app/code/Magento/Ui/view/base/web/js/modal/modal.js +app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js +app/code/Magento/Ui/view/frontend/web/js/model/messageList.js +app/code/Magento/Ui/view/frontend/web/js/view/messages.js +app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validation-rules.js +app/code/Magento/Ups/view/frontend/web/js/model/shipping-rates-validator.js +app/code/Magento/Ups/view/frontend/web/js/view/shipping-rates-validation.js +app/code/Magento/User/view/adminhtml/requirejs-config.js +app/code/Magento/User/view/adminhtml/web/app-config.js +app/code/Magento/User/view/adminhtml/web/js/roles-tree.js +app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validation-rules.js +app/code/Magento/Usps/view/frontend/web/js/model/shipping-rates-validator.js +app/code/Magento/Usps/view/frontend/web/js/view/shipping-rates-validation.js +app/code/Magento/Variable/view/adminhtml/web/variables.js +app/code/Magento/Weee/view/adminhtml/requirejs-config.js +app/code/Magento/Weee/view/adminhtml/web/js/fpt-attribute.js +app/code/Magento/Weee/view/frontend/requirejs-config.js +app/code/Magento/Weee/view/frontend/web/js/view/checkout/summary/item/price/row_excl_tax.js +app/code/Magento/Weee/view/frontend/web/js/view/checkout/summary/item/price/row_incl_tax.js +app/code/Magento/Weee/view/frontend/web/js/view/checkout/summary/item/price/weee.js +app/code/Magento/Weee/view/frontend/web/js/view/checkout/summary/weee.js +app/code/Magento/Weee/view/frontend/web/tax-toggle.js +app/code/Magento/Wishlist/view/frontend/requirejs-config.js +app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js +app/code/Magento/Wishlist/view/frontend/web/js/search.js +app/code/Magento/Wishlist/view/frontend/web/js/view/wishlist.js +app/code/Magento/Wishlist/view/frontend/web/wishlist.js +app/design/adminhtml/Magento/backend/web/js/theme.js +app/design/frontend/Magento/blank/web/js/navigation-menu.js +app/design/frontend/Magento/blank/web/js/responsive.js +app/design/frontend/Magento/blank/web/js/theme.js +dev/tests/js/jasmine/tests/app/code/Magento/Msrp/frontend/js/msrp.test.js +dev/tests/js/jasmine/tests/app/code/Magento/PageCache/frontend/js/page-cache.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/actions.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/multiselect.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/bookmarks.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/storage.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/view.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/ko/bind/datepicker.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js +dev/tests/js/jasmine/tests/lib/mage/apply.test.js +dev/tests/js/jasmine/tests/lib/mage/requirejs/static-jsbuild.test.js +dev/tests/js/jasmine/tests/lib/mage/requirejs/static-text.test.js +dev/tests/js/jasmine/tests/lib/mage/requirejs/statistician.test.js +dev/tests/js/jasmine/tests/lib/mage/scripts.test.js +dev/tests/js/jasmine/tests/lib/mage/template.test.js +lib/web/mage/accordion.js +lib/web/mage/adminhtml/accordion.js +lib/web/mage/adminhtml/backup.js +lib/web/mage/adminhtml/browser.js +lib/web/mage/adminhtml/events.js +lib/web/mage/adminhtml/form.js +lib/web/mage/adminhtml/globals.js +lib/web/mage/adminhtml/grid.js +lib/web/mage/adminhtml/tools.js +lib/web/mage/adminhtml/varienLoader.js +lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js +lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js +lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +lib/web/mage/adminhtml/wysiwyg/widget.js +lib/web/mage/app/config.js +lib/web/mage/apply/main.js +lib/web/mage/apply/scripts.js +lib/web/mage/backend/action-link.js +lib/web/mage/backend/bootstrap.js +lib/web/mage/backend/button.js +lib/web/mage/backend/editablemultiselect.js +lib/web/mage/backend/floating-header.js +lib/web/mage/backend/form.js +lib/web/mage/backend/menu.js +lib/web/mage/backend/notification.js +lib/web/mage/backend/suggest.js +lib/web/mage/backend/tabs.js +lib/web/mage/backend/tree-suggest.js +lib/web/mage/backend/validation.js +lib/web/mage/bootstrap.js +lib/web/mage/calendar.js +lib/web/mage/captcha.js +lib/web/mage/collapsible.js +lib/web/mage/common.js +lib/web/mage/cookies.js +lib/web/mage/dataPost.js +lib/web/mage/decorate.js +lib/web/mage/deletable-item.js +lib/web/mage/dialog.js +lib/web/mage/dropdown_old.js +lib/web/mage/dropdown.js +lib/web/mage/dropdowns.js +lib/web/mage/edit-trigger.js +lib/web/mage/fieldset-controls.js +lib/web/mage/gallery-fullscreen.js +lib/web/mage/gallery.js +lib/web/mage/ie-class-fixer.js +lib/web/mage/item-table.js +lib/web/mage/layout.js +lib/web/mage/list.js +lib/web/mage/loader_old.js +lib/web/mage/loader.js +lib/web/mage/mage.js +lib/web/mage/menu.js +lib/web/mage/popup-window.js +lib/web/mage/redirect-url.js +lib/web/mage/requirejs/plugin/id-normalizer.js +lib/web/mage/requirejs/resolver.js +lib/web/mage/requirejs/static.js +lib/web/mage/smart-keyboard-handler.js +lib/web/mage/sticky.js +lib/web/mage/storage.js +lib/web/mage/tabs.js +lib/web/mage/template.js +lib/web/mage/terms.js +lib/web/mage/toggle.js +lib/web/mage/tooltip.js +lib/web/mage/translate-inline-vde.js +lib/web/mage/translate-inline.js +lib/web/mage/translate.js +lib/web/mage/url.js +lib/web/mage/utils/arrays.js +lib/web/mage/utils/compare.js +lib/web/mage/utils/main.js +lib/web/mage/utils/misc.js +lib/web/mage/utils/objects.js +lib/web/mage/utils/strings.js +lib/web/mage/utils/template.js +lib/web/mage/validation.js +lib/web/mage/validation/validation.js +lib/web/mage/view/composite.js +lib/web/mage/webapi.js +lib/web/mage/zoom.js diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc new file mode 100644 index 0000000000000..611105806dd4a --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": [ + "./.eslintrc-reset", + "./.eslintrc-magento" + ] +} \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento new file mode 100644 index 0000000000000..3e2ce35ce29a6 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-magento @@ -0,0 +1,64 @@ +{ + "env": { + "browser": true, + "node": true, + "jasmine": true, + "amd": true + }, + "rules": { + "lines-around-comment": [2, {"beforeBlockComment": true}], + "eqeqeq": [2, "smart"], + "no-extend-native": 2, + "no-native-reassign": 2, + "no-use-before-define": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-caller": 2, + "no-unused-vars": [2, {"vars": "all", "args": "after-used"}], + "strict": 2, + "max-depth": [2, 2], + "max-len": [2, 120, 4], + "no-cond-assign": 2, + "no-constant-condition": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 2, + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-negated-in-lhs": 2, + "no-regex-spaces": 2, + "no-unreachable": 2, + "use-isnan": 2, + "valid-typeof": 2, + "guard-for-in": 2, + "no-else-return": 2, + "no-extra-bind": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-str": 2, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 2, + "no-self-compare": 2, + "no-with": 2, + "radix": 2, + "vars-on-top": 2, + "no-catch-shadow": 2, + "no-shadow": 2, + "max-nested-callbacks": [2, 3], + "no-array-constructor": 2, + "no-lonely-if": 2, + "no-new-object": 2, + "semi-spacing": 2, + "no-extra-parens": 2, + "operator-assignment": [2, "always"], + "semi": [2, "always"], + "strict": 2, + "consistent-return": 2 + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-reset b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-reset new file mode 100644 index 0000000000000..ceb9a8c421c93 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc-reset @@ -0,0 +1,217 @@ +{ + // http://eslint.org/docs/rules/ + + "ecmaFeatures": { + "binaryLiterals": false, // enable binary literals + "blockBindings": false, // enable let and const (aka block bindings) + "defaultParams": false, // enable default function parameters + "forOf": false, // enable for-of loops + "generators": false, // enable generators + "objectLiteralComputedProperties": false, // enable computed object literal property names + "objectLiteralDuplicateProperties": false, // enable duplicate object literal properties in strict mode + "objectLiteralShorthandMethods": false, // enable object literal shorthand methods + "objectLiteralShorthandProperties": false, // enable object literal shorthand properties + "octalLiterals": false, // enable octal literals + "regexUFlag": false, // enable the regular expression u flag + "regexYFlag": false, // enable the regular expression y flag + "templateStrings": false, // enable template strings + "unicodeCodePointEscapes": false, // enable code point escapes + "jsx": false // enable JSX + }, + + "env": { + "browser": false, // browser global variables. + "node": false, // Node.js global variables and Node.js-specific rules. + "amd": false, // defines require() and define() as global variables as per the amd spec. + "mocha": false, // adds all of the Mocha testing global variables. + "jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0. + "phantomjs": false, // phantomjs global variables. + "jquery": false, // jquery global variables. + "prototypejs": false, // prototypejs global variables. + "shelljs": false, // shelljs global variables. + }, + + "globals": { + // e.g. "angular": true + }, + + "plugins": [ + // e.g. "react" (must run `npm install eslint-plugin-react` first) + ], + + "rules": { + ////////// Possible Errors ////////// + + "no-comma-dangle": 0, // disallow trailing commas in object literals + "no-cond-assign": 0, // disallow assignment in conditional expressions + "no-console": 0, // disallow use of console (off by default in the node environment) + "no-constant-condition": 0, // disallow use of constant expressions in conditions + "no-control-regex": 0, // disallow control characters in regular expressions + "no-debugger": 0, // disallow use of debugger + "no-dupe-keys": 0, // disallow duplicate keys when creating object literals + "no-empty": 0, // disallow empty statements + "no-empty-class": 0, // disallow the use of empty character classes in regular expressions + "no-ex-assign": 0, // disallow assigning to the exception in a catch block + "no-extra-boolean-cast": 0, // disallow double-negation boolean casts in a boolean context + "no-extra-parens": 0, // disallow unnecessary parentheses (off by default) + "no-extra-semi": 0, // disallow unnecessary semicolons + "no-func-assign": 0, // disallow overwriting functions written as function declarations + "no-inner-declarations": 0, // disallow function or variable declarations in nested blocks + "no-invalid-regexp": 0, // disallow invalid regular expression strings in the RegExp constructor + "no-irregular-whitespace": 0, // disallow irregular whitespace outside of strings and comments + "no-negated-in-lhs": 0, // disallow negation of the left operand of an in expression + "no-obj-calls": 0, // disallow the use of object properties of the global object (Math and JSON) as functions + "no-regex-spaces": 0, // disallow multiple spaces in a regular expression literal + "no-reserved-keys": 0, // disallow reserved words being used as object literal keys (off by default) + "no-sparse-arrays": 0, // disallow sparse arrays + "no-unreachable": 0, // disallow unreachable statements after a return, throw, continue, or break statement + "use-isnan": 0, // disallow comparisons with the value NaN + "valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default) + "valid-typeof": 0, // Ensure that the results of typeof are compared against a valid string + + + ////////// Best Practices ////////// + + "block-scoped-var": 0, // treat var statements as if they were block scoped (off by default) + "complexity": 0, // specify the maximum cyclomatic complexity allowed in a program (off by default) + "consistent-return": 0, // require return statements to either always or never specify values + "curly": 0, // specify curly brace conventions for all control statements + "default-case": 0, // require default case in switch statements (off by default) + "dot-notation": 0, // encourages use of dot notation whenever possible + "eqeqeq": 0, // require the use of === and !== + "guard-for-in": 0, // make sure for-in loops have an if statement (off by default) + "no-alert": 0, // disallow the use of alert, confirm, and prompt + "no-caller": 0, // disallow use of arguments.caller or arguments.callee + "no-div-regex": 0, // disallow division operators explicitly at beginning of regular expression (off by default) + "no-else-return": 0, // disallow else after a return in an if (off by default) + "no-empty-label": 0, // disallow use of labels for anything other then loops and switches + "no-eq-null": 0, // disallow comparisons to null without a type-checking operator (off by default) + "no-eval": 0, // disallow use of eval() + "no-extend-native": 0, // disallow adding to native types + "no-extra-bind": 0, // disallow unnecessary function binding + "no-fallthrough": 0, // disallow fallthrough of case statements + "no-floating-decimal": 0, // disallow the use of leading or trailing decimal points in numeric literals (off by default) + "no-implied-eval": 0, // disallow use of eval()-like methods + "no-iterator": 0, // disallow usage of __iterator__ property + "no-labels": 0, // disallow use of labeled statements + "no-lone-blocks": 0, // disallow unnecessary nested blocks + "no-loop-func": 0, // disallow creation of functions within loops + "no-multi-spaces": 0, // disallow use of multiple spaces + "no-multi-str": 0, // disallow use of multiline strings + "no-native-reassign": 0, // disallow reassignments of native objects + "no-new": 0, // disallow use of new operator when not part of the assignment or comparison + "no-new-func": 0, // disallow use of new operator for Function object + "no-new-wrappers": 0, // disallows creating new instances of String, Number, and Boolean + "no-octal": 0, // disallow use of octal literals + "no-octal-escape": 0, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251"; + "no-process-env": 0, // disallow use of process.env (off by default) + "no-proto": 0, // disallow usage of __proto__ property + "no-redeclare": 0, // disallow declaring the same variable more then once + "no-return-assign": 0, // disallow use of assignment in return statement + "no-script-url": 0, // disallow use of javascript: urls. + "no-self-compare": 0, // disallow comparisons where both sides are exactly the same (off by default) + "no-sequences": 0, // disallow use of comma operator + "no-unused-expressions": 0, // disallow usage of expressions in statement position + "no-void": 0, // disallow use of void operator (off by default) + "no-warning-comments": 0, // disallow usage of configurable warning terms in comments, e.g. TODO or FIXME (off by default) + "no-with": 0, // disallow use of the with statement + "radix": 0, // require use of the second argument for parseInt() (off by default) + "vars-on-top": 0, // requires to declare all vars on top of their containing scope (off by default) + "wrap-iife": 0, // require immediate function invocation to be wrapped in parentheses (off by default) + "yoda": 0, // require or disallow Yoda conditions + + + ////////// Strict Mode ////////// + + "global-strict": 0, // (deprecated) require or disallow the "use strict" pragma in the global scope (off by default in the node environment) + "no-extra-strict": 0, // (deprecated) disallow unnecessary use of "use strict"; when already in strict mode + "strict": 0, // controls location of Use Strict Directives + + + ////////// Variables ////////// + + "no-catch-shadow": 0, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) + "no-delete-var": 0, // disallow deletion of variables + "no-label-var": 0, // disallow labels that share a name with a variable + "no-shadow": 0, // disallow declaration of variables already declared in the outer scope + "no-shadow-restricted-names": 0, // disallow shadowing of names such as arguments + "no-undef": 0, // disallow use of undeclared variables unless mentioned in a /*global */ block + "no-undef-init": 0, // disallow use of undefined when initializing variables + "no-undefined": 0, // disallow use of undefined variable (off by default) + "no-unused-vars": 0, // disallow declaration of variables that are not used in the code + "no-use-before-define": 0, // disallow use of variables before they are defined + + + ////////// Node.js ////////// + + "handle-callback-err": 0, // enforces error handling in callbacks (off by default) (on by default in the node environment) + "no-mixed-requires": 0, // disallow mixing regular variable and require declarations (off by default) (on by default in the node environment) + "no-new-require": 0, // disallow use of new operator with the require function (off by default) (on by default in the node environment) + "no-path-concat": 0, // disallow string concatenation with __dirname and __filename (off by default) (on by default in the node environment) + "no-process-exit": 0, // disallow process.exit() (on by default in the node environment) + "no-restricted-modules": 0, // restrict usage of specified node modules (off by default) + "no-sync": 0, // disallow use of synchronous methods (off by default) + + + ////////// Stylistic Issues ////////// + + "brace-style": 0, // enforce one true brace style (off by default) + "camelcase": 0, // require camel case names + "comma-spacing": 0, // enforce spacing before and after comma + "comma-style": 0, // enforce one true comma style (off by default) + "consistent-this": 0, // enforces consistent naming when capturing the current execution context (off by default) + "eol-last": 0, // enforce newline at the end of file, with no multiple empty lines + "func-names": 0, // require function expressions to have a name (off by default) + "func-style": 0, // enforces use of function declarations or expressions (off by default) + "key-spacing": 0, // enforces spacing between keys and values in object literal properties + "max-nested-callbacks": 0, // specify the maximum depth callbacks can be nested (off by default) + "new-cap": 0, // require a capital letter for constructors + "new-parens": 0, // disallow the omission of parentheses when invoking a constructor with no arguments + "no-array-constructor": 0, // disallow use of the Array constructor + "no-inline-comments": 0, // disallow comments inline after code (off by default) + "no-lonely-if": 0, // disallow if as the only statement in an else block (off by default) + "no-mixed-spaces-and-tabs": 0, // disallow mixed spaces and tabs for indentation + "no-multiple-empty-lines": 0, // disallow multiple empty lines (off by default) + "no-nested-ternary": 0, // disallow nested ternary expressions (off by default) + "no-new-object": 0, // disallow use of the Object constructor + "no-space-before-semi": 0, // disallow space before semicolon + "no-spaced-func": 0, // disallow space between function identifier and application + "no-ternary": 0, // disallow the use of ternary operators (off by default) + "no-trailing-spaces": 0, // disallow trailing whitespace at the end of lines + "no-underscore-dangle": 0, // disallow dangling underscores in identifiers + "no-wrap-func": 0, // disallow wrapping of non-IIFE statements in parens + "one-var": 0, // allow just one var statement per function (off by default) + "operator-assignment": 0, // require assignment operator shorthand where possible or prohibit it entirely (off by default) + "padded-blocks": 0, // enforce padding within blocks (off by default) + "quote-props": 0, // require quotes around object literal property names (off by default) + "quotes": 0, // specify whether double or single quotes should be used + "semi": 0, // require or disallow use of semicolons instead of ASI + "sort-vars": 0, // sort variables within the same declaration block (off by default) + "space-after-function-name": 0, // require a space after function names (off by default) + "space-after-keywords": 0, // require a space after certain keywords (off by default) + "space-before-blocks": 0, // require or disallow space before blocks (off by default) + "space-in-brackets": 0, // require or disallow spaces inside brackets (off by default) + "space-in-parens": 0, // require or disallow spaces inside parentheses (off by default) + "space-infix-ops": 0, // require spaces around operators + "space-return-throw-case": 0, // require a space after return, throw, and case + "space-unary-ops": 0, // Require or disallow spaces before/after unary operators (words on by default, nonwords off by default) + "spaced-line-comment": 0, // require or disallow a space immediately following the // in a line comment (off by default) + "wrap-regex": 0, // require regex literals to be wrapped in parentheses (off by default) + + + ////////// ECMAScript 6 ////////// + + "no-var": 0, // require let or const instead of var (off by default) + "generator-star": 0, // enforce the position of the * in generator functions (off by default) + + + ////////// Legacy ////////// + + "max-depth": 0, // specify the maximum depth that blocks can be nested (off by default) + "max-len": 0, // specify the maximum length of a line in your program (off by default) + "max-params": 0, // limits the number of parameters that can be used in the function declaration. (off by default) + "max-statements": 0, // specify the maximum number of statement allowed in a function (off by default) + "no-bitwise": 0, // disallow use of bitwise operators (off by default) + "no-plusplus": 0 // disallow use of unary operators, ++ and -- (off by default) + } +} \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc b/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc new file mode 100644 index 0000000000000..96ea18895001f --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc @@ -0,0 +1,54 @@ +{ + "preset": "crockford", + "plugins": [ + "jscs-jsdoc" + ], + "requirePaddingNewlinesBeforeKeywords": [ + "do", + "for", + "if", + "switch", + "case", + "try", + "void", + "while", + "with", + "return" + ], + "requireSpaceBeforeKeywords": [ + "else", + "while", + "catch" + ], + "disallowMultipleLineStrings": true, + "validateQuoteMarks": "'", + "requireOperatorBeforeLineBreak": true, + "disallowYodaConditions": true, + "disallowMultipleLineBreaks": true, + "disallowSpacesInCallExpression": true, + "requirePaddingNewLinesInObjects": true, + "requireLineFeedAtFileEnd": true, + "disallowSpaceAfterObjectKeys": true, + "requireSpaceBeforeObjectValues": true, + "disallowSpaceAfterPrefixUnaryOperators": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "validateParameterSeparator": ", ", + "disallowSpacesInsideObjectBrackets": "all", + "disallowSpacesInsideArrayBrackets": "all", + "requireLineBreakAfterVariableAssignment": true, + "requirePaddingNewLinesAfterUseStrict": true, + "disallowDanglingUnderscores": null, + "jsDoc": { + "checkAnnotations": { + "preset": "jsdoc3" + }, + "enforceExistence": "exceptExports", + "requireParamTypes": true, + "checkRedundantParams": true, + "checkReturnTypes": true, + "checkRedundantReturns": true, + "checkParamNames": true, + "checkTypes": "capitalizedNativeCase", + "requireHyphenBeforeDescription": true + } +} \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt similarity index 100% rename from dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/core.txt rename to dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/blacklist/core.txt diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/whitelist/core.txt similarity index 100% rename from dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/core.txt rename to dev/tests/static/testsuite/Magento/Test/Js/_files/jshint/whitelist/core.txt diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt new file mode 100644 index 0000000000000..19aab504018b3 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/magento.txt @@ -0,0 +1,4 @@ +app/code/**/*.js +app/design/**/*.js +dev/tests/js/jasmine/tests/**/*.js +lib/web/mage/**/*.js diff --git a/dev/tools/grunt/configs/eslint.js b/dev/tools/grunt/configs/eslint.js new file mode 100644 index 0000000000000..c72131becc648 --- /dev/null +++ b/dev/tools/grunt/configs/eslint.js @@ -0,0 +1,26 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +'use strict'; + +module.exports = { + file: { + options: { + configFile: 'dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc', + reset: true + }, + src: '' + }, + test: { + options: { + configFile: 'dev/tests/static/testsuite/Magento/Test/Js/_files/eslint/.eslintrc', + reset: true, + outputFile: 'dev/tests/static/eslint-error-report.xml', + format: 'checkstyle', + quiet: true + }, + src: '' + } +}; diff --git a/dev/tools/grunt/configs/jscs.js b/dev/tools/grunt/configs/jscs.js new file mode 100644 index 0000000000000..8b89e0293bdb5 --- /dev/null +++ b/dev/tools/grunt/configs/jscs.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +'use strict'; + +module.exports = { + file: { + options: { + config: 'dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc' + }, + src: '' + }, + test: { + options: { + config: 'dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc', + reporterOutput: 'dev/tests/static/jscs-error-report.xml', + reporter: 'checkstyle' + }, + src: '' + } +}; diff --git a/dev/tools/grunt/configs/path.js b/dev/tools/grunt/configs/path.js index f160b35c92823..5021becadca7f 100644 --- a/dev/tools/grunt/configs/path.js +++ b/dev/tools/grunt/configs/path.js @@ -25,5 +25,11 @@ module.exports = { legacy: 'lib/web/legacy-build.min.js' }, doc: 'lib/web/css/docs', - spec: 'dev/tests/js/spec' + spec: 'dev/tests/js/spec', + static: { + dir: 'dev/tests/static/testsuite/Magento/Test/Js/_files', + whitelist: 'dev/tests/static/testsuite/Magento/Test/Js/_files/whitelist/', + blacklist: 'dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/', + tmp: 'validation-files.txt' + } }; diff --git a/dev/tools/grunt/tasks/black-list-generator.js b/dev/tools/grunt/tasks/black-list-generator.js new file mode 100644 index 0000000000000..cd98b734cf235 --- /dev/null +++ b/dev/tools/grunt/tasks/black-list-generator.js @@ -0,0 +1,26 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +module.exports = function (grunt) { + 'use strict'; + + var glob = require('glob'), + fs = require('fs'), + path = require('path'), + fst = require('../tools/fs-tools.js'), + pc = require('../configs/path'); + + grunt.registerTask('black-list-generator', function () { + process.chdir(grunt.option('dir') || '.'); + + var whiteListFile = glob.sync(pc.static.whitelist + '*.txt')[0], + blacklistFile = pc.static.blacklist + path.basename(whiteListFile), + whiteList = fst.getData(whiteListFile); + + fst.arrayRead(whiteList, function (data) { + fst.write(blacklistFile, data); + }); + }); +}; \ No newline at end of file diff --git a/dev/tools/grunt/tasks/clean-black-list.js b/dev/tools/grunt/tasks/clean-black-list.js new file mode 100644 index 0000000000000..93318bd628cdf --- /dev/null +++ b/dev/tools/grunt/tasks/clean-black-list.js @@ -0,0 +1,30 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +module.exports = function (grunt) { + 'use strict'; + + var fs = require('fs'), + _ = require('underscore'), + glob = require('glob'), + fst = require('../tools/fs-tools'), + pc = require('../configs/path'), + removeFromFile = function (path, files) { + var data = _.difference(fst.getData(path), files); + + fst.write(path, data); + }; + + grunt.registerTask('clean-black-list', function () { + process.chdir(grunt.option('dir') || '.'); + + var filesToRemove = grunt.option('file').split(','), + files = glob.sync(pc.static.blacklist + '*.txt'); + + _.each(files, function (file) { + removeFromFile(file, filesToRemove); + }); + }); +}; diff --git a/dev/tools/grunt/tasks/static.js b/dev/tools/grunt/tasks/static.js new file mode 100644 index 0000000000000..433e7a2b161f3 --- /dev/null +++ b/dev/tools/grunt/tasks/static.js @@ -0,0 +1,36 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +module.exports = function (grunt) { + 'use strict'; + + var pc = require('../configs/path'), + fs = require('fs'), + cvf = require('../tools/collect-validation-files'), + setConfig = function (task, target, data) { + var config = grunt.config.get(task); + + config[target].src = data; + grunt.config.set(task, config); + }; + + grunt.registerTask('static', function (target) { + var currentTarget = target || 'test', + file = grunt.option('file'), + tasks = [ + 'eslint:' + currentTarget, + 'jscs:' + currentTarget + ]; + + setConfig('eslint', currentTarget, cvf.getFiles(file)); + setConfig('jscs', currentTarget, cvf.getFiles(file)); + grunt.option('force', true); + grunt.task.run(tasks); + + if (!grunt.option('path')) { + fs.unlinkSync(pc.static.tmp); + } + }); +}; diff --git a/dev/tools/grunt/tools/collect-validation-files.js b/dev/tools/grunt/tools/collect-validation-files.js new file mode 100644 index 0000000000000..a8c55f75040db --- /dev/null +++ b/dev/tools/grunt/tools/collect-validation-files.js @@ -0,0 +1,55 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +'use strict'; + +var glob = require('glob'), + fs = require('fs'), + _ = require('underscore'), + fst = require('../tools/fs-tools'), + pc = require('../configs/path'); + +module.exports = { + readFiles: function (paths) { + var data = []; + + _.each(paths, function (path) { + data = _.union(data, fst.getData(path)); + }); + + return data; + }, + + getFilesForValidate: function () { + + var blackListFiles = glob.sync(pc.static.blacklist + '*.txt'), + whiteListFiles = glob.sync(pc.static.whitelist + '*.txt'), + blackList = this.readFiles(blackListFiles), + whiteList = this.readFiles(whiteListFiles), + files = []; + + fst.arrayRead(whiteList, function (data) { + files = _.difference(data, blackList); + }); + + return files; + }, + + getFiles: function (file) { + if (file) { + return file.split(','); + } + + if (!fs.existsSync(pc.static.tmp)) { + fst.write(pc.static.tmp, this.getFilesForValidate()); + } + + return fst.getData(pc.static.tmp); + } +}; diff --git a/dev/tools/grunt/tools/fs-tools.js b/dev/tools/grunt/tools/fs-tools.js new file mode 100644 index 0000000000000..d5e6e924ef478 --- /dev/null +++ b/dev/tools/grunt/tools/fs-tools.js @@ -0,0 +1,57 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +'use strict'; + +var fs = require('fs'), + glob = require('glob'), + nl = (function () { + if (process.platform === 'win32') { + return '\r\n'; + } + + return '\n'; + })(); + +module.exports = { + getData: function (filePath) { + return this.parseToReadData(fs.readFileSync(filePath)); + }, + write: function (file, data) { + fs.writeFileSync(file, this.parseToWriteData(data)); + console.log('The file was saved!'); + }, + + read: function (filePath) { + console.log('Collect data from ' + filePath + ': Start!'); + + return glob.sync(filePath); + }, + + arrayRead: function (pathArr, callback) { + var len = pathArr.length, + data = [], + i = 0; + + for (; i < len; i++) { + data = data.concat(this.read(pathArr[i])); + console.log('Collect data from ' + pathArr[i] + ': Finish!'); + } + callback(data); + }, + + parseToReadData: function (data) { + var result = data.toString().split(nl); + + result.pop(); + + return result; + }, + + parseToWriteData: function (data) { + data = data.join(nl) + nl; + + return data; + } +}; diff --git a/package.json b/package.json index c2f3cb1eaaf9e..d65941df608b4 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,14 @@ "name": "Magento2", "author": "Magento, an eBay Inc. company", "description": "Magento2 node modules dependencies for local development", - "version": "0.74.0-beta7", + "version": "1.0.0-beta", "repository": { "type": "git", "url": "https://github.com/magento/magento2.git" }, "homepage": "http://magento.com/", "devDependencies": { + "glob": "^5.0.14", "grunt": "^0.4.5", "grunt-autoprefixer": "^2.0.0", "grunt-banner": "^0.4.0", @@ -19,15 +20,19 @@ "grunt-contrib-jasmine": "^0.8.1", "grunt-contrib-less": "^0.12.0", "grunt-contrib-watch": "^0.6.1", + "grunt-eslint": "^16.0.0", "grunt-exec": "^0.4.6", + "grunt-jscs": "^1.8.0", "grunt-replace": "^0.9.2", "grunt-styledocco": "^0.1.4", "grunt-template-jasmine-requirejs": "^0.2.3", "grunt-text-replace": "^0.4.0", "imagemin-svgo": "^4.0.1", + "jscs-jsdoc": "^1.1.0", "load-grunt-config": "^0.16.0", "morgan": "^1.5.0", "node-minify": "^1.0.1", + "path": "^0.11.14", "serve-static": "^1.7.1", "strip-json-comments": "^1.0.2", "time-grunt": "^1.0.0", From 7aaef8474f2a58dccc35844fb939fb0e843a8442 Mon Sep 17 00:00:00 2001 From: Ihor Melnychenko Date: Wed, 22 Jul 2015 16:44:39 +0300 Subject: [PATCH 25/25] MAGETWO-22612: Multifield forms has incorect validation for required fields --- lib/web/mage/validation.js | 282 +++++++++++++++++++------------------ 1 file changed, 147 insertions(+), 135 deletions(-) diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 78cc93607e66e..98240eb8cfa40 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -22,16 +22,16 @@ /** * Check if string is empty with trim * @param {string} value - */ - isEmpty: function(value) { - return (value === '' || value === undefined || (value == null) || (value.length === 0) || /^\s+$/.test(value)); + */ + isEmpty: function (value) { + return (value === '' || value === undefined || (value == null) || (value.length === 0) || /^\s+$/.test(value)); }, /** * Check if string is empty no trim * @param {string} value - */ - isEmptyNoTrim: function(value) { + */ + isEmptyNoTrim: function (value) { return (value === '' || (value == null) || (value.length === 0)); }, @@ -43,16 +43,16 @@ * @param {string} to * @returns {boolean} */ - isBetween: function(value, from, to){ + isBetween: function (value, from, to) { return ($.mage.isEmpty(from) || value >= $.mage.parseNumber(from)) && - ($.mage.isEmpty(to) || value <= $.mage.parseNumber(to)); + ($.mage.isEmpty(to) || value <= $.mage.parseNumber(to)); }, /** * Parse price string * @param {string} value - */ - parseNumber: function(value) { + */ + parseNumber: function (value) { if (typeof value !== 'string') { return parseFloat(value); } @@ -75,7 +75,7 @@ * @param value Value being stripped. * @return {*} */ - stripHtml: function(value) { + stripHtml: function (value) { return value.replace(/<.[^<>]*?>/g, ' ').replace(/ | /gi, ' ') .replace(/[0-9.(),;:!?%#$'"_+=\/-]*/g, ''); } @@ -85,7 +85,7 @@ $.validator.addMethod = function (name, method, message, dontSkip) { $.validator.methods[name] = method; $.validator.messages[name] = message !== undefined ? message : $.validator.messages[name]; - + if (method.length < 3 || dontSkip) { $.validator.addClassRules(name, $.validator.normalizeRule(name)); } @@ -146,63 +146,63 @@ */ var rules = { "max-words": [ - function(value, element, params) { + function (value, element, params) { return this.optional(element) || $.mage.stripHtml(value).match(/\b\w+\b/g).length < params; }, 'Please enter {0} words or less.' ], "min-words": [ - function(value, element, params) { + function (value, element, params) { return this.optional(element) || $.mage.stripHtml(value).match(/\b\w+\b/g).length >= params; }, 'Please enter at least {0} words.' ], "range-words": [ - function(value, element, params) { + function (value, element, params) { return this.optional(element) || $.mage.stripHtml(value).match(/\b\w+\b/g).length >= params[0] && - value.match(/bw+b/g).length < params[1]; + value.match(/bw+b/g).length < params[1]; }, 'Please enter between {0} and {1} words.' ], "letters-with-basic-punc": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^[a-z\-.,()'\"\s]+$/i.test(value); }, 'Letters or punctuation only please' ], "alphanumeric": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^\w+$/i.test(value); }, 'Letters, numbers, spaces or underscores only please' ], "letters-only": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^[a-z]+$/i.test(value); }, 'Letters only please' ], "no-whitespace": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^\S+$/i.test(value); }, 'No white space please' ], "zip-range": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^90[2-5]-\d{2}-\d{4}$/.test(value); }, 'Your ZIP-code must be in the range 902xx-xxxx to 905-xx-xxxx' ], "integer": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^-?\d+$/.test(value); }, 'A positive or negative non-decimal number please' ], "vinUS": [ - function(v) { + function (v) { if (v.length !== 17) { return false; } @@ -245,7 +245,7 @@ 'The specified vehicle identification number (VIN) is invalid.' ], "dateITA": [ - function(value, element) { + function (value, element) { var check = false; var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/; if (re.test(value)) { @@ -268,25 +268,25 @@ 'Please enter a correct date' ], "dateNL": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^\d\d?[\.\/-]\d\d?[\.\/-]\d\d\d?\d?$/.test(value); }, 'Vul hier een geldige datum in.' ], "time": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^([01]\d|2[0-3])(:[0-5]\d){0,2}$/.test(value); }, 'Please enter a valid time, between 00:00 and 23:59' ], "time12h": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$/i.test(value); }, 'Please enter a valid time, between 00:00 am and 12:00 pm' ], "phoneUS": [ - function(phone_number, element) { + function (phone_number, element) { phone_number = phone_number.replace(/\s+/g, ""); return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/); @@ -294,39 +294,39 @@ 'Please specify a valid phone number' ], "phoneUK": [ - function(phone_number, element) { + function (phone_number, element) { return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(\(?(0|\+44)[1-9]{1}\d{1,4}?\)?\s?\d{3,4}\s?\d{3,4})$/); }, 'Please specify a valid phone number' ], "mobileUK": [ - function(phone_number, element) { + function (phone_number, element) { return this.optional(element) || phone_number.length > 9 && phone_number.match(/^((0|\+44)7(5|6|7|8|9){1}\d{2}\s?\d{6})$/); }, 'Please specify a valid mobile number' ], "stripped-min-length": [ - function(value, element, param) { + function (value, element, param) { return $(value).text().length >= param; }, 'Please enter at least {0} characters' ], "email2": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value); }, $.validator.messages.email ], "url2": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); }, $.validator.messages.url ], "credit-card-types": [ - function(value, element, param) { + function (value, element, param) { if (/[^0-9-]+/.test(value)) { return false; } @@ -393,25 +393,25 @@ 'Please enter a valid credit card number.' ], "ipv4": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i.test(value); }, 'Please enter a valid IP v4 address.' ], "ipv6": [ - function(value, element) { + function (value, element) { return this.optional(element) || /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(value); }, 'Please enter a valid IP v6 address.' ], "pattern": [ - function(value, element, param) { + function (value, element, param) { return this.optional(element) || param.test(value); }, 'Invalid format.' ], "allow-container-className": [ - function(element) { + function (element) { if (element.type === 'radio' || element.type === 'checkbox') { return $(element).hasClass('change-container-classname'); } @@ -419,73 +419,73 @@ '' ], "validate-no-html-tags": [ - function(value) { + function (value) { return !/<(\/)?\w+/.test(value); }, 'HTML tags are not allowed.' ], "validate-select": [ - function(value) { + function (value) { return ((value !== "none") && (value != null) && (value.length !== 0)); }, 'Please select an option.' ], "validate-no-empty": [ - function(value) { + function (value) { return !$.mage.isEmpty(value); }, 'Empty Value.' ], "validate-alphanum-with-spaces": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[a-zA-Z0-9 ]+$/.test(v); }, 'Please use only letters (a-z or A-Z), numbers (0-9) or spaces only in this field.' ], "validate-data": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[A-Za-z]+[A-Za-z0-9_]+$/.test(v); }, 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in this field, and the first character should be a letter.' ], "validate-street": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[ \w]{3,}([A-Za-z]\.)?([ \w]*\#\d+)?(\r\n| )[ \w]{3,}/.test(v); }, 'Please use only letters (a-z or A-Z), numbers (0-9), spaces and "#" in this field.' ], "validate-phoneStrict": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/.test(v); }, 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.' ], "validate-phoneLax": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^((\d[\-. ]?)?((\(\d{3}\))|\d{3}))?[\-. ]?\d{3}[\-. ]?\d{4}$/.test(v); }, 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.' ], "validate-fax": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/.test(v); }, 'Please enter a valid fax number (Ex: 123-456-7890).' ], "validate-email": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v); }, 'Please enter a valid email address (Ex: johndoe@domain.com).' ], "validate-emailSender": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[\S ]+$/.test(v); }, 'Please enter a valid email address (Ex: johndoe@domain.com).' ], "validate-password": [ - function(v) { + function (v) { if (v == null) { return false; } @@ -499,7 +499,7 @@ 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.' ], "validate-admin-password": [ - function(v) { + function (v) { if (v == null) { return false; } @@ -519,7 +519,7 @@ 'Please enter 7 or more characters, using both numeric and alphabetic.' ], "validate-url": [ - function(v) { + function (v) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -530,35 +530,35 @@ 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://).' ], "validate-clean-url": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+.(com|org|net|dk|at|us|tv|info|uk|co.uk|biz|se)$)(:(\d+))?\/?/i.test(v) || /^(www)((\.[A-Z0-9][A-Z0-9_-]*)+.(com|org|net|dk|at|us|tv|info|uk|co.uk|biz|se)$)(:(\d+))?\/?/i.test(v); }, 'Please enter a valid URL. For example http://www.example.com or www.example.com.' ], "validate-xml-identifier": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[A-Z][A-Z0-9_\/-]*$/i.test(v); }, 'Please enter a valid XML-identifier (Ex: something_1, block5, id-4).' ], "validate-ssn": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^\d{3}-?\d{2}-?\d{4}$/.test(v); }, 'Please enter a valid social security number (Ex: 123-45-6789).' ], "validate-zip-us": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /(^\d{5}$)|(^\d{5}-\d{4}$)/.test(v); }, 'Please enter a valid zip code (Ex: 90602 or 90602-1234).' ], "validate-date-au": [ - function(v) { + function (v) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -575,14 +575,14 @@ 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.' ], "validate-currency-dollar": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v); }, 'Please enter a valid $ amount. For example $100.00.' ], "validate-not-negative-number": [ - function(v) { + function (v) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -594,7 +594,7 @@ ], // validate-not-negative-number should be replaced in all places with this one and then removed "validate-zero-or-greater": [ - function(v) { + function (v) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -605,7 +605,7 @@ 'Please enter a number 0 or greater in this field.' ], "validate-greater-than-zero": [ - function(v) { + function (v) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -615,7 +615,7 @@ 'Please enter a number greater than 0 in this field.' ], "validate-css-length": [ - function(v) { + function (v) { if (v !== '') { return (/^[0-9]*\.*[0-9]+(px|pc|pt|ex|em|mm|cm|in|%)?$/).test(v); } @@ -625,19 +625,19 @@ ], /** @description Additional methods */ "validate-number": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || (!isNaN($.mage.parseNumber(v)) && /^\s*-?\d*(\.\d*)?\s*$/.test(v)); }, 'Please enter a valid number in this field.' ], "required-number": [ - function(v){ + function (v) { return !!v.length; }, 'Please enter a valid number in this field.' ], "validate-number-range": [ - function(v, elm, param) { + function (v, elm, param) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -658,7 +658,7 @@ if (m) { result = result && $.mage.isBetween(numValue, m[1], m[2]); } - } else if (elm && elm.className ) { + } else if (elm && elm.className) { classes = elm.className.split(" "); ii = classes.length; @@ -678,13 +678,13 @@ true ], "validate-digits": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || !/[^\d]/.test(v); }, 'Please enter a valid number in this field.' ], "validate-digits-range": [ - function(v, elm, param) { + function (v, elm, param) { if ($.mage.isEmptyNoTrim(v)) { return true; } @@ -699,13 +699,13 @@ result = true, range, m, classes, ii; range = param; - + if (typeof range === 'object') { m = dataAttrRange.exec(range); if (m) { result = result && $.mage.isBetween(numValue, m[1], m[2]); } - } else if (elm && elm.className ) { + } else if (elm && elm.className) { classes = elm.className.split(" "); ii = classes.length; @@ -725,7 +725,7 @@ true ], 'validate-range': [ - function(v, elm) { + function (v, elm) { var minValue, maxValue; if ($.mage.isEmptyNoTrim(v)) { return true; @@ -756,8 +756,8 @@ var minValidRange = $.mage.parseNumber(validRange[1]); var maxValidRange = $.mage.parseNumber(validRange[2]); result = result && - (isNaN(minValidRange) || minValue >= minValidRange) && - (isNaN(maxValidRange) || maxValue <= maxValidRange); + (isNaN(minValidRange) || minValue >= minValidRange) && + (isNaN(maxValidRange) || maxValue <= maxValidRange); } } return result; @@ -765,39 +765,39 @@ 'The value is not within the specified range.' ], "validate-alpha": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[a-zA-Z]+$/.test(v); }, 'Please use letters only (a-z or A-Z) in this field.' ], "validate-code": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[a-z]+[a-z0-9_]+$/.test(v); }, 'Please use only letters (a-z), numbers (0-9) or underscore (_) in this field, and the first character should be a letter.' ], "validate-alphanum": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[a-zA-Z0-9]+$/.test(v); }, 'Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.' ], "validate-date": [ - function(v) { + function (v) { var test = new Date(v); return $.mage.isEmptyNoTrim(v) || !isNaN(test); - },'Please enter a valid date.' + }, 'Please enter a valid date.' ], "validate-date-range": [ - function(v, elm) { + function (v, elm) { var m = /\bdate-range-(\w+)-(\w+)\b/.exec(elm.className); if (!m || m[2] === 'to' || $.mage.isEmptyNoTrim(v)) { return true; } var currentYear = new Date().getFullYear() + ''; - var normalizedTime = function(v) { + var normalizedTime = function (v) { v = v.split(/[.\/]/); if (v[2] && v[2].length < 4) { v[2] = currentYear.substr(0, v[2].length) + v[2]; @@ -812,7 +812,7 @@ 'Make sure the To Date is later than or the same as the From Date.' ], "validate-cpassword": [ - function() { + function () { var conf = $('#confirmation').length > 0 ? $('#confirmation') : $($('.validate-cpassword')[0]); var pass = false; if ($('#password')) { @@ -833,7 +833,7 @@ 'Please make sure your passwords match.' ], "validate-identifier": [ - function(v) { + function (v) { return $.mage.isEmptyNoTrim(v) || /^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/.test(v); }, 'Please enter a valid URL Key (Ex: "example-page", "example-page.html" or "anotherlevel/example-page").' @@ -843,29 +843,29 @@ // @TODO: Cleanup return Validation.get('IsEmpty').test(v) || /(^[A-z0-9]{2,10}([\s]{0,1}|[\-]{0,1})[A-z0-9]{2,10}$)/.test(v); }*/ - function() { + function () { return true; }, 'Please enter a valid zip code.' ], "validate-one-required": [ - function(v, elm) { + function (v, elm) { var p = $(elm).parent(); var options = p.find('input'); - return options.map(function(elm) { - return $(elm).val(); - }).length > 0; + return options.map(function (elm) { + return $(elm).val(); + }).length > 0; }, 'Please select one of the options above.' ], "validate-state": [ - function(v) { + function (v) { return (v !== 0 || v === ''); }, 'Please select State/Province.' ], "required-file": [ - function(v, elm) { + function (v, elm) { var result = !$.mage.isEmptyNoTrim(v); if (!result) { var ovId = $(elm).attr('id') + '_value'; @@ -878,9 +878,9 @@ 'Please select a file.' ], "validate-ajax-error": [ - function(v, element) { + function (v, element) { element = $(element); - element.on('change.ajaxError', function() { + element.on('change.ajaxError', function () { element.removeClass('validate-ajax-error'); element.off('change.ajaxError'); }); @@ -889,7 +889,7 @@ '' ], "validate-optional-datetime": [ - function(v, elm, param) { + function (v, elm, param) { var dateTimeParts = $('.datetime-picker[id^="options_' + param + '"]'), hasWithValue = false, hasWithNoValue = false, pattern = /day_part$/i; @@ -907,7 +907,7 @@ 'The field isn\'t complete.' ], "validate-required-datetime": [ - function(v, elm, param) { + function (v, elm, param) { var dateTimeParts = $('.datetime-picker[id^="options_' + param + '"]'); for (var i = 0; i < dateTimeParts.length; i++) { if (dateTimeParts[i].value === "") { @@ -919,43 +919,43 @@ 'This is a required field.' ], "validate-one-required-by-name": [ - function(v, elm, selector) { - var name = elm.name.replace(/([\\"])/g, '\\$1'), - container = this.currentForm, - selector = selector === true ? 'input[name="' + name + '"]:checked' : selector; - + function (v, elm, selector) { + var name = elm.name.replace(/([\\"])/g, '\\$1'), + container = this.currentForm, + selector = selector === true ? 'input[name="' + name + '"]:checked' : selector; + return !!container.querySelectorAll(selector).length; }, 'Please select one of the options.' ], "less-than-equals-to": [ - function(value, element, params) { + function (value, element, params) { if ($.isNumeric($(params).val()) && $.isNumeric(value)) { this.lteToVal = $(params).val(); return parseFloat(value) <= parseFloat($(params).val()); } return true; }, - function() { + function () { var message = $.mage.__('Please enter a value less than or equal to %s.'); return message.replace('%s', this.lteToVal); } ], "greater-than-equals-to": [ - function(value, element, params) { + function (value, element, params) { if ($.isNumeric($(params).val()) && $.isNumeric(value)) { this.gteToVal = $(params).val(); return parseFloat(value) >= parseFloat($(params).val()); } return true; }, - function() { + function () { var message = $.mage.__('Please enter a value greater than or equal to %s.'); return message.replace('%s', this.gteToVal); } ], "validate-emails": [ - function(value) { + function (value) { if ($.mage.isEmpty(value)) { return true; } @@ -978,7 +978,7 @@ * @param params - selector for credit card number * @return {boolean} */ - function(value, element, params) { + function (value, element, params) { if (value && params && creditCartTypes[value]) { return creditCartTypes[value][0].test($(params).val().replace(/\s+/g, '')); } @@ -991,7 +991,7 @@ * @param value - credit card number * @return {boolean} */ - function(value) { + function (value) { if (value) { return validateCreditCard(value); } @@ -1006,7 +1006,7 @@ * @param params - selector for credit card type * @return {boolean} */ - function(value, element, params) { + function (value, element, params) { if (value && params) { var ccType = $(params).val(); value = value.replace(/\s/g, '').replace(/\-/g, ''); @@ -1027,7 +1027,7 @@ * @param params - year selector * @return {Boolean} */ - function(value, element, params) { + function (value, element, params) { var isValid = false; if (value && params) { var month = value, @@ -1048,7 +1048,7 @@ * @param params - credit card type selector * @return {*} */ - function(value, element, params) { + function (value, element, params) { if (value && params) { var ccType = $(params).val(); if (creditCartTypes[ccType] && creditCartTypes[ccType][0]) { @@ -1064,19 +1064,19 @@ * @param value - input field value * @return {*} */ - function(value) { + function (value) { return value; }, 'Please enter issue number or start date for switch/solo card type.' ], "validate-length": [ - function(v, elm) { + function (v, elm) { var reMax = new RegExp(/^maximum-length-[0-9]+$/), reMin = new RegExp(/^minimum-length-[0-9]+$/), validator = this, result = true, length = 0; - $.each(elm.className.split(' '), function(index, name) { + $.each(elm.className.split(' '), function (index, name) { if (name.match(reMax) && result) { length = name.split('-')[2]; validator.attrLength = length; @@ -1088,18 +1088,18 @@ } }); return result; - }, function() { + }, function () { return $.mage.__("Maximum length of this field must be equal or less than %1 symbols.") .replace('%1', this.attrLength); } ], 'required-entry': [ - function(value) { + function (value) { return !$.mage.isEmpty(value); }, $.mage.__('This is a required field.') ], 'not-negative-amount': [ - function(v) { + function (v) { if (v.length) return (/^\s*\d+([,.]\d+)*\s*%?\s*$/).test(v); else @@ -1108,7 +1108,7 @@ 'Please enter positive number in this field.' ], 'validate-per-page-value-list': [ - function(v) { + function (v) { var isValid = !$.mage.isEmpty(v); var values = v.split(','); for (var i = 0; i < values.length; i++) { @@ -1121,7 +1121,7 @@ 'Please enter a valid value, ex: 10,20,30' ], 'validate-per-page-value': [ - function(v, elm) { + function (v, elm) { if ($.mage.isEmpty(v)) { return false; } @@ -1131,10 +1131,9 @@ 'Please enter a valid value from list' ], 'validate-new-password': [ - function(v) { + function (v) { - if ($.validator.methods['validate-password'] && - !$.validator.methods['validate-password'](v)) { + if ($.validator.methods['validate-password'] && !$.validator.methods['validate-password'](v)) { return false; } if ($.mage.isEmpty(v) && v !== '') { @@ -1168,6 +1167,19 @@ }, 'This is a required field.' ], + 'required-if-all-sku-empty': [ + function (value, element, params) { + var valid = false; + + $('input[' + params + '=true]').each(function () { + if ($(this).val() !== '') { + valid = true; + } + }); + + return valid; + }, 'Enter valid SKU key' + ], 'required-if-specified': [ function (value, element, params) { var valid = true; @@ -1194,9 +1206,9 @@ 'This is a required field.' ], 'required-number-if-specified': [ - function (value, element, params) { - var valid = true, - dependent = $(params), + function (value, element, params) { + var valid = true, + dependent = $(params), depeValue; if (dependent.length) { @@ -1219,8 +1231,8 @@ // validate quantity var isMinAllowedValid = typeof params.minAllowed === 'undefined' || (qty >= $.mage.parseNumber(params.minAllowed)); - var isMaxAllowedValid = typeof params.maxAllowed === 'undefined' || (qty <= $.mage.parseNumber(params.maxAllowed)); - var isQtyIncrementsValid = typeof params.qtyIncrements === 'undefined' || (qty % $.mage.parseNumber(params.qtyIncrements) === 0); + var isMaxAllowedValid = typeof params.maxAllowed === 'undefined' || (qty <= $.mage.parseNumber(params.maxAllowed)); + var isQtyIncrementsValid = typeof params.qtyIncrements === 'undefined' || (qty % $.mage.parseNumber(params.qtyIncrements) === 0); return isMaxAllowedValid && isMinAllowedValid && isQtyIncrementsValid && qty > 0; }, @@ -1228,7 +1240,7 @@ ] }; - $.each(rules, function(i, rule) { + $.each(rules, function (i, rule) { rule.unshift(i); $.validator.addMethod.apply($.validator, rule); }); @@ -1254,7 +1266,7 @@ var showLabel = $.validator.prototype.showLabel; $.extend(true, $.validator.prototype, { - showLabel: function(element, message) { + showLabel: function (element, message) { showLabel.call(this, element, message); // ARIA (adding aria-invalid & aria-describedby) @@ -1262,7 +1274,7 @@ elem = $(element); if (!label.attr('id')) { - label.attr('id', this.idOrName(element)+'-error'); + label.attr('id', this.idOrName(element) + '-error'); } elem.attr('aria-invalid', 'true') .attr('aria-describedby', label.attr('id')); @@ -1274,7 +1286,7 @@ * @param {Element||String} element - DOM element or selector * @return {Boolean} validation result */ - $.validator.validateElement = function(element) { + $.validator.validateElement = function (element) { element = $(element); var form = element.get(0).form, validator = form ? $(form).data('validator') : null; @@ -1284,7 +1296,7 @@ } else { var valid = true, classes = element.prop('class').split(' '); - $.each(classes, $.proxy(function(i, className) { + $.each(classes, $.proxy(function (i, className) { if (this.methods[className] && !this.methods[className](element.val(), element.get(0))) { valid = false; return valid; @@ -1303,7 +1315,7 @@ ignoreTitle: true, errorClass: 'mage-error', errorElement: 'div', - errorPlacement: function(error, element) { + errorPlacement: function (error, element) { var errorPlacement = element; // logic for date-picker error placement if (element.hasClass('hasDatepicker')) { @@ -1325,16 +1337,16 @@ * Check if form pass validation rules without submit * @return boolean */ - isValid: function() { + isValid: function () { return this.element.valid(); }, /** * Remove validation error messages */ - clearError: function() { + clearError: function () { if (arguments.length) { - $.each(arguments, $.proxy(function(index, item) { + $.each(arguments, $.proxy(function (index, item) { this.validate.prepareElement(item); this.validate.hideErrors(); }, this)); @@ -1346,7 +1358,7 @@ * Validation creation * @protected */ - _create: function() { + _create: function () { this.validate = this.element.validate(this.options); // ARIA (adding aria-required attribute) @@ -1362,7 +1374,7 @@ * Validation listening * @protected */ - _listenFormValidate: function() { + _listenFormValidate: function () { $('form').on('invalid-form.validate', function (event, validation) { var firstActive = $(validation.errorList[0].element || []), lastActive = $(validation.findLastActive() || validation.errorList.length && validation.errorList[0].element || []); @@ -1378,7 +1390,7 @@ // ARIA (removing aria attributes if success) var successList = validation.successList; if (successList.length) { - $.each(successList, function() { + $.each(successList, function () { $(this) .removeAttr('aria-describedby') .removeAttr('aria-invalid');