Gitako/tests/lib/util/update-query-string.js
EnixCoda 18ce99c8f6 Squashed 'packages/pjax/' content from commit 8abb21e
git-subtree-dir: packages/pjax
git-subtree-split: 8abb21e1e9d899217b03c489c9b2d9ecd92074b5
2018-06-05 23:48:45 +08:00

21 lines
769 B
JavaScript

var tape = require("tape")
var updateQueryString = require("../../../lib/util/update-query-string")
tape("test update query string method", function(t) {
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()
})