From 29af1760b1bb5cdcdcdff6b5a6b1d0c9726d7ce9 Mon Sep 17 00:00:00 2001 From: Matteo Gabriele Date: Sun, 2 May 2021 13:54:02 +0200 Subject: [PATCH] fix: bootstrap, first config hit and multiple hit (#294) closes #165 --- __tests__/__snapshots__/install.spec.js.snap | 32 -- __tests__/__snapshots__/util.spec.js.snap | 33 -- __tests__/api/config.spec.js | 39 -- __tests__/api/event.spec.js | 44 --- __tests__/api/exception.spec.js | 14 - __tests__/api/ga-disable.spec.js | 42 --- __tests__/api/linker.spec.js | 11 - __tests__/api/opt-in.spec.js | 16 - __tests__/api/opt-out.spec.js | 16 - __tests__/api/pageview.spec.js | 23 -- __tests__/api/purchase.spec.js | 14 - __tests__/api/query.spec.js | 36 -- __tests__/api/refund.spec.js | 14 - __tests__/api/screenview.spec.js | 35 -- __tests__/api/set.spec.js | 14 - __tests__/api/time.spec.js | 14 - __tests__/bootstrap.spec.js | 332 ----------------- __tests__/extend.spec.js | 18 - __tests__/index.spec.js | 20 - __tests__/install.spec.js | 50 --- __tests__/page-tracker.spec.js | 171 --------- __tests__/ssr-friendly.spec.js | 15 - bili.config.dev.js | 13 - bili.config.js | 14 +- jest/init.js | 2 + package.json | 36 +- src/add-configuration.js | 19 + src/add-routes-tracker.js | 32 ++ src/api/config.js | 4 +- src/api/custom-map.js | 2 +- src/api/disable.js | 15 + src/api/event.js | 13 +- src/api/exception.js | 2 +- src/api/ga-disable.js | 13 - src/api/index.js | 45 +-- src/api/opt-in.js | 2 +- src/api/opt-out.js | 2 +- src/api/pageview.js | 34 +- src/api/purchase.js | 6 +- src/api/query.js | 13 +- src/api/refund.js | 2 +- src/api/screenview.js | 32 +- src/api/set.js | 2 +- src/api/time.js | 6 +- src/attach-api.js | 5 + src/bootstrap.js | 66 ++-- src/extend.js | 8 - src/index.js | 63 ++-- src/install.js | 56 --- src/options.js | 41 +++ src/page-tracker.js | 100 ----- src/register-globals.js | 26 ++ src/router.js | 9 + src/track.js | 44 +++ src/{util.js => utils.js} | 47 ++- test/__mocks__/vue/index.js | 6 + test/__snapshots__/options.spec.js.snap | 63 ++++ .../register-globals.spec.js.snap | 10 + test/__snapshots__/utils.spec.js.snap | 30 ++ test/add-configuration.spec.js | 55 +++ test/add-routes-tracker.spec.js | 238 ++++++++++++ test/api/config.spec.js | 43 +++ {__tests__ => test}/api/custom-map.spec.js | 5 +- test/api/disable.spec.js | 71 ++++ test/api/event.spec.js | 81 +++++ test/api/exception.spec.js | 14 + test/api/linker.spec.js | 14 + test/api/opt-in.spec.js | 11 + test/api/opt-out.spec.js | 11 + test/api/pageview.spec.js | 136 +++++++ test/api/purchase.spec.js | 14 + test/api/query.spec.js | 31 ++ test/api/refund.spec.js | 14 + test/api/screenview.spec.js | 77 ++++ test/api/set.spec.js | 12 + test/api/time.spec.js | 14 + test/basic.spec.js | 78 ++++ test/bootstrap.spec.js | 206 +++++++++++ test/exports.spec.js | 55 +++ test/options.spec.js | 21 ++ test/register-globals.spec.js | 88 +++++ test/track.spec.js | 323 ++++++++++++++++ __tests__/util.spec.js => test/utils.spec.js | 39 +- yarn.lock | 344 ++++++++++++++++-- 84 files changed, 2456 insertions(+), 1425 deletions(-) delete mode 100644 __tests__/__snapshots__/install.spec.js.snap delete mode 100644 __tests__/__snapshots__/util.spec.js.snap delete mode 100644 __tests__/api/config.spec.js delete mode 100644 __tests__/api/event.spec.js delete mode 100644 __tests__/api/exception.spec.js delete mode 100644 __tests__/api/ga-disable.spec.js delete mode 100644 __tests__/api/linker.spec.js delete mode 100644 __tests__/api/opt-in.spec.js delete mode 100644 __tests__/api/opt-out.spec.js delete mode 100644 __tests__/api/pageview.spec.js delete mode 100644 __tests__/api/purchase.spec.js delete mode 100644 __tests__/api/query.spec.js delete mode 100644 __tests__/api/refund.spec.js delete mode 100644 __tests__/api/screenview.spec.js delete mode 100644 __tests__/api/set.spec.js delete mode 100644 __tests__/api/time.spec.js delete mode 100644 __tests__/bootstrap.spec.js delete mode 100644 __tests__/extend.spec.js delete mode 100644 __tests__/index.spec.js delete mode 100644 __tests__/install.spec.js delete mode 100644 __tests__/page-tracker.spec.js delete mode 100644 __tests__/ssr-friendly.spec.js delete mode 100644 bili.config.dev.js create mode 100644 jest/init.js create mode 100644 src/add-configuration.js create mode 100644 src/add-routes-tracker.js create mode 100644 src/api/disable.js delete mode 100644 src/api/ga-disable.js create mode 100644 src/attach-api.js delete mode 100644 src/extend.js delete mode 100644 src/install.js create mode 100644 src/options.js delete mode 100644 src/page-tracker.js create mode 100644 src/register-globals.js create mode 100644 src/router.js create mode 100644 src/track.js rename src/{util.js => utils.js} (63%) create mode 100644 test/__mocks__/vue/index.js create mode 100644 test/__snapshots__/options.spec.js.snap create mode 100644 test/__snapshots__/register-globals.spec.js.snap create mode 100644 test/__snapshots__/utils.spec.js.snap create mode 100644 test/add-configuration.spec.js create mode 100644 test/add-routes-tracker.spec.js create mode 100644 test/api/config.spec.js rename {__tests__ => test}/api/custom-map.spec.js (73%) create mode 100644 test/api/disable.spec.js create mode 100644 test/api/event.spec.js create mode 100644 test/api/exception.spec.js create mode 100644 test/api/linker.spec.js create mode 100644 test/api/opt-in.spec.js create mode 100644 test/api/opt-out.spec.js create mode 100644 test/api/pageview.spec.js create mode 100644 test/api/purchase.spec.js create mode 100644 test/api/query.spec.js create mode 100644 test/api/refund.spec.js create mode 100644 test/api/screenview.spec.js create mode 100644 test/api/set.spec.js create mode 100644 test/api/time.spec.js create mode 100644 test/basic.spec.js create mode 100644 test/bootstrap.spec.js create mode 100644 test/exports.spec.js create mode 100644 test/options.spec.js create mode 100644 test/register-globals.spec.js create mode 100644 test/track.spec.js rename __tests__/util.spec.js => test/utils.spec.js (68%) diff --git a/__tests__/__snapshots__/install.spec.js.snap b/__tests__/__snapshots__/install.spec.js.snap deleted file mode 100644 index 443e47e..0000000 --- a/__tests__/__snapshots__/install.spec.js.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`install should have default options 1`] = ` -Object { - "appName": null, - "bootstrap": true, - "config": Object { - "id": null, - "params": Object { - "send_page_view": false, - }, - }, - "customPreconnectOrigin": "https://www.googletagmanager.com", - "customResourceURL": "https://www.googletagmanager.com/gtag/js", - "defaultGroupName": "default", - "deferScriptLoad": false, - "disableScriptLoad": false, - "enabled": true, - "globalDataLayerName": "dataLayer", - "globalObjectName": "gtag", - "includes": null, - "onAfterTrack": [Function], - "onBeforeTrack": [Function], - "onError": [Function], - "onReady": [Function], - "pageTrackerEnabled": true, - "pageTrackerScreenviewEnabled": false, - "pageTrackerSkipSamePath": true, - "pageTrackerTemplate": [Function], - "pageTrackerUseFullPath": false, -} -`; diff --git a/__tests__/__snapshots__/util.spec.js.snap b/__tests__/__snapshots__/util.spec.js.snap deleted file mode 100644 index c2ea03f..0000000 --- a/__tests__/__snapshots__/util.spec.js.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`loadScript should create a link for domain preconnect 1`] = ` - - -