aboutsummaryrefslogtreecommitdiff
path: root/catapult/third_party/polymer/components/iron-location/test/iron-query-params.html
diff options
context:
space:
mode:
Diffstat (limited to 'catapult/third_party/polymer/components/iron-location/test/iron-query-params.html')
-rw-r--r--catapult/third_party/polymer/components/iron-location/test/iron-query-params.html102
1 files changed, 102 insertions, 0 deletions
diff --git a/catapult/third_party/polymer/components/iron-location/test/iron-query-params.html b/catapult/third_party/polymer/components/iron-location/test/iron-query-params.html
new file mode 100644
index 00000000..8b276427
--- /dev/null
+++ b/catapult/third_party/polymer/components/iron-location/test/iron-query-params.html
@@ -0,0 +1,102 @@
+<!doctype html>
+<!--
+@license
+Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+-->
+<html>
+<head>
+ <title>iron-location</title>
+
+ <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
+ <script src="../../web-component-tester/browser.js"></script>
+
+ <link rel="import" href="../../polymer/polymer.html">
+ <link rel="import" href="../../promise-polyfill/promise-polyfill.html">
+ <link rel="import" href="../iron-query-params.html">
+</head>
+<body>
+
+ <test-fixture id="BasicQueryParams">
+ <template>
+ <iron-query-params></iron-query-params>
+ </template>
+ </test-fixture>
+
+ <script>
+ 'use strict';
+
+ suite('<iron-query-params>', function () {
+
+ var paramsElem;
+ setup(function() {
+ paramsElem = fixture('BasicQueryParams');
+ });
+
+ test('basic functionality with ?key=value params', function() {
+ // Check initialization
+ expect(paramsElem.paramsString).to.be.eq('');
+ expect(paramsElem.paramsObject).to.deep.eq({});
+
+ // Check the mapping from paramsString to paramsObject.
+ paramsElem.paramsString = 'greeting=hello&target=world';
+ expect(paramsElem.paramsObject).to.deep.equal(
+ {greeting: 'hello', target: 'world'});
+
+ // Check the mapping from paramsObject back to paramsString.
+ paramsElem.set('paramsObject.another', 'key');
+ expect(paramsElem.paramsString).to.be.equal(
+ 'greeting=hello&target=world&another=key');
+ });
+ test('encoding of params', function() {
+ var mappings = [
+ {
+ string: 'a=b',
+ object: {'a': 'b'}
+ },
+ {
+ string: 'debug&ok',
+ object: {'debug': '', 'ok': ''}
+ },
+ {
+ string: 'monster%20kid%3A=%F0%9F%98%BF&quotes=%27%27',
+ object: {'monster kid:': '😿', 'quotes': '\'\''}
+ },
+ {
+ string: 'yes%2C%20ok?%20what%20is%20up%20with%20%CB%9Athiiis%CB%9A=%E2%98%83',
+ object: {'yes, ok? what is up with ˚thiiis˚': '☃'}
+ },
+ ];
+
+ mappings.forEach(function(mapping) {
+ // Clear
+ paramsElem.paramsObject = {};
+ expect(paramsElem.paramsString).to.be.equal('');
+
+ // Test going from string to object
+ paramsElem.paramsString = mapping.string;
+ expect(paramsElem.paramsObject).to.deep.equal(mapping.object);
+
+ // Clear again.
+ paramsElem.paramsObject = {};
+ expect(paramsElem.paramsString).to.be.equal('');
+
+ // Test going from object to string
+ paramsElem.paramsObject = mapping.object;
+ expect(paramsElem.paramsString).to.be.equal(mapping.string);
+ });
+ });
+ test('query strings with alternative encodings', function() {
+ // Check the mapping for querystrings with + instead of %20.
+ paramsElem.paramsString = 'key=value+with+spaces';
+ expect(paramsElem.paramsObject).to.deep.equal(
+ {key: 'value with spaces'});
+ });
+ });
+
+ </script>
+</body>