4
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
5
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
Code distributed by Google as part of the polymer project is also
9
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
13
<title>iron-location</title>
15
<script src="../../webcomponentsjs/webcomponents.js"></script>
16
<script src="../../web-component-tester/browser.js"></script>
18
<link rel="import" href="../../polymer/polymer.html">
19
<link rel="import" href="../../promise-polyfill/promise-polyfill.html">
20
<link rel="import" href="../iron-query-params.html">
24
<test-fixture id="BasicQueryParams">
26
<iron-query-params></iron-query-params>
33
suite('<iron-query-params>', function () {
37
paramsElem = fixture('BasicQueryParams');
40
test('basic functionality with ?key=value params', function() {
41
// Check initialization
42
expect(paramsElem.paramsString).to.be.eq('');
43
expect(paramsElem.paramsObject).to.deep.eq({});
45
// Check the mapping from paramsString to paramsObject.
46
paramsElem.paramsString = 'greeting=hello&target=world';
47
expect(paramsElem.paramsObject).to.deep.equal(
48
{greeting: 'hello', target: 'world'});
50
// Check the mapping from paramsObject back to paramsString.
51
paramsElem.set('paramsObject.another', 'key');
52
expect(paramsElem.paramsString).to.be.equal(
53
'greeting=hello&target=world&another=key');
55
test('encoding of params', function() {
63
object: {'debug': '', 'ok': ''}
66
string: 'monster%20kid%3A=%F0%9F%98%BF',
67
object: {'monster kid:': '😿'}
70
string: 'yes%2C%20ok%3F%20what%20is%20up%20with%20%CB%9Athiiis%CB%9A=%E2%98%83',
71
object: {'yes, ok? what is up with ˚thiiis˚': '☃'}
75
mappings.forEach(function(mapping) {
77
paramsElem.paramsObject = {};
78
expect(paramsElem.paramsString).to.be.equal('');
80
// Test going from string to object
81
paramsElem.paramsString = mapping.string;
82
expect(paramsElem.paramsObject).to.deep.equal(mapping.object);
85
paramsElem.paramsObject = {};
86
expect(paramsElem.paramsString).to.be.equal('');
88
// Test going from object to string
89
paramsElem.paramsObject = mapping.object;
90
expect(paramsElem.paramsString).to.be.equal(mapping.string);