Skip to content

Commit

Permalink
Add unit test suite for CaseMap
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Feb 5, 2016
1 parent 9968266 commit ee9a600
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/unit/case-map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<!doctype html>
<!--
@license
Copyright (c) 2014 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>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../src/polymer-lib.html">
<link rel="import" href="../../src/lib/case-map.html">
</head>
<body>

<script>
suite('case-map', function() {
var caseMap;

setup(function() {
caseMap = Polymer.CaseMap;
});

test('camelToDashCase converts to dashes', function() {
assert.equal(caseMap.camelToDashCase('camelCase'), 'camel-case');
assert.equal(caseMap.camelToDashCase('camelCCase'), 'camel-c-case');
});

test('camelToDashCase caches conversions', function() {
caseMap._caseMap['camelCase'] = 'some-other-camel-case';
assert.equal(caseMap.camelToDashCase('camelCase'), 'some-other-camel-case');

var result = caseMap.camelToDashCase('camelCCase');
assert.equal(Polymer.CaseMap._caseMap['camelCCase'], result);
});

test('dashToCamelCase converts to camelCase', function() {
assert.equal(caseMap.dashToCamelCase('camel-case'), 'camelCase');
assert.equal(caseMap.dashToCamelCase('camel-c-case'), 'camelCCase');
});

test('dashToCamelCase caches conversions', function() {
caseMap._caseMap['camel-case'] = 'someOtherCamelCase';
assert.equal(caseMap.dashToCamelCase('camel-case'), 'someOtherCamelCase');

var result = caseMap.dashToCamelCase('camel-c-case');
assert.equal(Polymer.CaseMap._caseMap['camel-c-case'], result);
});

test('camelToDashCase and dashToCamelCase reverse the other function', function() {
var camelCase = caseMap.dashToCamelCase('camel-c-case');
assert.equal(caseMap.camelToDashCase(camelCase), 'camel-c-case');
});
});
</script>

0 comments on commit ee9a600

Please sign in to comment.