Files
pjax/tests/lib/util/update-query-string.js

34 lines
829 B
JavaScript
Raw Permalink Normal View History

2019-03-03 01:37:45 -05:00
var tape = require("tape");
2018-03-04 15:12:53 +00:00
2019-03-03 01:37:45 -05:00
var updateQueryString = require("../../../lib/util/update-query-string");
2018-03-04 15:12:53 +00:00
tape("test update query string method", function(t) {
2019-03-03 01:37:45 -05:00
var url = "http://example.com";
var updatedUrl = updateQueryString(url, "foo", "bar");
t.notEqual(url, updatedUrl, "update query string modifies URL");
t.equal(
updatedUrl,
url + "?foo=bar",
"update query string creates new query string when no query string params are set"
);
updatedUrl = updateQueryString(updatedUrl, "foo", "baz");
t.equal(
updatedUrl,
url + "?foo=baz",
"update query string updates existing query string param"
);
updatedUrl = updateQueryString(updatedUrl, "bar", "");
t.equal(
updatedUrl,
url + "?foo=baz&bar=",
"update query string appends to existing query string"
);
t.end();
});