mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Execute tests within browser page context
This commit is contained in:
@@ -107,7 +107,7 @@ npm run package --prefix ./app -- --platform=linux --packageType=rpm
|
||||
|
||||
Testing requires geckodriver (or chromedriver for Chrome parity testing). See [selenium-webdriver](https://www.npmjs.com/package/selenium-webdriver#installation) installation instructions (ignore `npm install`).
|
||||
|
||||
Tests fail in Chrome currently due to issue with loading the media router scripts.
|
||||
Test results will be displayed within the opened browser tab.
|
||||
|
||||
````sh
|
||||
npm run build --prefix ./app
|
||||
|
||||
11
jasmine.json
11
jasmine.json
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"spec_dir": "test/spec/**",
|
||||
"spec_files": [
|
||||
"*.spec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.js"
|
||||
],
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
"package": "npm run package:app && npm run package:ext",
|
||||
"package:app": "npm run package --prefix ./app",
|
||||
"package:ext": "npm run package --prefix ./ext",
|
||||
"test": "jasmine --config=jasmine.json",
|
||||
"test": "node test/driver.js",
|
||||
"install-manifest": "npm run install-manifest --prefix ./app",
|
||||
"remove-manifest": "npm run remove-manifest --prefix ./app"
|
||||
},
|
||||
|
||||
30
test/SpecRunner.html
Normal file
30
test/SpecRunner.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="lib/jasmine-3.3.0/jasmine.css">
|
||||
|
||||
<script src="lib/jasmine-3.3.0/jasmine.js"></script>
|
||||
<script src="lib/jasmine-3.3.0/jasmine-html.js"></script>
|
||||
<script src="lib/jasmine-3.3.0/boot.js"></script>
|
||||
|
||||
<!-- Cast API -->
|
||||
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
|
||||
|
||||
<!-- Spec files -->
|
||||
<script src="spec/shim/chrome.spec.js"></script>
|
||||
<script src="spec/shim/cast/ApiConfig.spec.js"></script>
|
||||
<script src="spec/shim/cast/DialRequest.spec.js"></script>
|
||||
<script src="spec/shim/cast/Error.spec.js"></script>
|
||||
<script src="spec/shim/cast/Image.spec.js"></script>
|
||||
<script src="spec/shim/cast/Receiver.spec.js"></script>
|
||||
<script src="spec/shim/cast/ReceiverDisplayStatus.spec.js"></script>
|
||||
<script src="spec/shim/cast/SenderApplication.spec.js"></script>
|
||||
<script src="spec/shim/cast/Session.spec.js"></script>
|
||||
<script src="spec/shim/cast/SessionRequest.spec.js"></script>
|
||||
<script src="spec/shim/cast/Timeout.spec.js"></script>
|
||||
<script src="spec/shim/cast/Volume.spec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -26,38 +26,79 @@ const TEST_PAGE_URL = `file:///${__dirname}/test.html`;
|
||||
|
||||
const firefoxOptions = new firefox.Options()
|
||||
.setBinary(firefox.Channel.NIGHTLY)
|
||||
.headless()
|
||||
.addExtensions(extensionArchivePath)
|
||||
.setPreference("xpinstall.signatures.required", false);
|
||||
|
||||
const chromeOptions = new chrome.Options()
|
||||
.headless()
|
||||
.excludeSwitches([ "disable-background-networking"
|
||||
, "disable-default-apps"]);
|
||||
|
||||
|
||||
async function create () {
|
||||
/**
|
||||
* Chrome doesn't load the media router extension immediately
|
||||
* and there doesn't seem to be a consistent way of
|
||||
* determining when it has loaded.
|
||||
|
||||
* Workaround is to poll every 100ms, refresh the page, and
|
||||
* check whether the chrome.cast API objects are defined.
|
||||
*/
|
||||
function waitUntilDefined (
|
||||
driver
|
||||
, pollingTimeout = 10000
|
||||
, pollingFrequency = 100) {
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let time = pollingFrequency;
|
||||
|
||||
const interval = setInterval(async () => {
|
||||
await driver.navigate().refresh();
|
||||
|
||||
const isDefined = await driver.executeScript(() => {
|
||||
return window.chrome.cast !== undefined;
|
||||
});
|
||||
|
||||
time += pollingFrequency;
|
||||
|
||||
if (isDefined) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
} else if (time >= pollingTimeout) {
|
||||
reject("Timed out");
|
||||
}
|
||||
}, pollingFrequency);
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const driver = new webdriver.Builder()
|
||||
.forBrowser("firefox")
|
||||
.setFirefoxOptions(firefoxOptions)
|
||||
.setChromeOptions(chromeOptions)
|
||||
.build();
|
||||
|
||||
// Navigate to test page
|
||||
await driver.get(TEST_PAGE_URL);
|
||||
|
||||
try {
|
||||
// Allow access from other specs
|
||||
this.driver = driver;
|
||||
} catch (err) {}
|
||||
const capabilties = await driver.getCapabilities();
|
||||
switch (capabilties.get("browserName")) {
|
||||
// Need to wait for cast extension on Chrome
|
||||
case "chrome":
|
||||
console.log("Waiting for cast extension...");
|
||||
await waitUntilDefined(driver);
|
||||
console.log("Cast extension loaded!");
|
||||
|
||||
return driver;
|
||||
}
|
||||
break;
|
||||
|
||||
function destroy (driver = this.driver) {
|
||||
driver.quit();
|
||||
}
|
||||
case "firefox":
|
||||
break;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
create
|
||||
, destroy
|
||||
}
|
||||
// Load Jasmine
|
||||
await driver.executeScript(() => {
|
||||
const iframe = document.querySelector("iframe");
|
||||
iframe.setAttribute("src", "SpecRunner.html");
|
||||
});
|
||||
})();
|
||||
|
||||
// Keep process alive
|
||||
process.stdin.resume();
|
||||
|
||||
136
test/lib/jasmine-3.3.0/boot.js
Normal file
136
test/lib/jasmine-3.3.0/boot.js
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
||||
|
||||
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
||||
|
||||
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
||||
|
||||
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* ## Require & Instantiate
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
window.jasmine = jasmineRequire.core(jasmineRequire);
|
||||
|
||||
/**
|
||||
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
||||
*/
|
||||
jasmineRequire.html(jasmine);
|
||||
|
||||
/**
|
||||
* Create the Jasmine environment. This is used to run all specs in a project.
|
||||
*/
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
/**
|
||||
* ## The Global Interface
|
||||
*
|
||||
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
||||
*/
|
||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||
|
||||
/**
|
||||
* Add all of the Jasmine global/public interface to the global scope, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
extend(window, jasmineInterface);
|
||||
|
||||
/**
|
||||
* ## Runner Parameters
|
||||
*
|
||||
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
||||
*/
|
||||
|
||||
var queryString = new jasmine.QueryString({
|
||||
getWindowLocation: function() { return window.location; }
|
||||
});
|
||||
|
||||
var filterSpecs = !!queryString.getParam("spec");
|
||||
|
||||
var config = {
|
||||
failFast: queryString.getParam("failFast"),
|
||||
oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
|
||||
hideDisabled: queryString.getParam("hideDisabled")
|
||||
};
|
||||
|
||||
var random = queryString.getParam("random");
|
||||
|
||||
if (random !== undefined && random !== "") {
|
||||
config.random = random;
|
||||
}
|
||||
|
||||
var seed = queryString.getParam("seed");
|
||||
if (seed) {
|
||||
config.seed = seed;
|
||||
}
|
||||
|
||||
/**
|
||||
* ## Reporters
|
||||
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
||||
*/
|
||||
var htmlReporter = new jasmine.HtmlReporter({
|
||||
env: env,
|
||||
navigateWithNewParam: function(key, value) { return queryString.navigateWithNewParam(key, value); },
|
||||
addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); },
|
||||
getContainer: function() { return document.body; },
|
||||
createElement: function() { return document.createElement.apply(document, arguments); },
|
||||
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
||||
timer: new jasmine.Timer(),
|
||||
filterSpecs: filterSpecs
|
||||
});
|
||||
|
||||
/**
|
||||
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
||||
*/
|
||||
env.addReporter(jasmineInterface.jsApiReporter);
|
||||
env.addReporter(htmlReporter);
|
||||
|
||||
/**
|
||||
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
||||
*/
|
||||
var specFilter = new jasmine.HtmlSpecFilter({
|
||||
filterString: function() { return queryString.getParam("spec"); }
|
||||
});
|
||||
|
||||
config.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
env.configure(config);
|
||||
|
||||
/**
|
||||
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
||||
*/
|
||||
window.setTimeout = window.setTimeout;
|
||||
window.setInterval = window.setInterval;
|
||||
window.clearTimeout = window.clearTimeout;
|
||||
window.clearInterval = window.clearInterval;
|
||||
|
||||
/**
|
||||
* ## Execution
|
||||
*
|
||||
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
||||
*/
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
htmlReporter.initialize();
|
||||
env.execute();
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function for readability above.
|
||||
*/
|
||||
function extend(destination, source) {
|
||||
for (var property in source) destination[property] = source[property];
|
||||
return destination;
|
||||
}
|
||||
|
||||
}());
|
||||
626
test/lib/jasmine-3.3.0/jasmine-html.js
Normal file
626
test/lib/jasmine-3.3.0/jasmine-html.js
Normal file
@@ -0,0 +1,626 @@
|
||||
/*
|
||||
Copyright (c) 2008-2018 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
jasmineRequire.html = function(j$) {
|
||||
j$.ResultsNode = jasmineRequire.ResultsNode();
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
var noopTimer = {
|
||||
start: function() {},
|
||||
elapsed: function() { return 0; }
|
||||
};
|
||||
|
||||
function ResultsStateBuilder() {
|
||||
this.topResults = new j$.ResultsNode({}, '', null);
|
||||
this.currentParent = this.topResults;
|
||||
this.specsExecuted = 0;
|
||||
this.failureCount = 0;
|
||||
this.pendingSpecCount = 0;
|
||||
}
|
||||
|
||||
ResultsStateBuilder.prototype.suiteStarted = function(result) {
|
||||
this.currentParent.addChild(result, 'suite');
|
||||
this.currentParent = this.currentParent.last();
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.suiteDone = function(result) {
|
||||
this.currentParent.updateResult(result);
|
||||
if (this.currentParent !== this.topResults) {
|
||||
this.currentParent = this.currentParent.parent;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.failureCount++;
|
||||
}
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.specStarted = function(result) {
|
||||
};
|
||||
|
||||
ResultsStateBuilder.prototype.specDone = function(result) {
|
||||
this.currentParent.addChild(result, 'spec');
|
||||
|
||||
if (result.status !== 'excluded') {
|
||||
this.specsExecuted++;
|
||||
}
|
||||
|
||||
if (result.status === 'failed') {
|
||||
this.failureCount++;
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
this.pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
function HtmlReporter(options) {
|
||||
var config = function() { return (options.env && options.env.configuration()) || {}; },
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
navigateWithNewParam = options.navigateWithNewParam || function() {},
|
||||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
||||
filterSpecs = options.filterSpecs,
|
||||
timer = options.timer || noopTimer,
|
||||
htmlReporterMain,
|
||||
symbols,
|
||||
deprecationWarnings = [];
|
||||
|
||||
this.initialize = function() {
|
||||
clearPrior();
|
||||
htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'},
|
||||
createDom('div', {className: 'jasmine-banner'},
|
||||
createDom('a', {className: 'jasmine-title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||
createDom('span', {className: 'jasmine-version'}, j$.version)
|
||||
),
|
||||
createDom('ul', {className: 'jasmine-symbol-summary'}),
|
||||
createDom('div', {className: 'jasmine-alert'}),
|
||||
createDom('div', {className: 'jasmine-results'},
|
||||
createDom('div', {className: 'jasmine-failures'})
|
||||
)
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom('div', {className: 'jasmine-summary'});
|
||||
|
||||
var stateBuilder = new ResultsStateBuilder();
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
stateBuilder.suiteStarted(result);
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
stateBuilder.suiteDone(result);
|
||||
|
||||
if (result.status === 'failed') {
|
||||
failures.push(failureDom(result));
|
||||
}
|
||||
addDeprecationWarnings(result);
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
stateBuilder.specStarted(result);
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
stateBuilder.specDone(result);
|
||||
|
||||
if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') {
|
||||
console.error('Spec \'' + result.fullName + '\' has no expectations.');
|
||||
}
|
||||
|
||||
if (!symbols){
|
||||
symbols = find('.jasmine-symbol-summary');
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: this.displaySpecInCorrectFormat(result),
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
));
|
||||
|
||||
if (result.status === 'failed') {
|
||||
failures.push(failureDom(result));
|
||||
}
|
||||
|
||||
addDeprecationWarnings(result);
|
||||
};
|
||||
|
||||
this.displaySpecInCorrectFormat = function(result) {
|
||||
return noExpectations(result) ? 'jasmine-empty' : this.resultStatus(result.status);
|
||||
};
|
||||
|
||||
this.resultStatus = function(status) {
|
||||
if(status === 'excluded') {
|
||||
return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
|
||||
}
|
||||
return 'jasmine-' + status;
|
||||
};
|
||||
|
||||
this.jasmineDone = function(doneResult) {
|
||||
var banner = find('.jasmine-banner');
|
||||
var alert = find('.jasmine-alert');
|
||||
var order = doneResult && doneResult.order;
|
||||
var i;
|
||||
alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||
|
||||
banner.appendChild(optionsMenu(config()));
|
||||
|
||||
if (stateBuilder.specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
var skippedLink = addToExistingQueryString('spec', '');
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-bar jasmine-skipped'},
|
||||
createDom('a', {href: skippedLink, title: 'Run all specs'}, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'jasmine-overall-result jasmine-bar ';
|
||||
var globalFailures = (doneResult && doneResult.failedExpectations) || [];
|
||||
var failed = stateBuilder.failureCount + globalFailures.length > 0;
|
||||
|
||||
if (totalSpecsDefined > 0 || failed) {
|
||||
statusBarMessage += pluralize('spec', stateBuilder.specsExecuted) + ', ' + pluralize('failure', stateBuilder.failureCount);
|
||||
if (stateBuilder.pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', stateBuilder.pendingSpecCount); }
|
||||
}
|
||||
|
||||
if (doneResult.overallStatus === 'passed') {
|
||||
statusBarClassName += ' jasmine-passed ';
|
||||
} else if (doneResult.overallStatus === 'incomplete') {
|
||||
statusBarClassName += ' jasmine-incomplete ';
|
||||
statusBarMessage = 'Incomplete: ' + doneResult.incompleteReason + ', ' + statusBarMessage;
|
||||
} else {
|
||||
statusBarClassName += ' jasmine-failed ';
|
||||
}
|
||||
|
||||
var seedBar;
|
||||
if (order && order.random) {
|
||||
seedBar = createDom('span', {className: 'jasmine-seed-bar'},
|
||||
', randomized with seed ',
|
||||
createDom('a', {title: 'randomized with seed ' + order.seed, href: seedHref(order.seed)}, order.seed)
|
||||
);
|
||||
}
|
||||
|
||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage, seedBar));
|
||||
|
||||
var errorBarClassName = 'jasmine-bar jasmine-errored';
|
||||
var afterAllMessagePrefix = 'AfterAll ';
|
||||
|
||||
for(i = 0; i < globalFailures.length; i++) {
|
||||
alert.appendChild(createDom('span', {className: errorBarClassName}, globalFailureMessage(globalFailures[i])));
|
||||
}
|
||||
|
||||
function globalFailureMessage(failure) {
|
||||
if (failure.globalErrorType === 'load') {
|
||||
var prefix = 'Error during loading: ' + failure.message;
|
||||
|
||||
if (failure.filename) {
|
||||
return prefix + ' in ' + failure.filename + ' line ' + failure.lineno;
|
||||
} else {
|
||||
return prefix;
|
||||
}
|
||||
} else {
|
||||
return afterAllMessagePrefix + failure.message;
|
||||
}
|
||||
}
|
||||
|
||||
addDeprecationWarnings(doneResult);
|
||||
|
||||
var warningBarClassName = 'jasmine-bar jasmine-warning';
|
||||
for(i = 0; i < deprecationWarnings.length; i++) {
|
||||
var warning = deprecationWarnings[i];
|
||||
alert.appendChild(createDom('span', {className: warningBarClassName}, 'DEPRECATION: ' + warning));
|
||||
}
|
||||
|
||||
var results = find('.jasmine-results');
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(stateBuilder.topResults, summary);
|
||||
|
||||
if (failures.length) {
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-spec-list'},
|
||||
createDom('span', {}, 'Spec List | '),
|
||||
createDom('a', {className: 'jasmine-failures-menu', href: '#'}, 'Failures')));
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'jasmine-menu jasmine-bar jasmine-failure-list'},
|
||||
createDom('a', {className: 'jasmine-spec-list-menu', href: '#'}, 'Spec List'),
|
||||
createDom('span', {}, ' | Failures ')));
|
||||
|
||||
find('.jasmine-failures-menu').onclick = function() {
|
||||
setMenuModeTo('jasmine-failure-list');
|
||||
};
|
||||
find('.jasmine-spec-list-menu').onclick = function() {
|
||||
setMenuModeTo('jasmine-spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('jasmine-failure-list');
|
||||
|
||||
var failureNode = find('.jasmine-failures');
|
||||
for (i = 0; i < failures.length; i++) {
|
||||
failureNode.appendChild(failures[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function failureDom(result) {
|
||||
var failure =
|
||||
createDom('div', {className: 'jasmine-spec-detail jasmine-failed'},
|
||||
failureDescription(result, stateBuilder.currentParent),
|
||||
createDom('div', {className: 'jasmine-messages'})
|
||||
);
|
||||
var messages = failure.childNodes[1];
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var expectation = result.failedExpectations[i];
|
||||
messages.appendChild(createDom('div', {className: 'jasmine-result-message'}, expectation.message));
|
||||
messages.appendChild(createDom('div', {className: 'jasmine-stack-trace'}, expectation.stack));
|
||||
}
|
||||
|
||||
return failure;
|
||||
}
|
||||
|
||||
function summaryList(resultsTree, domParent) {
|
||||
var specListNode;
|
||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||
var resultNode = resultsTree.children[i];
|
||||
if (filterSpecs && !hasActiveSpec(resultNode)) {
|
||||
continue;
|
||||
}
|
||||
if (resultNode.type === 'suite') {
|
||||
var suiteListNode = createDom('ul', {className: 'jasmine-suite', id: 'suite-' + resultNode.result.id},
|
||||
createDom('li', {className: 'jasmine-suite-detail jasmine-' + resultNode.result.status},
|
||||
createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||
)
|
||||
);
|
||||
|
||||
summaryList(resultNode, suiteListNode);
|
||||
domParent.appendChild(suiteListNode);
|
||||
}
|
||||
if (resultNode.type === 'spec') {
|
||||
if (domParent.getAttribute('class') !== 'jasmine-specs') {
|
||||
specListNode = createDom('ul', {className: 'jasmine-specs'});
|
||||
domParent.appendChild(specListNode);
|
||||
}
|
||||
var specDescription = resultNode.result.description;
|
||||
if(noExpectations(resultNode.result)) {
|
||||
specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription;
|
||||
}
|
||||
if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') {
|
||||
specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason;
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom('li', {
|
||||
className: 'jasmine-' + resultNode.result.status,
|
||||
id: 'spec-' + resultNode.result.id
|
||||
},
|
||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function optionsMenu(config) {
|
||||
var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
createDom('div', { className: 'jasmine-payload' },
|
||||
createDom('div', { className: 'jasmine-stop-on-failure' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-fail-fast',
|
||||
id: 'jasmine-fail-fast',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-fail-fast' }, 'stop execution on spec failure')),
|
||||
createDom('div', { className: 'jasmine-throw-failures' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-throw',
|
||||
id: 'jasmine-throw-failures',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-throw-failures' }, 'stop spec on expectation failure')),
|
||||
createDom('div', { className: 'jasmine-random-order' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-random',
|
||||
id: 'jasmine-random-order',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-random-order' }, 'run tests in random order')),
|
||||
createDom('div', { className: 'jasmine-hide-disabled' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-disabled',
|
||||
id: 'jasmine-hide-disabled',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom('label', { className: 'jasmine-label', 'for': 'jasmine-hide-disabled' }, 'hide disabled tests'))
|
||||
)
|
||||
);
|
||||
|
||||
var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
|
||||
failFastCheckbox.checked = config.failFast;
|
||||
failFastCheckbox.onclick = function() {
|
||||
navigateWithNewParam('failFast', !config.failFast);
|
||||
};
|
||||
|
||||
var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
|
||||
throwCheckbox.checked = config.oneFailurePerSpec;
|
||||
throwCheckbox.onclick = function() {
|
||||
navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
|
||||
};
|
||||
|
||||
var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
|
||||
randomCheckbox.checked = config.random;
|
||||
randomCheckbox.onclick = function() {
|
||||
navigateWithNewParam('random', !config.random);
|
||||
};
|
||||
|
||||
var hideDisabled = optionsMenuDom.querySelector('#jasmine-hide-disabled');
|
||||
hideDisabled.checked = config.hideDisabled;
|
||||
hideDisabled.onclick = function() {
|
||||
navigateWithNewParam('hideDisabled', !config.hideDisabled);
|
||||
};
|
||||
|
||||
var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
isOpen = /\bjasmine-open\b/;
|
||||
|
||||
optionsTrigger.onclick = function() {
|
||||
if (isOpen.test(optionsPayload.className)) {
|
||||
optionsPayload.className = optionsPayload.className.replace(isOpen, '');
|
||||
} else {
|
||||
optionsPayload.className += ' jasmine-open';
|
||||
}
|
||||
};
|
||||
|
||||
return optionsMenuDom;
|
||||
}
|
||||
|
||||
function failureDescription(result, suite) {
|
||||
var wrapper = createDom('div', {className: 'jasmine-description'},
|
||||
createDom('a', {title: result.description, href: specHref(result)}, result.description)
|
||||
);
|
||||
var suiteLink;
|
||||
|
||||
while (suite && suite.parent) {
|
||||
wrapper.insertBefore(createTextNode(' > '), wrapper.firstChild);
|
||||
suiteLink = createDom('a', {href: suiteHref(suite)}, suite.result.description);
|
||||
wrapper.insertBefore(suiteLink, wrapper.firstChild);
|
||||
|
||||
suite = suite.parent;
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function suiteHref(suite) {
|
||||
var els = [];
|
||||
|
||||
while (suite && suite.parent) {
|
||||
els.unshift(suite.result.description);
|
||||
suite = suite.parent;
|
||||
}
|
||||
|
||||
return addToExistingQueryString('spec', els.join(' '));
|
||||
}
|
||||
|
||||
function addDeprecationWarnings(result) {
|
||||
if (result && result.deprecationWarnings) {
|
||||
for(var i = 0; i < result.deprecationWarnings.length; i++) {
|
||||
var warning = result.deprecationWarnings[i].message;
|
||||
if (!j$.util.arrayContains(warning)) {
|
||||
deprecationWarnings.push(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function find(selector) {
|
||||
return getContainer().querySelector('.jasmine_html-reporter ' + selector);
|
||||
}
|
||||
|
||||
function clearPrior() {
|
||||
// return the reporter
|
||||
var oldReporter = find('');
|
||||
|
||||
if(oldReporter) {
|
||||
getContainer().removeChild(oldReporter);
|
||||
}
|
||||
}
|
||||
|
||||
function createDom(type, attrs, childrenVarArgs) {
|
||||
var el = createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == 'className') {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
function pluralize(singular, count) {
|
||||
var word = (count == 1 ? singular : singular + 's');
|
||||
|
||||
return '' + count + ' ' + word;
|
||||
}
|
||||
|
||||
function specHref(result) {
|
||||
return addToExistingQueryString('spec', result.fullName);
|
||||
}
|
||||
|
||||
function seedHref(seed) {
|
||||
return addToExistingQueryString('seed', seed);
|
||||
}
|
||||
|
||||
function defaultQueryString(key, value) {
|
||||
return '?' + key + '=' + value;
|
||||
}
|
||||
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode);
|
||||
}
|
||||
|
||||
function noExpectations(result) {
|
||||
return (result.failedExpectations.length + result.passedExpectations.length) === 0 &&
|
||||
result.status === 'passed';
|
||||
}
|
||||
|
||||
function hasActiveSpec(resultNode) {
|
||||
if (resultNode.type == 'spec' && resultNode.result.status != 'excluded') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (resultNode.type == 'suite') {
|
||||
for (var i = 0, j = resultNode.children.length; i < j; i++) {
|
||||
if (hasActiveSpec(resultNode.children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return HtmlReporter;
|
||||
};
|
||||
|
||||
jasmineRequire.HtmlSpecFilter = function() {
|
||||
function HtmlSpecFilter(options) {
|
||||
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
var filterPattern = new RegExp(filterString);
|
||||
|
||||
this.matches = function(specName) {
|
||||
return filterPattern.test(specName);
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlSpecFilter;
|
||||
};
|
||||
|
||||
jasmineRequire.ResultsNode = function() {
|
||||
function ResultsNode(result, type, parent) {
|
||||
this.result = result;
|
||||
this.type = type;
|
||||
this.parent = parent;
|
||||
|
||||
this.children = [];
|
||||
|
||||
this.addChild = function(result, type) {
|
||||
this.children.push(new ResultsNode(result, type, this));
|
||||
};
|
||||
|
||||
this.last = function() {
|
||||
return this.children[this.children.length - 1];
|
||||
};
|
||||
|
||||
this.updateResult = function(result) {
|
||||
this.result = result;
|
||||
};
|
||||
}
|
||||
|
||||
return ResultsNode;
|
||||
};
|
||||
|
||||
jasmineRequire.QueryString = function() {
|
||||
function QueryString(options) {
|
||||
|
||||
this.navigateWithNewParam = function(key, value) {
|
||||
options.getWindowLocation().search = this.fullStringWithNewParam(key, value);
|
||||
};
|
||||
|
||||
this.fullStringWithNewParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
paramMap[key] = value;
|
||||
return toQueryString(paramMap);
|
||||
};
|
||||
|
||||
this.getParam = function(key) {
|
||||
return queryStringToParamMap()[key];
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function toQueryString(paramMap) {
|
||||
var qStrPairs = [];
|
||||
for (var prop in paramMap) {
|
||||
qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop]));
|
||||
}
|
||||
return '?' + qStrPairs.join('&');
|
||||
}
|
||||
|
||||
function queryStringToParamMap() {
|
||||
var paramStr = options.getWindowLocation().search.substring(1),
|
||||
params = [],
|
||||
paramMap = {};
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
var value = decodeURIComponent(p[1]);
|
||||
if (value === 'true' || value === 'false') {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
paramMap[decodeURIComponent(p[0])] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return QueryString;
|
||||
};
|
||||
66
test/lib/jasmine-3.3.0/jasmine.css
Normal file
66
test/lib/jasmine-3.3.0/jasmine.css
Normal file
File diff suppressed because one or more lines are too long
6972
test/lib/jasmine-3.3.0/jasmine.js
Normal file
6972
test/lib/jasmine-3.3.0/jasmine.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
const { create, destroy } = require("./driver");
|
||||
|
||||
|
||||
let driver;
|
||||
|
||||
module.exports = async () => {
|
||||
if (!driver) {
|
||||
driver = await create();
|
||||
}
|
||||
|
||||
return driver;
|
||||
};
|
||||
@@ -1,71 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.ApiConfig", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_receiverListener
|
||||
, typeof_sessionListener
|
||||
, typeof_sessionRequest
|
||||
, apiConfig ] = await driver.executeScript(() => {
|
||||
|
||||
const apiConfig = new chrome.cast.ApiConfig();
|
||||
|
||||
return [
|
||||
typeof apiConfig.receiverListener
|
||||
, typeof apiConfig.sessionListener
|
||||
, typeof apiConfig.sessionRequest
|
||||
, apiConfig
|
||||
];
|
||||
});
|
||||
const apiConfig = new chrome.cast.ApiConfig();
|
||||
|
||||
expect(apiConfig.additionalSessionRequests).toEqual([]);
|
||||
expect(apiConfig.autoJoinPolicy).toBe("tab_and_origin_scoped");
|
||||
expect(apiConfig.customDialLaunchCallback).toBe(null);
|
||||
expect(apiConfig.defaultActionPolicy).toBe("create_session");
|
||||
expect(apiConfig.invisibleSender).toBe(false);
|
||||
expect(typeof_receiverListener).toBe("undefined");
|
||||
expect(typeof_sessionListener).toBe("undefined");
|
||||
expect(typeof_sessionRequest).toBe("undefined");
|
||||
expect(typeof apiConfig.receiverListener).toBe("undefined");
|
||||
expect(typeof apiConfig.sessionListener).toBe("undefined");
|
||||
expect(typeof apiConfig.sessionRequest).toBe("undefined");
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const [ typeof_sessionListener
|
||||
, typeof_receiverListener
|
||||
, apiConfig ] = await driver.executeScript(() => {
|
||||
const sessionRequest = new chrome.cast.SessionRequest(
|
||||
chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID);
|
||||
|
||||
const sessionRequest = new chrome.cast.SessionRequest(
|
||||
chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID);
|
||||
function sessionListener () {}
|
||||
function receiverListener () {}
|
||||
|
||||
function sessionListener () {}
|
||||
function receiverListener () {}
|
||||
const apiConfig = new chrome.cast.ApiConfig(
|
||||
sessionRequest
|
||||
, sessionListener
|
||||
, receiverListener
|
||||
, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
|
||||
, chrome.cast.DefaultActionPolicy.CAST_THIS_TAB);
|
||||
|
||||
const apiConfig = new chrome.cast.ApiConfig(
|
||||
sessionRequest
|
||||
, sessionListener
|
||||
, receiverListener
|
||||
, chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
|
||||
, chrome.cast.DefaultActionPolicy.CAST_THIS_TAB);
|
||||
|
||||
return [
|
||||
typeof sessionListener
|
||||
, typeof receiverListener
|
||||
, apiConfig
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_sessionListener).toBe("function");
|
||||
expect(typeof_receiverListener).toBe("function");
|
||||
expect(typeof apiConfig.sessionListener).toBe("function");
|
||||
expect(typeof apiConfig.receiverListener).toBe("function");
|
||||
expect(apiConfig.autoJoinPolicy).toBe("origin_scoped");
|
||||
expect(apiConfig.defaultActionPolicy).toBe("cast_this_tab");
|
||||
});
|
||||
|
||||
@@ -1,40 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.DialRequest", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_appName
|
||||
, dialRequest ] = await driver.executeScript(() => {
|
||||
const dialRequest = new chrome.cast.DialRequest();
|
||||
|
||||
const dialRequest = new chrome.cast.DialRequest();
|
||||
|
||||
return [
|
||||
typeof dialRequest.appName
|
||||
, dialRequest
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_appName).toBe("undefined");
|
||||
expect(typeof dialRequest.appName).toBe("undefined");
|
||||
expect(dialRequest.launchParameter).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const dialRequest = await driver.executeScript(() => {
|
||||
return new chrome.cast.DialRequest(
|
||||
"testAppName"
|
||||
, "testLaunchParameter");
|
||||
});
|
||||
const dialRequest = new chrome.cast.DialRequest(
|
||||
"testAppName"
|
||||
, "testLaunchParameter");
|
||||
|
||||
expect(dialRequest.appName).toBe("testAppName");
|
||||
expect(dialRequest.launchParameter).toBe("testLaunchParameter");
|
||||
|
||||
@@ -1,42 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Error", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_code
|
||||
, error ] = await driver.executeScript(() => {
|
||||
const error = new chrome.cast.Error();
|
||||
|
||||
const error = new chrome.cast.Error();
|
||||
|
||||
return [
|
||||
typeof error.code
|
||||
, error
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_code).toBe("undefined");
|
||||
expect(typeof error.code).toBe("undefined");
|
||||
expect(error.description).toBe(null);
|
||||
expect(error.details).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const error = await driver.executeScript(() => {
|
||||
return new chrome.cast.Error(
|
||||
chrome.cast.ErrorCode.CANCEL
|
||||
, "testErrorDescription"
|
||||
, { testErrorDetails: "testErrorDetails" });
|
||||
});
|
||||
const error = new chrome.cast.Error(
|
||||
chrome.cast.ErrorCode.CANCEL
|
||||
, "testErrorDescription"
|
||||
, { testErrorDetails: "testErrorDetails" });
|
||||
|
||||
expect(error.code).toBe("cancel");
|
||||
expect(error.description).toBe("testErrorDescription");
|
||||
|
||||
@@ -1,39 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Image", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_url
|
||||
, image ] = await driver.executeScript(() => {
|
||||
const image = new chrome.cast.Image();
|
||||
|
||||
const image = new chrome.cast.Image();
|
||||
|
||||
return [
|
||||
typeof image.url
|
||||
, image
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_url).toBe("undefined");
|
||||
expect(typeof image.url).toBe("undefined");
|
||||
expect(image.height).toBe(null);
|
||||
expect(image.width).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const image = await driver.executeScript(() => {
|
||||
return new chrome.cast.Image("http://example.com");
|
||||
});
|
||||
const image = new chrome.cast.Image("http://example.com");
|
||||
|
||||
expect(image.url).toBe("http://example.com");
|
||||
});
|
||||
|
||||
@@ -1,34 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Receiver", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_friendlyName
|
||||
, typeof_label
|
||||
, receiver ] = await driver.executeScript(() => {
|
||||
const receiver = new chrome.cast.Receiver();
|
||||
|
||||
const receiver = new chrome.cast.Receiver();
|
||||
|
||||
return [
|
||||
typeof receiver.friendlyName
|
||||
, typeof receiver.label
|
||||
, receiver
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_friendlyName).toBe("undefined");
|
||||
expect(typeof_label).toBe("undefined");
|
||||
expect(typeof receiver.friendlyName).toBe("undefined");
|
||||
expect(typeof receiver.label).toBe("undefined");
|
||||
expect(receiver.capabilities).toEqual([]);
|
||||
expect(receiver.displayStatus).toBe(null);
|
||||
expect(receiver.isActiveInput).toBe(null);
|
||||
@@ -37,18 +14,16 @@ describe("chrome.cast.Receiver", () => {
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const error = await driver.executeScript(() => {
|
||||
return new chrome.cast.Receiver(
|
||||
"testLabel"
|
||||
, "testFriendlyName"
|
||||
, [ chrome.cast.Capability.VIDEO_OUT
|
||||
, chrome.cast.Capability.AUDIO_OUT ]
|
||||
, new chrome.cast.Volume(1, false));
|
||||
});
|
||||
const receiver = new chrome.cast.Receiver(
|
||||
"testLabel"
|
||||
, "testFriendlyName"
|
||||
, [ chrome.cast.Capability.VIDEO_OUT
|
||||
, chrome.cast.Capability.AUDIO_OUT ]
|
||||
, new chrome.cast.Volume(1, false));
|
||||
|
||||
expect(error.capabilities).toEqual([ "video_out", "audio_out" ]);
|
||||
expect(error.friendlyName).toBe("testFriendlyName");
|
||||
expect(error.label).toBe("testLabel");
|
||||
expect(error.volume).toEqual({ level: 1, muted: false });
|
||||
expect(receiver.capabilities).toEqual([ "video_out", "audio_out" ]);
|
||||
expect(receiver.friendlyName).toBe("testFriendlyName");
|
||||
expect(receiver.label).toBe("testLabel");
|
||||
expect(receiver.volume).toEqual(jasmine.objectContaining({ level: 1, muted: false }));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,52 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
const { create } = require("../../../driver");
|
||||
|
||||
describe("chrome.cast.Receiver", () => {
|
||||
let driver;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
})
|
||||
|
||||
|
||||
it("should have all properties", async () => {
|
||||
const [ typeof_appImages
|
||||
, typeof_statusText
|
||||
, receiverDisplayStatus ] = await driver.executeScript(() => {
|
||||
const receiverDisplayStatus =
|
||||
new chrome.cast.ReceiverDisplayStatus();
|
||||
|
||||
const receiverDisplayStatus =
|
||||
new chrome.cast.ReceiverDisplayStatus();
|
||||
|
||||
return [
|
||||
typeof receiverDisplayStatus.appImages
|
||||
, typeof receiverDisplayStatus.statusText
|
||||
, receiverDisplayStatus
|
||||
];
|
||||
});
|
||||
|
||||
expect(typeof_appImages).toBe("undefined");
|
||||
expect(typeof_statusText).toBe("undefined");
|
||||
expect(typeof receiverDisplayStatus.appImages).toBe("undefined");
|
||||
expect(typeof receiverDisplayStatus.statusText).toBe("undefined");
|
||||
expect(receiverDisplayStatus.showStop).toBe(null);
|
||||
});
|
||||
|
||||
it("should have expected assigned properties", async () => {
|
||||
const receiverDisplayStatus = await driver.executeScript(() => {
|
||||
return new chrome.cast.ReceiverDisplayStatus(
|
||||
"testStatusText"
|
||||
, [
|
||||
new chrome.cast.Image("http://example.com/1")
|
||||
, new chrome.cast.Image("http://example.com/2")
|
||||
]);
|
||||
});
|
||||
const receiverDisplayStatus = new chrome.cast.ReceiverDisplayStatus(
|
||||
"testStatusText"
|
||||
, [
|
||||
new chrome.cast.Image("http://example.com/1")
|
||||
, new chrome.cast.Image("http://example.com/2")
|
||||
]);
|
||||
|
||||
expect(receiverDisplayStatus.statusText).toBe("testStatusText");
|
||||
expect(receiverDisplayStatus.appImages).toEqual([
|
||||
{ url: "http://example.com/1", height: null, width: null }
|
||||
, { url: "http://example.com/2", height: null, width: null }
|
||||
]);
|
||||
expect(receiverDisplayStatus.appImages).toContain(jasmine.objectContaining({ url: "http://example.com/1", height: null, width: null }))
|
||||
expect(receiverDisplayStatus.appImages).toContain(jasmine.objectContaining({ url: "http://example.com/2", height: null, width: null }))
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,29 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const { create, destroy } = require("../../driver");
|
||||
|
||||
describe("chrome", () => {
|
||||
let driver;
|
||||
let chrome;
|
||||
|
||||
beforeAll(async () => {
|
||||
driver = await create();
|
||||
chrome = await driver.executeScript(() => {
|
||||
return chrome;
|
||||
});
|
||||
});
|
||||
afterAll(() => {
|
||||
driver.quit();
|
||||
});
|
||||
|
||||
|
||||
it("should exist", () => {
|
||||
expect(chrome).toBeDefined();
|
||||
expect(chrome.cast).toBeDefined();
|
||||
expect(chrome.cast.media).toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
describe("chrome.cast", () => {
|
||||
it("should have all api methods", () => {
|
||||
expect(chrome.cast.addReceiverActionListener).toBeDefined();
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1>TEST PAGE</h1>
|
||||
<iframe width="800" height="600" src=""></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user