mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
e1d75fd9c2
commit
aaeb444675
22 changed files with 253 additions and 90 deletions
|
@ -18,6 +18,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
<link rel="import" href="../../polymer/polymer.html">
|
||||
<link rel="import" href="../../promise-polyfill/promise-polyfill.html">
|
||||
<link rel="import" href="../iron-location.html">
|
||||
<link rel="import" href="./redirection.html">
|
||||
</head>
|
||||
<body>
|
||||
<test-fixture id='Solo'>
|
||||
|
@ -33,7 +34,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
</div>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id='RedirectHash'>
|
||||
<template>
|
||||
<redirect-hash></redirect-hash>
|
||||
</template>
|
||||
</test-fixture>
|
||||
<test-fixture id='RedirectPath'>
|
||||
<template>
|
||||
<redirect-path></redirect-path>
|
||||
</template>
|
||||
</test-fixture>
|
||||
<test-fixture id='RedirectQuery'>
|
||||
<template>
|
||||
<redirect-query></redirect-query>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
|
@ -46,15 +61,18 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
});
|
||||
}
|
||||
|
||||
suite('<iron-location>', function () {
|
||||
var initialUrl;
|
||||
setup(function() {
|
||||
initialUrl = window.location.href;
|
||||
});
|
||||
teardown(function(){
|
||||
window.history.replaceState({}, '', initialUrl);
|
||||
});
|
||||
// A window.history.replaceState wrapper that's smart about baseURI.
|
||||
function replaceState(url) {
|
||||
window.history.replaceState(
|
||||
{}, '', window.location.protocol + '//' + window.location.host + url);
|
||||
}
|
||||
|
||||
/**
|
||||
* We run the iron location tests with a couple different page configurations
|
||||
* (e.g. with and withoug a base URI), so we define the test set as a function
|
||||
* that we call in each of these configurations.
|
||||
*/
|
||||
function ironLocationTests() {
|
||||
suite('when used solo', function() {
|
||||
var urlElem;
|
||||
setup(function() {
|
||||
|
@ -70,7 +88,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
// Changing the hash via normal means changes the urlElem.
|
||||
var anchor = document.createElement('a');
|
||||
anchor.href = '#/wat';
|
||||
var base =
|
||||
window.location.protocol + '//' + window.location.host +
|
||||
window.location.pathname;
|
||||
anchor.href = base + '#/wat';
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
// In IE10 it appears that the hashchange event is asynchronous.
|
||||
|
@ -88,17 +109,26 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
|
||||
// Changing the path and sending a custom event on the window changes
|
||||
// the urlElem.
|
||||
window.history.replaceState({}, '', '/baz')
|
||||
replaceState('/baz');
|
||||
window.dispatchEvent(new CustomEvent('location-changed'));
|
||||
expect(urlElem.path).to.be.equal('/baz');
|
||||
});
|
||||
test('assigning to a relative path URL', function() {
|
||||
urlElem.path = '/foo/bar';
|
||||
expect(window.location.pathname).to.be.equal('/foo/bar');
|
||||
|
||||
// A relative path is treated as an absolute one, just with a
|
||||
// missing leading slash.
|
||||
urlElem.path = 'baz';
|
||||
expect(window.location.pathname).to.be.equal('/baz');
|
||||
});
|
||||
test('basic functionality with ?key=value params', function() {
|
||||
// Initialized to the window location's params.
|
||||
expect(urlElem.query).to.be.eq('');
|
||||
|
||||
// Changing location.search and sending a custom event on the window
|
||||
// changes the urlElem.
|
||||
window.history.replaceState({}, '', '/?greeting=hello&target=world');
|
||||
replaceState('/?greeting=hello&target=world');
|
||||
window.dispatchEvent(new CustomEvent('location-changed'));
|
||||
expect(urlElem.query).to.be.equal('greeting=hello&target=world');
|
||||
|
||||
|
@ -134,6 +164,67 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
assertHaveSameUrls(urlElem, otherUrlElem);
|
||||
});
|
||||
});
|
||||
|
||||
suite('supports doing synchronous redirection', function() {
|
||||
test('of the hash portion of the URL', function() {
|
||||
expect(window.location.hash).to.be.equal('');
|
||||
var redirector = fixture('RedirectHash');
|
||||
expect(window.location.hash).to.be.equal('#redirectedTo');
|
||||
expect(redirector.hash).to.be.equal('redirectedTo');
|
||||
redirector.hash = 'newHash';
|
||||
expect(window.location.hash).to.be.equal('#redirectedTo');
|
||||
expect(redirector.hash).to.be.equal('redirectedTo');
|
||||
});
|
||||
|
||||
test('of the path portion of the URL', function() {
|
||||
expect(window.location.pathname).to.not.be.equal('/redirectedTo');
|
||||
var redirector = fixture('RedirectPath');
|
||||
expect(window.location.pathname).to.be.equal('/redirectedTo');
|
||||
expect(redirector.path).to.be.equal('/redirectedTo');
|
||||
redirector.path = '/newPath';
|
||||
expect(window.location.pathname).to.be.equal('/redirectedTo');
|
||||
expect(redirector.path).to.be.equal('/redirectedTo');
|
||||
});
|
||||
|
||||
test('of the query portion of the URL', function() {
|
||||
expect(window.location.search).to.be.equal('');
|
||||
var redirector = fixture('RedirectQuery');
|
||||
expect(window.location.search).to.be.equal('?redirectedTo');
|
||||
expect(redirector.query).to.be.equal('redirectedTo');
|
||||
redirector.query = 'newQuery';
|
||||
expect(window.location.search).to.be.equal('?redirectedTo');
|
||||
expect(redirector.query).to.be.equal('redirectedTo');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
suite('<iron-location>', function () {
|
||||
var initialUrl;
|
||||
setup(function() {
|
||||
initialUrl = window.location.href;
|
||||
});
|
||||
teardown(function(){
|
||||
window.history.replaceState({}, '', initialUrl);
|
||||
});
|
||||
|
||||
ironLocationTests();
|
||||
|
||||
suite('with a base URI', function() {
|
||||
var baseElem;
|
||||
setup(function() {
|
||||
expect(document.baseURI).to.be.equal(window.location.href);
|
||||
baseElem = document.createElement('base');
|
||||
var href = 'https://example.com/i/dont/exist/obviously'
|
||||
baseElem.href = href;
|
||||
document.head.appendChild(baseElem);
|
||||
expect(document.baseURI).to.be.equal(href);
|
||||
});
|
||||
teardown(function() {
|
||||
document.head.removeChild(baseElem);
|
||||
});
|
||||
|
||||
ironLocationTests();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue