Files
polymer/test/unit/path.html
Daniel Freedman 155e3ffc4e move src -> lib
2017-02-28 10:37:04 -08:00

87 lines
3.3 KiB
HTML

<!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="../../lib/utils/path.html">
</head>
<body>
<script>
suite('path utilities', function() {
var Path;
setup(function() {
Path = Polymer.Path;
});
test('root()', function() {
assert.equal(Path.root('foo'), 'foo');
assert.equal(Path.root('foo.bar'), 'foo');
});
test('isDeep()', function() {
assert.equal(Path.isDeep('foo'), false);
assert.equal(Path.isDeep('foo.bar'), true);
});
test('isAncestor()', function() {
assert.equal(Path.isAncestor('foo.bar', 'foo'), true);
assert.equal(Path.isAncestor('foo.bar', 'foo.bar'), false);
assert.equal(Path.isAncestor('foo.bar', 'foo.baz'), false);
assert.equal(Path.isAncestor('foo.bar', 'fooz'), false);
assert.equal(Path.isAncestor('foo.bar', 'bar'), false);
assert.equal(Path.isAncestor('foo.bar', 'foo.bars'), false);
assert.equal(Path.isAncestor('foo.bar', 'foo.bar.quux'), false);
assert.equal(Path.isAncestor('foo.bar.baz', 'foo'), true);
assert.equal(Path.isAncestor('foo.bar.baz', 'foo.bar'), true);
assert.equal(Path.isAncestor('foo.bar.baz', 'foo.baz'), false);
assert.equal(Path.isAncestor('foo.bar.baz', 'foo.bars'), false);
});
test('isDescendant()', function() {
assert.equal(Path.isDescendant('foo.bar', 'foo.bar.baz'), true);
assert.equal(Path.isDescendant('foo.bar', 'foo.bar'), false);
assert.equal(Path.isDescendant('foo.bar', 'foo.bars'), false);
assert.equal(Path.isDescendant('foo.bar', 'foo'), false);
assert.equal(Path.isDescendant('foo.bar', 'bar'), false);
assert.equal(Path.isDescendant('foo', 'foo.bar'), true);
assert.equal(Path.isDescendant('foo', 'foo'), false);
});
test('translate()', function() {
assert.equal(Path.translate('foo', 'baz', 'foo.bar'),
'baz.bar');
assert.equal(Path.translate('foo', 'quux', 'foo.bar.baz'),
'quux.bar.baz');
assert.equal(Path.translate('foo.bar', 'quux', 'foo.bar.baz'),
'quux.baz');
});
test('matches()', function() {
assert.equal(Path.matches('foo.bar','foo'), true);
assert.equal(Path.matches('foo.bar','foo.bar'), true);
assert.equal(Path.matches('foo.bar','foo.bar.baz'), true);
assert.equal(Path.matches('foo.bar','fooz'), false);
assert.equal(Path.matches('foo.bar','foo.baz'), false);
assert.equal(Path.matches('foo.bar','foo.bars'), false);
});
});
</script>