@polymer/polymer
Version:
The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to
87 lines (72 loc) • 3.34 kB
HTML
<!--
@license
Copyright (c) 2017 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>