aboutsummaryrefslogtreecommitdiff
path: root/catapult/third_party/polymer/components/app-route/test/app-route-converter.html
blob: b5b8c559a691e7855a68a65b04c03b26356efbf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!doctype html>
<!--
@license
Copyright (c) 2016 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>app-route-converter</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="../app-route-converter.html">
</head>
<body>
  <test-fixture id="BasicRouteConversion">
    <template>
      <app-route-converter>
      </app-route-converter>
    </template>
  </test-fixture>

  <script>
    'use strict';

    suite('<app-route-converter>', function() {
      test('it bidirectionally maps path and queryParams to route', function() {
        var converter = fixture('BasicRouteConversion');

        var queryParams = {x: '10'};
        converter.path = '/a/b/c';
        converter.queryParams = queryParams;

        expect(converter.route).to.be.deep.equal({
          prefix: '',
          path: '/a/b/c',
          __queryParams: queryParams
        });

        converter.set('route.path', '/d/e/f');
        expect(converter.path).to.be.equal('/d/e/f');

        queryParams = {y: '11'};
        converter.set('route.__queryParams', queryParams);
        expect(converter.queryParams).to.be.deep.equal(queryParams);

        queryParams['z'] = '12';
        expect(converter.queryParams).to.be.deep.equal(queryParams);
      });
    });
  </script>
</body>