Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2019-01-27 06:23:03 +0300
committerGitHub <noreply@github.com>2019-01-27 06:23:03 +0300
commit141962167f74b52a101ff0a781ff855e1a09d163 (patch)
tree8f329091e8bab3540ec4d1d7741519f18665f4ff /tests/javascript
parent7e8954044d71806e26169115f61b4a086234cc78 (diff)
Add method to get ecommerce items to tracker (#14028)
* Add getEcommerceItems() method to tracker so users can see what was added/removed. * doc twea * Update minified JS. * Fix test.
Diffstat (limited to 'tests/javascript')
-rw-r--r--tests/javascript/index.php48
1 files changed, 46 insertions, 2 deletions
diff --git a/tests/javascript/index.php b/tests/javascript/index.php
index 65d197544a..d2c5f8cfa2 100644
--- a/tests/javascript/index.php
+++ b/tests/javascript/index.php
@@ -2141,7 +2141,7 @@ function PiwikTest() {
});
test("API methods", function() {
- expect(105);
+ expect(106);
equal( typeof Piwik.addPlugin, 'function', 'addPlugin' );
equal( typeof Piwik.addPlugin, 'function', 'addTracker' );
@@ -2243,6 +2243,7 @@ function PiwikTest() {
equal( typeof tracker.logAllContentBlocksOnPage, 'function', 'logAllContentBlocksOnPage' );
// ecommerce
equal( typeof tracker.setEcommerceView, 'function', 'setEcommerceView' );
+ equal( typeof tracker.getEcommerceItems, 'function', 'getEcommerceItems' );
equal( typeof tracker.addEcommerceItem, 'function', 'addEcommerceItem' );
equal( typeof tracker.removeEcommerceItem, 'function', 'removeEcommerceItem' );
equal( typeof tracker.clearEcommerceCart, 'function', 'clearEcommerceCart' );
@@ -3630,7 +3631,7 @@ if ($mysql) {
test("tracking", function() {
- expect(157);
+ expect(158);
// Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL)
var stopEvent = function (evt) {
@@ -3963,6 +3964,49 @@ if ($mysql) {
tracker3.addEcommerceItem("SKU NO PRICE NO QUANTITY", "PRODUCT NAME 3", "CATEGORY", "", "" );
tracker3.addEcommerceItem("SKU ONLY" );
tracker3.removeEcommerceItem("SKU TO REMOVE");
+
+ var cart = tracker3.getEcommerceItems();
+ deepEqual(cart, {
+ "SKU NO PRICE NO QUANTITY": [
+ "SKU NO PRICE NO QUANTITY",
+ "PRODUCT NAME 3",
+ "CATEGORY",
+ "",
+ ""
+ ],
+ "SKU ONLY": [
+ "SKU ONLY",
+ null,
+ null,
+ null,
+ null
+ ],
+ "SKU ONLY NAME": [
+ "SKU ONLY NAME",
+ "PRODUCT NAME 2",
+ "",
+ "",
+ null
+ ],
+ "SKU ONLY SKU": [
+ "SKU ONLY SKU",
+ "",
+ "",
+ "",
+ ""
+ ],
+ "SKU PRODUCT": [
+ "SKU PRODUCT",
+ "random",
+ "random PRODUCT CATEGORY",
+ 11.1111,
+ 2
+ ]
+ });
+
+ // test that changing the cart object does not change the internal ecommerceItems var
+ cart["SKU PRODUCT"][3] = 5;
+
tracker3.trackEcommerceCartUpdate( 555.55 );
tracker3.trackEcommerceOrder( "ORDER ID YES", 666.66, 333, 222, 111, 1 );