diff options
author | Stevo Slavic <sslavic@gmail.com> | 2014-06-30 20:25:17 +0400 |
---|---|---|
committer | Stevo Slavic <sslavic@gmail.com> | 2014-06-30 23:31:39 +0400 |
commit | 855d83bb7f1fb47e900e2ba9ae0a69fc6b0c7a84 (patch) | |
tree | 84d128c506fce4166206b88408fa94c806628bd0 /tests/javascript | |
parent | 49d6eec6243e9ee88e838f239868093f2da77735 (diff) |
Fixed addPlugin unit test to use a different approch for verifying custom plugin was succssfully registered and works as expected
Diffstat (limited to 'tests/javascript')
-rw-r--r-- | tests/javascript/index.php | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/tests/javascript/index.php b/tests/javascript/index.php index 2f38c69dea..c1cff28772 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -772,21 +772,22 @@ function PiwikTest() { // support for addPlugin( pluginName, pluginObj ) test("Tracker addPlugin() and getRequest()", function() { - expect(9); + expect(12); var tracker = Piwik.getTracker(); - var interactionTypePlugin = (function() { - function _getInteractionTypeQueryParam(method) { return "&_interactionType='" + method + "'"; } - function ecommerce() { return _getInteractionTypeQueryParam("ecommerce"); } - function event() { return _getInteractionTypeQueryParam("event"); } - function goal() { return _getInteractionTypeQueryParam("goal"); } - function link() { return _getInteractionTypeQueryParam("link"); } - function load() { return _getInteractionTypeQueryParam("load"); } - function log() { return _getInteractionTypeQueryParam("log"); } - function ping() { return _getInteractionTypeQueryParam("ping"); } - function sitesearch() { return _getInteractionTypeQueryParam("sitesearch"); } - function unload() { return _getInteractionTypeQueryParam("unload"); } + var litp = (function() { + var lastInteractionType = ""; + function ecommerce() { lastInteractionType = "ecommerce"; } + function event() { lastInteractionType = "event"; } + function goal() { lastInteractionType = "goal"; } + function link() { lastInteractionType = "link"; } + function load() { lastInteractionType = "load"; } + function log() { lastInteractionType = "log"; } + function ping() { lastInteractionType = "ping"; } + function sitesearch() { lastInteractionType = "sitesearch"; } + function unload() { lastInteractionType = "unload"; } + function getLastInteractionType() { return lastInteractionType; } return { ecommerce: ecommerce, @@ -797,21 +798,36 @@ function PiwikTest() { log : log, ping: ping, sitesearch : sitesearch, - unload : unload + unload : unload, + getLastInteractionType: getLastInteractionType }; })(); - tracker.addPlugin("interactionTypePlugin", interactionTypePlugin); - - ok( tracker.getRequest("", "", "ecommerce").indexOf("&_interactionType='ecommerce'") > -1); - ok( tracker.getRequest("", "", "event").indexOf("&_interactionType='event'") > -1); - ok( tracker.getRequest("", "", "goal").indexOf("&_interactionType='goal'") > -1); - ok( tracker.getRequest("", "", "link").indexOf("&_interactionType='link'") > -1); - ok( tracker.getRequest("", "", "load").indexOf("&_interactionType='load'") > -1); - ok( tracker.getRequest("", "", "log").indexOf("&_interactionType='log'") > -1); - ok( tracker.getRequest("", "", "ping").indexOf("&_interactionType='ping'") > -1); - ok( tracker.getRequest("", "", "sitesearch").indexOf("&_interactionType='sitesearch'") > -1); - ok( tracker.getRequest("", "", "unload").indexOf("&_interactionType='unload'") > -1); + tracker.addPlugin("interactionTypePlugin", litp); + + ok(litp.getLastInteractionType() !== 'ecommerce'); + tracker.trackEcommerceOrder("ORDER ID YES", 666.66); + ok(litp.getLastInteractionType() === 'ecommerce'); + + ok(litp.getLastInteractionType() !== 'event'); + tracker.trackEvent("Event Category", "Event Action"); + ok(litp.getLastInteractionType() === 'event'); + + ok(litp.getLastInteractionType() !== 'goal'); + tracker.trackGoal(42); + ok(litp.getLastInteractionType() === 'goal'); + + ok(litp.getLastInteractionType() !== 'link'); + tracker.trackLink("http://example.ca", "link"); + ok(litp.getLastInteractionType() === 'link'); + + ok(litp.getLastInteractionType() !== 'log'); + tracker.trackPageView(); + ok(litp.getLastInteractionType() === 'log'); + + ok(litp.getLastInteractionType() !== 'sitesearch'); + tracker.trackSiteSearch("search Keyword"); + ok(litp.getLastInteractionType() === 'sitesearch'); }); test("prefixPropertyName()", function() { |