diff --git a/package.json b/package.json index aa887d2..b9d9581 100755 --- a/package.json +++ b/package.json @@ -202,14 +202,14 @@ "scripts": { "build": "./script/build-dist.sh && ./script/build-esm.js", "build+test": "npm run build && npm run test", - "fuzz": "jazzer ./test/jazzer-fuzz-test.js --sync", + "fuzz": "jazzer ./test/fuzz/redos.js --sync", "test": "./script/test-all.sh", - "test:dts-lint": "tsd --typings src/main/ua-parser.d.ts --files test/dts-test.ts", + "test:dts-lint": "tsd --typings src/main/ua-parser.d.ts --files test/static/dts-lint.ts", "test:eslint": "eslint src && eslint script", "test:jshint": "jshint src/main", "test:lockfile-lint": "npx lockfile-lint -p package-lock.json", - "test:mocha": "mocha test/mocha*js", - "test:playwright": "playwright test" + "test:mocha": "mocha test/unit", + "test:playwright": "playwright test test/e2e --browser all" }, "dependencies": { "detect-europe-js": "^0.1.2", diff --git a/test/specs/browser/browser-all.json b/test/data/ua/browser/browser-all.json similarity index 100% rename from test/specs/browser/browser-all.json rename to test/data/ua/browser/browser-all.json diff --git a/test/specs/cpu/cpu-all.json b/test/data/ua/cpu/cpu-all.json similarity index 100% rename from test/specs/cpu/cpu-all.json rename to test/data/ua/cpu/cpu-all.json diff --git a/test/specs/device/_others.json b/test/data/ua/device/_others.json similarity index 100% rename from test/specs/device/_others.json rename to test/data/ua/device/_others.json diff --git a/test/specs/device/acer.json b/test/data/ua/device/acer.json similarity index 100% rename from test/specs/device/acer.json rename to test/data/ua/device/acer.json diff --git a/test/specs/device/advan.json b/test/data/ua/device/advan.json similarity index 100% rename from test/specs/device/advan.json rename to test/data/ua/device/advan.json diff --git a/test/specs/device/alcatel.json b/test/data/ua/device/alcatel.json similarity index 100% rename from test/specs/device/alcatel.json rename to test/data/ua/device/alcatel.json diff --git a/test/specs/device/amazon.json b/test/data/ua/device/amazon.json similarity index 100% rename from test/specs/device/amazon.json rename to test/data/ua/device/amazon.json diff --git a/test/specs/device/apple.json b/test/data/ua/device/apple.json similarity index 100% rename from test/specs/device/apple.json rename to test/data/ua/device/apple.json diff --git a/test/specs/device/asus.json b/test/data/ua/device/asus.json similarity index 100% rename from test/specs/device/asus.json rename to test/data/ua/device/asus.json diff --git a/test/specs/device/blackberry.json b/test/data/ua/device/blackberry.json similarity index 100% rename from test/specs/device/blackberry.json rename to test/data/ua/device/blackberry.json diff --git a/test/specs/device/cat.json b/test/data/ua/device/cat.json similarity index 100% rename from test/specs/device/cat.json rename to test/data/ua/device/cat.json diff --git a/test/specs/device/energizer.json b/test/data/ua/device/energizer.json similarity index 100% rename from test/specs/device/energizer.json rename to test/data/ua/device/energizer.json diff --git a/test/specs/device/facebook.json b/test/data/ua/device/facebook.json similarity index 100% rename from test/specs/device/facebook.json rename to test/data/ua/device/facebook.json diff --git a/test/specs/device/fairphone.json b/test/data/ua/device/fairphone.json similarity index 100% rename from test/specs/device/fairphone.json rename to test/data/ua/device/fairphone.json diff --git a/test/specs/device/google.json b/test/data/ua/device/google.json similarity index 100% rename from test/specs/device/google.json rename to test/data/ua/device/google.json diff --git a/test/specs/device/hmd.json b/test/data/ua/device/hmd.json similarity index 100% rename from test/specs/device/hmd.json rename to test/data/ua/device/hmd.json diff --git a/test/specs/device/honor.json b/test/data/ua/device/honor.json similarity index 100% rename from test/specs/device/honor.json rename to test/data/ua/device/honor.json diff --git a/test/specs/device/htc.json b/test/data/ua/device/htc.json similarity index 100% rename from test/specs/device/htc.json rename to test/data/ua/device/htc.json diff --git a/test/specs/device/huawei.json b/test/data/ua/device/huawei.json similarity index 100% rename from test/specs/device/huawei.json rename to test/data/ua/device/huawei.json diff --git a/test/specs/device/imo.json b/test/data/ua/device/imo.json similarity index 100% rename from test/specs/device/imo.json rename to test/data/ua/device/imo.json diff --git a/test/specs/device/infinix.json b/test/data/ua/device/infinix.json similarity index 100% rename from test/specs/device/infinix.json rename to test/data/ua/device/infinix.json diff --git a/test/specs/device/itel.json b/test/data/ua/device/itel.json similarity index 100% rename from test/specs/device/itel.json rename to test/data/ua/device/itel.json diff --git a/test/specs/device/jolla.json b/test/data/ua/device/jolla.json similarity index 100% rename from test/specs/device/jolla.json rename to test/data/ua/device/jolla.json diff --git a/test/specs/device/kobo.json b/test/data/ua/device/kobo.json similarity index 100% rename from test/specs/device/kobo.json rename to test/data/ua/device/kobo.json diff --git a/test/specs/device/lenovo.json b/test/data/ua/device/lenovo.json similarity index 100% rename from test/specs/device/lenovo.json rename to test/data/ua/device/lenovo.json diff --git a/test/specs/device/lg.json b/test/data/ua/device/lg.json similarity index 100% rename from test/specs/device/lg.json rename to test/data/ua/device/lg.json diff --git a/test/specs/device/meizu.json b/test/data/ua/device/meizu.json similarity index 100% rename from test/specs/device/meizu.json rename to test/data/ua/device/meizu.json diff --git a/test/specs/device/micromax.json b/test/data/ua/device/micromax.json similarity index 100% rename from test/specs/device/micromax.json rename to test/data/ua/device/micromax.json diff --git a/test/specs/device/microsoft.json b/test/data/ua/device/microsoft.json similarity index 100% rename from test/specs/device/microsoft.json rename to test/data/ua/device/microsoft.json diff --git a/test/specs/device/motorola.json b/test/data/ua/device/motorola.json similarity index 100% rename from test/specs/device/motorola.json rename to test/data/ua/device/motorola.json diff --git a/test/specs/device/nintendo.json b/test/data/ua/device/nintendo.json similarity index 100% rename from test/specs/device/nintendo.json rename to test/data/ua/device/nintendo.json diff --git a/test/specs/device/nokia.json b/test/data/ua/device/nokia.json similarity index 100% rename from test/specs/device/nokia.json rename to test/data/ua/device/nokia.json diff --git a/test/specs/device/nothing.json b/test/data/ua/device/nothing.json similarity index 100% rename from test/specs/device/nothing.json rename to test/data/ua/device/nothing.json diff --git a/test/specs/device/nvidia.json b/test/data/ua/device/nvidia.json similarity index 100% rename from test/specs/device/nvidia.json rename to test/data/ua/device/nvidia.json diff --git a/test/specs/device/oneplus.json b/test/data/ua/device/oneplus.json similarity index 100% rename from test/specs/device/oneplus.json rename to test/data/ua/device/oneplus.json diff --git a/test/specs/device/oppo.json b/test/data/ua/device/oppo.json similarity index 100% rename from test/specs/device/oppo.json rename to test/data/ua/device/oppo.json diff --git a/test/specs/device/ouya.json b/test/data/ua/device/ouya.json similarity index 100% rename from test/specs/device/ouya.json rename to test/data/ua/device/ouya.json diff --git a/test/specs/device/panasonic.json b/test/data/ua/device/panasonic.json similarity index 100% rename from test/specs/device/panasonic.json rename to test/data/ua/device/panasonic.json diff --git a/test/specs/device/pico.json b/test/data/ua/device/pico.json similarity index 100% rename from test/specs/device/pico.json rename to test/data/ua/device/pico.json diff --git a/test/specs/device/polytron.json b/test/data/ua/device/polytron.json similarity index 100% rename from test/specs/device/polytron.json rename to test/data/ua/device/polytron.json diff --git a/test/specs/device/realme.json b/test/data/ua/device/realme.json similarity index 100% rename from test/specs/device/realme.json rename to test/data/ua/device/realme.json diff --git a/test/specs/device/roku.json b/test/data/ua/device/roku.json similarity index 100% rename from test/specs/device/roku.json rename to test/data/ua/device/roku.json diff --git a/test/specs/device/samsung.json b/test/data/ua/device/samsung.json similarity index 100% rename from test/specs/device/samsung.json rename to test/data/ua/device/samsung.json diff --git a/test/specs/device/sharp.json b/test/data/ua/device/sharp.json similarity index 100% rename from test/specs/device/sharp.json rename to test/data/ua/device/sharp.json diff --git a/test/specs/device/smartfren.json b/test/data/ua/device/smartfren.json similarity index 100% rename from test/specs/device/smartfren.json rename to test/data/ua/device/smartfren.json diff --git a/test/specs/device/sony.json b/test/data/ua/device/sony.json similarity index 100% rename from test/specs/device/sony.json rename to test/data/ua/device/sony.json diff --git a/test/specs/device/tcl.json b/test/data/ua/device/tcl.json similarity index 100% rename from test/specs/device/tcl.json rename to test/data/ua/device/tcl.json diff --git a/test/specs/device/technisat.json b/test/data/ua/device/technisat.json similarity index 100% rename from test/specs/device/technisat.json rename to test/data/ua/device/technisat.json diff --git a/test/specs/device/tecno.json b/test/data/ua/device/tecno.json similarity index 100% rename from test/specs/device/tecno.json rename to test/data/ua/device/tecno.json diff --git a/test/specs/device/tesla.json b/test/data/ua/device/tesla.json similarity index 100% rename from test/specs/device/tesla.json rename to test/data/ua/device/tesla.json diff --git a/test/specs/device/ulefone.json b/test/data/ua/device/ulefone.json similarity index 100% rename from test/specs/device/ulefone.json rename to test/data/ua/device/ulefone.json diff --git a/test/specs/device/vivo.json b/test/data/ua/device/vivo.json similarity index 100% rename from test/specs/device/vivo.json rename to test/data/ua/device/vivo.json diff --git a/test/specs/device/xiaomi.json b/test/data/ua/device/xiaomi.json similarity index 100% rename from test/specs/device/xiaomi.json rename to test/data/ua/device/xiaomi.json diff --git a/test/specs/device/zte.json b/test/data/ua/device/zte.json similarity index 100% rename from test/specs/device/zte.json rename to test/data/ua/device/zte.json diff --git a/test/specs/engine/engine-all.json b/test/data/ua/engine/engine-all.json similarity index 100% rename from test/specs/engine/engine-all.json rename to test/data/ua/engine/engine-all.json diff --git a/test/specs/extension/cli.json b/test/data/ua/extension/cli.json similarity index 100% rename from test/specs/extension/cli.json rename to test/data/ua/extension/cli.json diff --git a/test/specs/extension/crawler.json b/test/data/ua/extension/crawler.json similarity index 100% rename from test/specs/extension/crawler.json rename to test/data/ua/extension/crawler.json diff --git a/test/specs/extension/email.json b/test/data/ua/extension/email.json similarity index 100% rename from test/specs/extension/email.json rename to test/data/ua/extension/email.json diff --git a/test/specs/extension/extra-devices.json b/test/data/ua/extension/extra-devices.json similarity index 100% rename from test/specs/extension/extra-devices.json rename to test/data/ua/extension/extra-devices.json diff --git a/test/specs/extension/fetcher.json b/test/data/ua/extension/fetcher.json similarity index 100% rename from test/specs/extension/fetcher.json rename to test/data/ua/extension/fetcher.json diff --git a/test/specs/extension/library.json b/test/data/ua/extension/library.json similarity index 100% rename from test/specs/extension/library.json rename to test/data/ua/extension/library.json diff --git a/test/specs/extension/mediaplayer.json b/test/data/ua/extension/mediaplayer.json similarity index 100% rename from test/specs/extension/mediaplayer.json rename to test/data/ua/extension/mediaplayer.json diff --git a/test/specs/os/aix.json b/test/data/ua/os/aix.json similarity index 100% rename from test/specs/os/aix.json rename to test/data/ua/os/aix.json diff --git a/test/specs/os/amigaos.json b/test/data/ua/os/amigaos.json similarity index 100% rename from test/specs/os/amigaos.json rename to test/data/ua/os/amigaos.json diff --git a/test/specs/os/android-x86.json b/test/data/ua/os/android-x86.json similarity index 100% rename from test/specs/os/android-x86.json rename to test/data/ua/os/android-x86.json diff --git a/test/specs/os/android.json b/test/data/ua/os/android.json similarity index 100% rename from test/specs/os/android.json rename to test/data/ua/os/android.json diff --git a/test/specs/os/arch.json b/test/data/ua/os/arch.json similarity index 100% rename from test/specs/os/arch.json rename to test/data/ua/os/arch.json diff --git a/test/specs/os/bada.json b/test/data/ua/os/bada.json similarity index 100% rename from test/specs/os/bada.json rename to test/data/ua/os/bada.json diff --git a/test/specs/os/beos.json b/test/data/ua/os/beos.json similarity index 100% rename from test/specs/os/beos.json rename to test/data/ua/os/beos.json diff --git a/test/specs/os/blackberry.json b/test/data/ua/os/blackberry.json similarity index 100% rename from test/specs/os/blackberry.json rename to test/data/ua/os/blackberry.json diff --git a/test/specs/os/centos.json b/test/data/ua/os/centos.json similarity index 100% rename from test/specs/os/centos.json rename to test/data/ua/os/centos.json diff --git a/test/specs/os/chrome-os.json b/test/data/ua/os/chrome-os.json similarity index 100% rename from test/specs/os/chrome-os.json rename to test/data/ua/os/chrome-os.json diff --git a/test/specs/os/chromecast-android.json b/test/data/ua/os/chromecast-android.json similarity index 100% rename from test/specs/os/chromecast-android.json rename to test/data/ua/os/chromecast-android.json diff --git a/test/specs/os/chromecast-fuchsia.json b/test/data/ua/os/chromecast-fuchsia.json similarity index 100% rename from test/specs/os/chromecast-fuchsia.json rename to test/data/ua/os/chromecast-fuchsia.json diff --git a/test/specs/os/chromecast-linux.json b/test/data/ua/os/chromecast-linux.json similarity index 100% rename from test/specs/os/chromecast-linux.json rename to test/data/ua/os/chromecast-linux.json diff --git a/test/specs/os/chromecast-smartspeaker.json b/test/data/ua/os/chromecast-smartspeaker.json similarity index 100% rename from test/specs/os/chromecast-smartspeaker.json rename to test/data/ua/os/chromecast-smartspeaker.json diff --git a/test/specs/os/contiki.json b/test/data/ua/os/contiki.json similarity index 100% rename from test/specs/os/contiki.json rename to test/data/ua/os/contiki.json diff --git a/test/specs/os/debian.json b/test/data/ua/os/debian.json similarity index 100% rename from test/specs/os/debian.json rename to test/data/ua/os/debian.json diff --git a/test/specs/os/deepin.json b/test/data/ua/os/deepin.json similarity index 100% rename from test/specs/os/deepin.json rename to test/data/ua/os/deepin.json diff --git a/test/specs/os/dragonfly.json b/test/data/ua/os/dragonfly.json similarity index 100% rename from test/specs/os/dragonfly.json rename to test/data/ua/os/dragonfly.json diff --git a/test/specs/os/elementary-os.json b/test/data/ua/os/elementary-os.json similarity index 100% rename from test/specs/os/elementary-os.json rename to test/data/ua/os/elementary-os.json diff --git a/test/specs/os/fedora.json b/test/data/ua/os/fedora.json similarity index 100% rename from test/specs/os/fedora.json rename to test/data/ua/os/fedora.json diff --git a/test/specs/os/firefox-os.json b/test/data/ua/os/firefox-os.json similarity index 100% rename from test/specs/os/firefox-os.json rename to test/data/ua/os/firefox-os.json diff --git a/test/specs/os/freebsd.json b/test/data/ua/os/freebsd.json similarity index 100% rename from test/specs/os/freebsd.json rename to test/data/ua/os/freebsd.json diff --git a/test/specs/os/fuchsia.json b/test/data/ua/os/fuchsia.json similarity index 100% rename from test/specs/os/fuchsia.json rename to test/data/ua/os/fuchsia.json diff --git a/test/specs/os/gentoo.json b/test/data/ua/os/gentoo.json similarity index 100% rename from test/specs/os/gentoo.json rename to test/data/ua/os/gentoo.json diff --git a/test/specs/os/ghostbsd.json b/test/data/ua/os/ghostbsd.json similarity index 100% rename from test/specs/os/ghostbsd.json rename to test/data/ua/os/ghostbsd.json diff --git a/test/specs/os/haiku.json b/test/data/ua/os/haiku.json similarity index 100% rename from test/specs/os/haiku.json rename to test/data/ua/os/haiku.json diff --git a/test/specs/os/harmonyos.json b/test/data/ua/os/harmonyos.json similarity index 100% rename from test/specs/os/harmonyos.json rename to test/data/ua/os/harmonyos.json diff --git a/test/specs/os/hp-ux.json b/test/data/ua/os/hp-ux.json similarity index 100% rename from test/specs/os/hp-ux.json rename to test/data/ua/os/hp-ux.json diff --git a/test/specs/os/hurd.json b/test/data/ua/os/hurd.json similarity index 100% rename from test/specs/os/hurd.json rename to test/data/ua/os/hurd.json diff --git a/test/specs/os/ios.json b/test/data/ua/os/ios.json similarity index 100% rename from test/specs/os/ios.json rename to test/data/ua/os/ios.json diff --git a/test/specs/os/joli.json b/test/data/ua/os/joli.json similarity index 100% rename from test/specs/os/joli.json rename to test/data/ua/os/joli.json diff --git a/test/specs/os/kaios.json b/test/data/ua/os/kaios.json similarity index 100% rename from test/specs/os/kaios.json rename to test/data/ua/os/kaios.json diff --git a/test/specs/os/kubuntu.json b/test/data/ua/os/kubuntu.json similarity index 100% rename from test/specs/os/kubuntu.json rename to test/data/ua/os/kubuntu.json diff --git a/test/specs/os/linpus.json b/test/data/ua/os/linpus.json similarity index 100% rename from test/specs/os/linpus.json rename to test/data/ua/os/linpus.json diff --git a/test/specs/os/linspire.json b/test/data/ua/os/linspire.json similarity index 100% rename from test/specs/os/linspire.json rename to test/data/ua/os/linspire.json diff --git a/test/specs/os/linux.json b/test/data/ua/os/linux.json similarity index 100% rename from test/specs/os/linux.json rename to test/data/ua/os/linux.json diff --git a/test/specs/os/macos.json b/test/data/ua/os/macos.json similarity index 100% rename from test/specs/os/macos.json rename to test/data/ua/os/macos.json diff --git a/test/specs/os/maemo.json b/test/data/ua/os/maemo.json similarity index 100% rename from test/specs/os/maemo.json rename to test/data/ua/os/maemo.json diff --git a/test/specs/os/mandriva.json b/test/data/ua/os/mandriva.json similarity index 100% rename from test/specs/os/mandriva.json rename to test/data/ua/os/mandriva.json diff --git a/test/specs/os/manjaro.json b/test/data/ua/os/manjaro.json similarity index 100% rename from test/specs/os/manjaro.json rename to test/data/ua/os/manjaro.json diff --git a/test/specs/os/meego.json b/test/data/ua/os/meego.json similarity index 100% rename from test/specs/os/meego.json rename to test/data/ua/os/meego.json diff --git a/test/specs/os/minix.json b/test/data/ua/os/minix.json similarity index 100% rename from test/specs/os/minix.json rename to test/data/ua/os/minix.json diff --git a/test/specs/os/mint.json b/test/data/ua/os/mint.json similarity index 100% rename from test/specs/os/mint.json rename to test/data/ua/os/mint.json diff --git a/test/specs/os/morphos.json b/test/data/ua/os/morphos.json similarity index 100% rename from test/specs/os/morphos.json rename to test/data/ua/os/morphos.json diff --git a/test/specs/os/netbsd.json b/test/data/ua/os/netbsd.json similarity index 100% rename from test/specs/os/netbsd.json rename to test/data/ua/os/netbsd.json diff --git a/test/specs/os/netrange.json b/test/data/ua/os/netrange.json similarity index 100% rename from test/specs/os/netrange.json rename to test/data/ua/os/netrange.json diff --git a/test/specs/os/nettv.json b/test/data/ua/os/nettv.json similarity index 100% rename from test/specs/os/nettv.json rename to test/data/ua/os/nettv.json diff --git a/test/specs/os/nintendo.json b/test/data/ua/os/nintendo.json similarity index 100% rename from test/specs/os/nintendo.json rename to test/data/ua/os/nintendo.json diff --git a/test/specs/os/openbsd.json b/test/data/ua/os/openbsd.json similarity index 100% rename from test/specs/os/openbsd.json rename to test/data/ua/os/openbsd.json diff --git a/test/specs/os/openharmony.json b/test/data/ua/os/openharmony.json similarity index 100% rename from test/specs/os/openharmony.json rename to test/data/ua/os/openharmony.json diff --git a/test/specs/os/os2.json b/test/data/ua/os/os2.json similarity index 100% rename from test/specs/os/os2.json rename to test/data/ua/os/os2.json diff --git a/test/specs/os/palm.json b/test/data/ua/os/palm.json similarity index 100% rename from test/specs/os/palm.json rename to test/data/ua/os/palm.json diff --git a/test/specs/os/pclinuxos.json b/test/data/ua/os/pclinuxos.json similarity index 100% rename from test/specs/os/pclinuxos.json rename to test/data/ua/os/pclinuxos.json diff --git a/test/specs/os/pico.json b/test/data/ua/os/pico.json similarity index 100% rename from test/specs/os/pico.json rename to test/data/ua/os/pico.json diff --git a/test/specs/os/plan9.json b/test/data/ua/os/plan9.json similarity index 100% rename from test/specs/os/plan9.json rename to test/data/ua/os/plan9.json diff --git a/test/specs/os/playstation.json b/test/data/ua/os/playstation.json similarity index 100% rename from test/specs/os/playstation.json rename to test/data/ua/os/playstation.json diff --git a/test/specs/os/qnx.json b/test/data/ua/os/qnx.json similarity index 100% rename from test/specs/os/qnx.json rename to test/data/ua/os/qnx.json diff --git a/test/specs/os/raspbian.json b/test/data/ua/os/raspbian.json similarity index 100% rename from test/specs/os/raspbian.json rename to test/data/ua/os/raspbian.json diff --git a/test/specs/os/redhat.json b/test/data/ua/os/redhat.json similarity index 100% rename from test/specs/os/redhat.json rename to test/data/ua/os/redhat.json diff --git a/test/specs/os/rim-tablet-os.json b/test/data/ua/os/rim-tablet-os.json similarity index 100% rename from test/specs/os/rim-tablet-os.json rename to test/data/ua/os/rim-tablet-os.json diff --git a/test/specs/os/risc-os.json b/test/data/ua/os/risc-os.json similarity index 100% rename from test/specs/os/risc-os.json rename to test/data/ua/os/risc-os.json diff --git a/test/specs/os/sabayon.json b/test/data/ua/os/sabayon.json similarity index 100% rename from test/specs/os/sabayon.json rename to test/data/ua/os/sabayon.json diff --git a/test/specs/os/sailfish.json b/test/data/ua/os/sailfish.json similarity index 100% rename from test/specs/os/sailfish.json rename to test/data/ua/os/sailfish.json diff --git a/test/specs/os/serenityos.json b/test/data/ua/os/serenityos.json similarity index 100% rename from test/specs/os/serenityos.json rename to test/data/ua/os/serenityos.json diff --git a/test/specs/os/series40.json b/test/data/ua/os/series40.json similarity index 100% rename from test/specs/os/series40.json rename to test/data/ua/os/series40.json diff --git a/test/specs/os/slackware.json b/test/data/ua/os/slackware.json similarity index 100% rename from test/specs/os/slackware.json rename to test/data/ua/os/slackware.json diff --git a/test/specs/os/solaris.json b/test/data/ua/os/solaris.json similarity index 100% rename from test/specs/os/solaris.json rename to test/data/ua/os/solaris.json diff --git a/test/specs/os/suse.json b/test/data/ua/os/suse.json similarity index 100% rename from test/specs/os/suse.json rename to test/data/ua/os/suse.json diff --git a/test/specs/os/symbian.json b/test/data/ua/os/symbian.json similarity index 100% rename from test/specs/os/symbian.json rename to test/data/ua/os/symbian.json diff --git a/test/specs/os/tizen.json b/test/data/ua/os/tizen.json similarity index 100% rename from test/specs/os/tizen.json rename to test/data/ua/os/tizen.json diff --git a/test/specs/os/ubuntu.json b/test/data/ua/os/ubuntu.json similarity index 100% rename from test/specs/os/ubuntu.json rename to test/data/ua/os/ubuntu.json diff --git a/test/specs/os/unix.json b/test/data/ua/os/unix.json similarity index 100% rename from test/specs/os/unix.json rename to test/data/ua/os/unix.json diff --git a/test/specs/os/watchos.json b/test/data/ua/os/watchos.json similarity index 100% rename from test/specs/os/watchos.json rename to test/data/ua/os/watchos.json diff --git a/test/specs/os/webos.json b/test/data/ua/os/webos.json similarity index 100% rename from test/specs/os/webos.json rename to test/data/ua/os/webos.json diff --git a/test/specs/os/windows-mobile.json b/test/data/ua/os/windows-mobile.json similarity index 100% rename from test/specs/os/windows-mobile.json rename to test/data/ua/os/windows-mobile.json diff --git a/test/specs/os/windows-phone.json b/test/data/ua/os/windows-phone.json similarity index 100% rename from test/specs/os/windows-phone.json rename to test/data/ua/os/windows-phone.json diff --git a/test/specs/os/windows.json b/test/data/ua/os/windows.json similarity index 100% rename from test/specs/os/windows.json rename to test/data/ua/os/windows.json diff --git a/test/specs/os/xbox.json b/test/data/ua/os/xbox.json similarity index 100% rename from test/specs/os/xbox.json rename to test/data/ua/os/xbox.json diff --git a/test/specs/os/zenwalk.json b/test/data/ua/os/zenwalk.json similarity index 100% rename from test/specs/os/zenwalk.json rename to test/data/ua/os/zenwalk.json diff --git a/test/playwright-test-main.spec.mjs b/test/e2e/browser.spec.mjs similarity index 97% rename from test/playwright-test-main.spec.mjs rename to test/e2e/browser.spec.mjs index db6e149..97431b6 100644 --- a/test/playwright-test-main.spec.mjs +++ b/test/e2e/browser.spec.mjs @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; import path from 'path'; import url from 'url'; -const localHtml = `file://${path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '../')}/dist/ua-parser.html`; +const localHtml = `file://${path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '../../')}/dist/ua-parser.html`; test.describe('Custom navigator.userAgent tests', () => { @@ -83,7 +83,7 @@ test.describe('withClientHints() tests', () => { test.describe('withFeatureCheck() tests', () => { - test('Detect Brave', async ({ page }) => { + test('Detect Brave', async ({ page, browserName }) => { await page.addInitScript(() => { Object.defineProperty(navigator, 'brave', { value: { @@ -94,7 +94,12 @@ test.describe('withFeatureCheck() tests', () => { await page.goto(localHtml); // @ts-ignore let uap = await page.evaluate(() => UAParser()); - expect(uap).toHaveProperty('browser.name', 'Chrome Headless'); + const browserMap = { + chromium: 'Chrome Headless', + firefox: 'Firefox', + webkit: 'Safari' + } + expect(uap).toHaveProperty('browser.name', browserMap[browserName]); // @ts-ignore uap = await page.evaluate(() => UAParser().withFeatureCheck()); expect(uap).toHaveProperty('browser.name', 'Brave'); diff --git a/test/jazzer-fuzz-test.js b/test/fuzz/redos.js similarity index 87% rename from test/jazzer-fuzz-test.js rename to test/fuzz/redos.js index 8d87049..b046862 100644 --- a/test/jazzer-fuzz-test.js +++ b/test/fuzz/redos.js @@ -1,6 +1,6 @@ const { FuzzedDataProvider } = require('@jazzer.js/core'); -const { UAParser } = require('../src/main/ua-parser'); -const UA_MAX_LENGTH = 350; +const { UAParser } = require('../../dist/main'); +const UA_MAX_LENGTH = 500; module.exports.fuzz = function (buffer) { const data = new FuzzedDataProvider(buffer); diff --git a/test/dts-test.ts b/test/static/dts-lint.ts similarity index 91% rename from test/dts-test.ts rename to test/static/dts-lint.ts index 39bb4a3..bcfc262 100644 --- a/test/dts-test.ts +++ b/test/static/dts-lint.ts @@ -1,6 +1,6 @@ import { expectType } from 'tsd'; -import { UAParser, IResult, IBrowser, ICPU, IEngine, IDevice, IOS } from "../src/main/ua-parser"; -import { isAppleSilicon, isChromeFamily } from "../src/helpers/ua-parser-helpers"; +import { UAParser, IResult, IBrowser, ICPU, IEngine, IDevice, IOS } from "../../src/main/ua-parser"; +import { isAppleSilicon, isChromeFamily } from "../../src/helpers/ua-parser-helpers"; const uastring = 'Mozilla/5.0 (X11; MyCustomOS; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0'; const extensions = { diff --git a/test/mocha-test-es6.mjs b/test/unit/es6.mjs similarity index 88% rename from test/mocha-test-es6.mjs rename to test/unit/es6.mjs index 69a334e..8e26908 100644 --- a/test/mocha-test-es6.mjs +++ b/test/unit/es6.mjs @@ -1,5 +1,5 @@ -import { UAParser } from '../src/main/ua-parser.mjs'; -import { CPU, Device, Engine } from '../src/enums/ua-parser-enums.mjs'; +import { UAParser } from '../../src/main/ua-parser.mjs'; +import { CPU, Device, Engine } from '../../src/enums/ua-parser-enums.mjs'; import * as assert from 'assert'; describe('Returns', () => { diff --git a/test/mocha-test-extension.js b/test/unit/extensions.js similarity index 91% rename from test/mocha-test-extension.js rename to test/unit/extensions.js index c32c1b8..6fd755b 100644 --- a/test/mocha-test-extension.js +++ b/test/unit/extensions.js @@ -3,13 +3,13 @@ const assert = require('assert'); const parseJS = require('@babel/parser').parse; const traverse = require('@babel/traverse').default; const safe = require('safe-regex'); -const { UAParser } = require('../src/main/ua-parser'); -const clis = require('./specs/extension/cli.json'); -const crawlers = require('./specs/extension/crawler.json'); -const emails = require('./specs/extension/email.json'); -const fetchers = require('./specs/extension/fetcher.json'); -const libraries = require('./specs/extension/library.json'); -const { Bots, CLIs, Crawlers, Emails, Fetchers, Libraries } = require('../src/extensions/ua-parser-extensions'); +const { UAParser } = require('../../src/main/ua-parser'); +const clis = require('../data/ua/extension/cli.json'); +const crawlers = require('../data/ua/extension/crawler.json'); +const emails = require('../data/ua/extension/email.json'); +const fetchers = require('../data/ua/extension/fetcher.json'); +const libraries = require('../data/ua/extension/library.json'); +const { Bots, CLIs, Crawlers, Emails, Fetchers, Libraries } = require('../../src/extensions/ua-parser-extensions'); describe('Extensions', () => { [ diff --git a/test/mocha-test-helpers.js b/test/unit/helpers.js similarity index 94% rename from test/mocha-test-helpers.js rename to test/unit/helpers.js index d6170bc..fcd6678 100644 --- a/test/mocha-test-helpers.js +++ b/test/unit/helpers.js @@ -1,7 +1,7 @@ const assert = require('assert'); -const { UAParser } = require('../src/main/ua-parser'); -const { getDeviceVendor, isAppleSilicon, isAIBot, isBot, isChromeFamily } = require('../src/helpers/ua-parser-helpers'); -const { Bots, Emails } = require('../src/extensions/ua-parser-extensions'); +const { UAParser } = require('../../src/main/ua-parser'); +const { getDeviceVendor, isAppleSilicon, isAIBot, isBot, isChromeFamily } = require('../../src/helpers/ua-parser-helpers'); +const { Bots, Emails } = require('../../src/extensions/ua-parser-extensions'); describe('getDeviceVendor', () => { it('Can guess the device vendor from a model name', () => { diff --git a/test/mocha-test.js b/test/unit/main.js similarity index 98% rename from test/mocha-test.js rename to test/unit/main.js index 9c50a82..0433882 100644 --- a/test/mocha-test.js +++ b/test/unit/main.js @@ -4,12 +4,12 @@ var assert = require('assert'); var requirejs = require('requirejs'); var parseJS = require('@babel/parser').parse; var traverse = require('@babel/traverse').default; -var {UAParser} = require('../src/main/ua-parser'); -var browsers = require('./specs/browser/browser-all.json'); -var cpus = require('./specs/cpu/cpu-all.json'); -var devices = readJsonFiles('test/specs/device'); -var engines = require('./specs/engine/engine-all.json'); -var os = readJsonFiles('test/specs/os'); +var {UAParser} = require('../../src/main/ua-parser'); +var browsers = require('../data/ua/browser/browser-all.json'); +var cpus = require('../data/ua/cpu/cpu-all.json'); +var devices = readJsonFiles('test/data/ua/device'); +var engines = require('../data/ua/engine/engine-all.json'); +var os = readJsonFiles('test/data/ua/os'); var { Headers } = require('node-fetch'); function readJsonFiles(dir) {