From d5395c3d07acf94d6ca10f3d2ab6d89867e96889 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Mon, 5 May 2014 08:36:12 +0200 Subject: [PATCH] Test isSupported kind of stupid, but I don't want to maintain a list of browser UA or whatever. --- src/scripts/lib/is-supported.js | 8 ++++++++ tests/scripts/lib/is-supported.js | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/scripts/lib/is-supported.js create mode 100644 tests/scripts/lib/is-supported.js diff --git a/src/scripts/lib/is-supported.js b/src/scripts/lib/is-supported.js new file mode 100644 index 0000000..825a3c7 --- /dev/null +++ b/src/scripts/lib/is-supported.js @@ -0,0 +1,8 @@ +module.exports = function() { + // Borrowed wholesale from https://github.com/defunkt/jquery-pjax + return window.history && + window.history.pushState && + window.history.replaceState && + // pushState isn’t reliable on iOS until 5. + !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/) +} diff --git a/tests/scripts/lib/is-supported.js b/tests/scripts/lib/is-supported.js new file mode 100644 index 0000000..7ca141b --- /dev/null +++ b/tests/scripts/lib/is-supported.js @@ -0,0 +1,8 @@ +var tape = require("tape") + +var isSupported = require("../../../src/scripts/lib/is-supported.js") + +tape("test isSupported method", function(t) { + t.true(isSupported(), "well, we run test on supported browser, so it should be ok here") + t.end() +})