This repository has been archived by the owner on Mar 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
367 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# Tests cannot be run from metarepo - it's a public repository, which doesn't have access to private repositories on Travis (for security reasons). | ||
# The actual test setup is in Page Builder bundle. | ||
language: php | ||
php: | ||
- '5.6' | ||
language: node_js | ||
|
||
node_js: | ||
- '11' | ||
|
||
install: | ||
- npm install | ||
|
||
script: | ||
- echo 'Test suite moved to PageBuilder bundle' | ||
- npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 13 additions & 15 deletions
28
app/Resources/views/themes/ezplatform/line/bundle_card.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "ezplatform.com", | ||
"version": "2.3.0", | ||
"author": "eZ Systems", | ||
"homepage": "ez.no", | ||
"scripts": { | ||
"test": "mocha --compilers js:babel-core/register ./test/*.spec.js" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.26.3", | ||
"babel-preset-es2015": "^6.24.1", | ||
"chai": "^4.2.0", | ||
"chai-dom": "^1.8.1", | ||
"chai-subset": "^1.6.0", | ||
"jquery": "^3.3.1", | ||
"jsdom": "^13.0.0", | ||
"mocha": "^5.2.0", | ||
"sinon": "^7.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const expect = require('chai').use(require('chai-subset')).expect, | ||
GoogleAnalyticsItem = require('../web/assets/js/GoogleAnalyticsItem'); | ||
|
||
describe('GoogleAnalyticsItem', () => { | ||
let gaItem; | ||
|
||
beforeEach(() => { | ||
gaItem = new GoogleAnalyticsItem('event', 'Downloads', 'Download', 'Label', 'Transport'); | ||
}); | ||
|
||
it('should return instance of GoogleAnalyticsItem', () => { | ||
expect(gaItem).to.be.instanceOf(GoogleAnalyticsItem); | ||
}); | ||
|
||
it('should be an object with own property hitType', () => { | ||
expect(gaItem).to.be.an('object').that.has.own.property('hitType'); | ||
}); | ||
|
||
it('should be an object with own property eventCategory', () => { | ||
expect(gaItem).to.be.an('object').that.has.own.property('eventCategory'); | ||
}); | ||
|
||
it('should be an object with own property eventAction', () => { | ||
expect(gaItem).to.be.an('object').that.has.own.property('eventAction'); | ||
}); | ||
|
||
it('should be an object with own property eventLabel', () => { | ||
expect(gaItem).to.be.an('object').that.has.own.property('eventLabel'); | ||
}); | ||
|
||
it('should be an object with own property transport', () => { | ||
expect(gaItem).to.be.an('object').that.has.own.property('transport'); | ||
}); | ||
|
||
it('should be an object contain subset', () => { | ||
expect(gaItem).to.be.an('object').that.containSubset({ | ||
'hitType': 'event', | ||
'eventCategory': 'Downloads', | ||
'eventAction': 'Download', | ||
'eventLabel': 'Label', | ||
'transport': 'Transport' | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
const expect = require('chai').use(require('chai-dom')).expect, | ||
sinon = require('sinon'), | ||
{ | ||
JSDOM | ||
} = require('jsdom'), | ||
GoogleAnalyticsService = require('../web/assets/js/GoogleAnalyticsService'), | ||
GoogleAnalyticsItem = require('../web/assets/js/GoogleAnalyticsItem'); | ||
|
||
describe('GoogleAnalyticsService', () => { | ||
let gaService, | ||
document, | ||
jQuery, | ||
eventClick; | ||
|
||
const template = '/html/gaTemplate.html', | ||
gaDataAttr = 'data-ga-action', | ||
gaCategoryAttr = 'data-ga-category', | ||
gaLabelAttr = 'data-ga-label'; | ||
|
||
beforeEach(() => { | ||
gaService = new GoogleAnalyticsService(); | ||
eventClick = sinon.spy(); | ||
|
||
return JSDOM.fromFile(__dirname + template) | ||
.then(dom => { | ||
document = dom.window.document | ||
jQuery = require('jquery')(dom.window); | ||
jQuery(document).on('click', eventClick); | ||
|
||
return document; | ||
}) | ||
.catch(error => { | ||
console.log(error); | ||
}); | ||
}); | ||
|
||
it('should return instance of GoogleAnalyticsService', () => { | ||
expect(gaService).to.be.instanceOf(GoogleAnalyticsService); | ||
}); | ||
|
||
it('should find selectors with data attribute data-ga-action', () => { | ||
expect(document.querySelectorAll(`[${gaDataAttr}]`)).not.to.have.lengthOf(0); | ||
}); | ||
|
||
it('should return value for each data-ga-action attribute', () => { | ||
let selectors = document.querySelectorAll(`[${gaDataAttr}]`); | ||
selectors.forEach(selector => { | ||
expect(gaService.getGAAction(selector), selector.outerHTML).not.to.have.lengthOf(0); | ||
}); | ||
}); | ||
|
||
it('should return true if body has data-ga-category attribute', () => { | ||
expect(document.body).to.have.attribute(gaCategoryAttr); | ||
}); | ||
|
||
it('should return value for data-ga-category attribute', () => { | ||
expect(document.querySelector(`[${gaCategoryAttr}]`).getAttribute(gaCategoryAttr)).not.to.have.lengthOf(0); | ||
}); | ||
|
||
it('should return Google Analytics Label if data-ga-label attribute exists', () => { | ||
let selectors = document.querySelectorAll(`[${gaLabelAttr}]`); | ||
selectors.forEach(selector => { | ||
expect(gaService.getGALabel(selector), selector.outerHTML).not.to.have.lengthOf(0); | ||
}); | ||
}); | ||
|
||
it ('should rewrite data attributes to child selector when ga-link-listener class exists', () => { | ||
let selector = document.querySelector('.ga-link-listener'), | ||
childSelector = gaService.rewriteIfHasChildSelector(selector); | ||
expect(childSelector.dataset).containSubset(selector.dataset); | ||
}); | ||
|
||
it('should create GoogleAnalyticsItem object after click on data-ga-action event', () => { | ||
let selectors = document.querySelectorAll(`[${gaDataAttr}]`), | ||
gaItem; | ||
|
||
selectors.forEach(selector => { | ||
selector.addEventListener('click', () => { | ||
gaItem = new GoogleAnalyticsItem('event', 'Downloads', 'Download', 'Label', 'Transport'); | ||
}); | ||
jQuery(selector).click(); | ||
expect(gaItem).to.be.instanceOf(GoogleAnalyticsItem).that.containSubset({ | ||
'hitType': 'event', | ||
'eventCategory': 'Downloads', | ||
'eventAction': 'Download', | ||
'eventLabel': 'Label', | ||
'transport': 'Transport' | ||
}); | ||
}); | ||
|
||
expect(eventClick.callCount).to.equal(selectors.length); | ||
}); | ||
}); |
Oops, something went wrong.