~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-location/test/iron-query-params.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!doctype html>
 
2
<!--
 
3
@license
 
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
 
10
-->
 
11
<html>
 
12
<head>
 
13
  <title>iron-location</title>
 
14
 
 
15
  <script src="../../webcomponentsjs/webcomponents.js"></script>
 
16
  <script src="../../web-component-tester/browser.js"></script>
 
17
 
 
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">
 
21
</head>
 
22
<body>
 
23
 
 
24
  <test-fixture id="BasicQueryParams">
 
25
    <template>
 
26
      <iron-query-params></iron-query-params>
 
27
    </template>
 
28
  </test-fixture>
 
29
 
 
30
  <script>
 
31
    'use strict';
 
32
 
 
33
    suite('<iron-query-params>', function () {
 
34
 
 
35
      var paramsElem;
 
36
      setup(function() {
 
37
        paramsElem = fixture('BasicQueryParams');
 
38
      });
 
39
 
 
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({});
 
44
 
 
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'});
 
49
 
 
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');
 
54
      });
 
55
      test('encoding of params', function() {
 
56
        var mappings = [
 
57
          {
 
58
            string: 'a=b',
 
59
            object: {'a': 'b'}
 
60
          },
 
61
          {
 
62
            string: 'debug&ok',
 
63
            object: {'debug': '', 'ok': ''}
 
64
          },
 
65
          {
 
66
            string: 'monster%20kid%3A=%F0%9F%98%BF',
 
67
            object: {'monster kid:': '😿'}
 
68
          },
 
69
          {
 
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˚': '☃'}
 
72
          },
 
73
        ];
 
74
 
 
75
        mappings.forEach(function(mapping) {
 
76
          // Clear
 
77
          paramsElem.paramsObject = {};
 
78
          expect(paramsElem.paramsString).to.be.equal('');
 
79
 
 
80
          // Test going from string to object
 
81
          paramsElem.paramsString = mapping.string;
 
82
          expect(paramsElem.paramsObject).to.deep.equal(mapping.object);
 
83
 
 
84
          // Clear again.
 
85
          paramsElem.paramsObject = {};
 
86
          expect(paramsElem.paramsString).to.be.equal('');
 
87
 
 
88
          // Test going from object to string
 
89
          paramsElem.paramsObject = mapping.object;
 
90
          expect(paramsElem.paramsString).to.be.equal(mapping.string);
 
91
        });
 
92
      });
 
93
    });
 
94
 
 
95
  </script>
 
96
</body>