|
| 1 | +<!doctype html> |
| 2 | +<!-- |
| 3 | +@license |
| 4 | +Copyright (c) 2014 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 | + <meta charset="utf-8"> |
| 14 | + <script src="../../../webcomponentsjs/webcomponents-lite.js"></script> |
| 15 | + <script src="../../../web-component-tester/browser.js"></script> |
| 16 | + <link rel="import" href="../../src/polymer-lib.html"> |
| 17 | + <link rel="import" href="../../src/lib/case-map.html"> |
| 18 | +</head> |
| 19 | +<body> |
| 20 | + |
| 21 | +<script> |
| 22 | + suite('case-map', function() { |
| 23 | + var caseMap; |
| 24 | + |
| 25 | + setup(function() { |
| 26 | + caseMap = Polymer.CaseMap; |
| 27 | + }); |
| 28 | + |
| 29 | + test('camelToDashCase converts to dashes', function() { |
| 30 | + assert.equal(caseMap.camelToDashCase('camelCase'), 'camel-case'); |
| 31 | + assert.equal(caseMap.camelToDashCase('camelCCase'), 'camel-c-case'); |
| 32 | + }); |
| 33 | + |
| 34 | + test('camelToDashCase caches conversions', function() { |
| 35 | + caseMap._caseMap['camelCase'] = 'some-other-camel-case'; |
| 36 | + assert.equal(caseMap.camelToDashCase('camelCase'), 'some-other-camel-case'); |
| 37 | + |
| 38 | + var result = caseMap.camelToDashCase('camelCCase'); |
| 39 | + assert.equal(Polymer.CaseMap._caseMap['camelCCase'], result); |
| 40 | + }); |
| 41 | + |
| 42 | + test('dashToCamelCase converts to camelCase', function() { |
| 43 | + assert.equal(caseMap.dashToCamelCase('camel-case'), 'camelCase'); |
| 44 | + assert.equal(caseMap.dashToCamelCase('camel-c-case'), 'camelCCase'); |
| 45 | + }); |
| 46 | + |
| 47 | + test('dashToCamelCase caches conversions', function() { |
| 48 | + caseMap._caseMap['camel-case'] = 'someOtherCamelCase'; |
| 49 | + assert.equal(caseMap.dashToCamelCase('camel-case'), 'someOtherCamelCase'); |
| 50 | + |
| 51 | + var result = caseMap.dashToCamelCase('camel-c-case'); |
| 52 | + assert.equal(Polymer.CaseMap._caseMap['camel-c-case'], result); |
| 53 | + }); |
| 54 | + |
| 55 | + test('camelToDashCase and dashToCamelCase reverse the other function', function() { |
| 56 | + var camelCase = caseMap.dashToCamelCase('camel-c-case'); |
| 57 | + assert.equal(caseMap.camelToDashCase(camelCase), 'camel-c-case'); |
| 58 | + }); |
| 59 | + }); |
| 60 | +</script> |
0 commit comments