mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
90 lines
3.3 KiB
HTML
90 lines
3.3 KiB
HTML
<!doctype 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="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js"></script>
|
|
<script src="wct-browser-config.js"></script>
|
|
<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
|
|
<script type="module" src="../../lib/utils/path.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<script type="module">
|
|
import * as path from '../../lib/utils/path.js';
|
|
import { isDeep } from '../../lib/utils/path.js';
|
|
suite('path utilities', function() {
|
|
|
|
var Path;
|
|
|
|
setup(function() {
|
|
Path = path;
|
|
});
|
|
|
|
test('root()', function() {
|
|
assert.equal(Path.root('foo'), 'foo');
|
|
assert.equal(Path.root('foo.bar'), 'foo');
|
|
});
|
|
|
|
test('isDeep()', function() {
|
|
assert.equal(isDeep('foo'), false);
|
|
assert.equal(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>
|