Partial tests and accompanying bugfixes.
This commit is contained in:
parent
110879829b
commit
1b0175d237
24
packages/projector/SpecRunner.html
Normal file
24
packages/projector/SpecRunner.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Jasmine Spec Runner v2.5.2</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="vendor/jasmine-2.5.2/jasmine_favicon.png">
|
||||
<link rel="stylesheet" href="vendor/jasmine-2.5.2/jasmine.css">
|
||||
|
||||
<script src="vendor/jasmine-2.5.2/jasmine.js"></script>
|
||||
<script src="vendor/jasmine-2.5.2/jasmine-html.js"></script>
|
||||
<script src="vendor/jasmine-2.5.2/boot.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="dist/projector.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="spec/projector.spec.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@ -1 +1,184 @@
|
||||
const { Projector } = require('../lib/index.js');
|
||||
// const { Projector } = require('../lib/index.js');
|
||||
|
||||
let COUNTER = 0;
|
||||
|
||||
describe('Projector', () => {
|
||||
let projector;
|
||||
let container;
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.createElement('div');
|
||||
container.className = 'testContainer';
|
||||
document.body.appendChild(container);
|
||||
|
||||
projector = Projector.Projector(container);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
container.parentNode.removeChild(container);
|
||||
container = null;
|
||||
});
|
||||
|
||||
function add(data, parentId = null, before) {
|
||||
projector.queueFrame([[0, parentId, data, before]]);
|
||||
return data.i;
|
||||
}
|
||||
|
||||
function patch(id, props) {
|
||||
projector.queueFrame([[1, id, props]]);
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
projector.queueFrame([[2, id]]);
|
||||
}
|
||||
|
||||
function h(tagName, props, children = []) {
|
||||
return {
|
||||
t: 1,
|
||||
n: tagName,
|
||||
p: props,
|
||||
c: children,
|
||||
i: COUNTER++
|
||||
};
|
||||
}
|
||||
|
||||
function waitForNextFrame() {
|
||||
return new Promise(resolve => {
|
||||
requestAnimationFrame(() => {
|
||||
setTimeout(resolve, 1);
|
||||
}, container);
|
||||
});
|
||||
}
|
||||
|
||||
describe('getElement', () => {
|
||||
it('getElement(null) method should to return the container.', () => {
|
||||
expect(projector.getElement(null)).toBe(container);
|
||||
});
|
||||
|
||||
it('getElement(id) method should to return the patched node.', () => {
|
||||
const id = add(h('div', { className: 'first' }));
|
||||
expect(projector.getElement(id)._id).toBe(id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('queueFrame', () => {
|
||||
describe('patch to add elements', () => {
|
||||
it('patch to add a basic element with a class', () => {
|
||||
expect(container.childNodes.length).toBe(0);
|
||||
|
||||
const id = add(h('div', { className: 'first' }));
|
||||
|
||||
expect(container.childNodes.length).toBe(1);
|
||||
const newEl = document.querySelector('.first');
|
||||
expect(newEl._id).toBe(id);
|
||||
expect(newEl.parentNode).toBe(container);
|
||||
expect(newEl.className).toBe('first');
|
||||
});
|
||||
|
||||
it('patch to add a text element', () => {
|
||||
expect(container.childNodes.length).toBe(0);
|
||||
|
||||
const id = add({
|
||||
t: 3,
|
||||
n: '',
|
||||
p: { textContent: 'howdy' },
|
||||
c: [],
|
||||
i: COUNTER++
|
||||
});
|
||||
|
||||
expect(container.childNodes.length).toBe(1);
|
||||
const newEl = container.childNodes[0];
|
||||
expect(newEl._id).toBe(id);
|
||||
expect(newEl.parentNode).toBe(container);
|
||||
expect(newEl.textContent).toBe('howdy');
|
||||
});
|
||||
|
||||
it('patch to add a sibling element with a class', done => {
|
||||
const id = add(h('div', { className: 'first' }));
|
||||
waitForNextFrame()
|
||||
.then(() => {
|
||||
const siblingId = add(h('div', { className: 'second' }), null, id);
|
||||
|
||||
expect(container.childNodes.length).toBe(2);
|
||||
const el = document.querySelector('.second');
|
||||
expect(el._id).toBe(siblingId);
|
||||
expect(el.parentNode).toBe(container);
|
||||
expect(el.nextSibling._id).toBe(id);
|
||||
})
|
||||
.then(done)
|
||||
.catch(console.error.bind(console));
|
||||
});
|
||||
|
||||
it('patch to add a tree of elements', () => {
|
||||
const id = add(h('div', {}, [h('span', { className: 'child' })]));
|
||||
const parent = projector.getElement(id);
|
||||
expect(container.childNodes.length).toBe(1);
|
||||
const child = parent.childNodes[0];
|
||||
expect(document.querySelector('.child')).toBe(child);
|
||||
expect(projector.getElement(child._id)).toBe(child);
|
||||
});
|
||||
});
|
||||
|
||||
describe('patch to update elements', () => {
|
||||
it('patch to change a class', done => {
|
||||
const id = add(h('div', { className: 'first' }));
|
||||
waitForNextFrame()
|
||||
.then(() => {
|
||||
patch(id, { className: 'second' });
|
||||
|
||||
expect(container.childNodes.length).toBe(1);
|
||||
const el = document.querySelector('.second');
|
||||
expect(el._id).toBe(id);
|
||||
expect(el.parentNode).toBe(container);
|
||||
expect(el.className).toBe('second');
|
||||
})
|
||||
.then(done)
|
||||
.catch(console.error.bind(console));
|
||||
});
|
||||
|
||||
it('patch to update text', done => {
|
||||
expect(container.childNodes.length).toBe(0);
|
||||
|
||||
const id = add({
|
||||
t: 3,
|
||||
n: '',
|
||||
p: { textContent: 'howdy' },
|
||||
c: [],
|
||||
i: COUNTER++
|
||||
});
|
||||
|
||||
expect(container.childNodes.length).toBe(1);
|
||||
const newEl = container.childNodes[0];
|
||||
expect(newEl._id).toBe(id);
|
||||
expect(newEl.parentNode).toBe(container);
|
||||
expect(newEl.textContent).toBe('howdy');
|
||||
waitForNextFrame()
|
||||
.then(() => {
|
||||
patch(id, { textContent: 'pardner' });
|
||||
|
||||
expect(newEl.textContent).toBe('pardner');
|
||||
})
|
||||
.then(done)
|
||||
.catch(console.error.bind(console));
|
||||
});
|
||||
});
|
||||
|
||||
describe('patch to remove an element', () => {
|
||||
it('', done => {
|
||||
const id = add(h('div', {}, [h('span', { className: 'child' })]));
|
||||
const parent = projector.getElement(id);
|
||||
const child = parent.childNodes[0];
|
||||
expect(projector.getElement(child._id)).toBe(child);
|
||||
remove(child._id);
|
||||
waitForNextFrame()
|
||||
.then(() => {
|
||||
expect(parent.childNodes.length).toBe(0);
|
||||
expect(child.parentNode).toBe(null);
|
||||
expect(projector.getElement(child._id)).toBe(undefined);
|
||||
})
|
||||
.then(done)
|
||||
.catch(console.error.bind(console));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,167 +2,151 @@ import { isFunction } from 'trimkit';
|
||||
|
||||
import { sanitizeObject, supportsPassive } from './utils.js';
|
||||
|
||||
|
||||
const OVERRIDING_EVENTS = ['contextmenu','dragover','drop'];
|
||||
const OVERRIDING_EVENTS = ['contextmenu', 'dragover', 'drop'];
|
||||
function getEventList(element) {
|
||||
return (element.getAttribute('evl') || '').split(';');
|
||||
const evtString = element.getAttribute('evl');
|
||||
return evtString ? evtString.split(';') : [];
|
||||
}
|
||||
|
||||
export function Projector(domRoot) {
|
||||
const elementMap = new Map();
|
||||
const pendingFrames = [];
|
||||
const eventCallbacks = [];
|
||||
let runningNextFrame;
|
||||
const elementMap = new Map();
|
||||
const pendingFrames = [];
|
||||
const eventCallbacks = [];
|
||||
const eventMap = new Map();
|
||||
let runningNextFrame;
|
||||
|
||||
function eventHandler(evt) {
|
||||
if (OVERRIDING_EVENTS.includes(eventName)) {
|
||||
evt.preventDefault();
|
||||
};
|
||||
function eventHandler(evt) {
|
||||
if (OVERRIDING_EVENTS.includes(eventName)) {
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
||||
const fakeEvt = sanitizeObject(evt);
|
||||
if (evt.target) {
|
||||
fakeEvt.target = evt.target._id;
|
||||
}
|
||||
const fakeEvt = sanitizeObject(evt);
|
||||
if (evt.target) {
|
||||
fakeEvt.target = evt.target._id;
|
||||
}
|
||||
|
||||
eventCallbacks.forEach(cb => cb(fakeEvt));
|
||||
}
|
||||
function removeEvent(eventSet, id, eventName) {
|
||||
eventSet.remove(element._id);
|
||||
if (!eventSet.size) {
|
||||
domRoot.removeEventListener(eventName, eventHandler);
|
||||
}
|
||||
}
|
||||
eventCallbacks.forEach(cb => cb(fakeEvt));
|
||||
}
|
||||
function removeEvent(eventSet, id, eventName) {
|
||||
eventSet.remove(element._id);
|
||||
if (!eventSet.size) {
|
||||
domRoot.removeEventListener(eventName, eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function setAttributes(element, props) {
|
||||
Object.entries((name, value) => {
|
||||
if (name in element) {
|
||||
if (name.startsWith('on')) {
|
||||
const eventName = name.substr(2);
|
||||
const eventSet = eventMap.get(eventName) || new Set();
|
||||
const eventList = getEventList(element);
|
||||
if (value === null) {
|
||||
// remove event
|
||||
eventList.splice(eventList.indexOf(eventName), 1);
|
||||
removeEvent(eventSet, element._id, eventName);
|
||||
} else {
|
||||
// add event
|
||||
if (!eventSet.size) {
|
||||
domRoot.addEventListener(
|
||||
eventName,
|
||||
eventHandler,
|
||||
(
|
||||
(supportsPassive && !OVERRIDING_EVENTS.includes(eventName))
|
||||
? { passive: true, capture: false }
|
||||
: false
|
||||
)
|
||||
);
|
||||
}
|
||||
eventList.push(eventName);
|
||||
eventSet.add(element._id);
|
||||
if (!eventMap.has(eventName)) {
|
||||
eventMap.set(eventName, eventSet);
|
||||
}
|
||||
}
|
||||
element.setAttribute('evl', eventList.join(';'));
|
||||
} else {
|
||||
element[name] = value;
|
||||
}
|
||||
} else if (value === null) {
|
||||
element.removeAttribute(name);
|
||||
} else {
|
||||
element.setAttribute(name, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
function setAttributes(element, props) {
|
||||
Object.entries(props).forEach(([name, value]) => {
|
||||
if (name in element) {
|
||||
if (name.startsWith('on')) {
|
||||
const eventName = name.substr(2);
|
||||
const eventSet = eventMap.get(eventName) || new Set();
|
||||
const eventList = getEventList(element);
|
||||
if (value === null) {
|
||||
// remove event
|
||||
eventList.splice(eventList.indexOf(eventName), 1);
|
||||
removeEvent(eventSet, element._id, eventName);
|
||||
} else {
|
||||
// add event
|
||||
if (!eventSet.size) {
|
||||
domRoot.addEventListener(
|
||||
eventName,
|
||||
eventHandler,
|
||||
supportsPassive && !OVERRIDING_EVENTS.includes(eventName)
|
||||
? { passive: true, capture: false }
|
||||
: false
|
||||
);
|
||||
}
|
||||
eventList.push(eventName);
|
||||
eventSet.add(element._id);
|
||||
if (!eventMap.has(eventName)) {
|
||||
eventMap.set(eventName, eventSet);
|
||||
}
|
||||
}
|
||||
element.setAttribute('evl', eventList.join(';'));
|
||||
} else {
|
||||
element[name] = value;
|
||||
}
|
||||
} else if (value === null) {
|
||||
element.removeAttribute(name);
|
||||
} else {
|
||||
element.setAttribute(name, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createElement({
|
||||
t as type,
|
||||
n as name,
|
||||
p as props,
|
||||
i as id,
|
||||
c as children
|
||||
}) {
|
||||
let element;
|
||||
if (type === 3) {
|
||||
element = document.createTextNode(props.textContent);
|
||||
} else if (type === 1) {
|
||||
element = document.createElement(name);
|
||||
}
|
||||
setAttributes(element, props);
|
||||
elementMap.set(element._id = id, element);
|
||||
function createElement({ t: type, n: name, p: props, i: id, c: children }) {
|
||||
let element;
|
||||
if (type === 3) {
|
||||
element = document.createTextNode(props.textContent);
|
||||
} else if (type === 1) {
|
||||
element = document.createElement(name);
|
||||
}
|
||||
setAttributes(element, props);
|
||||
elementMap.set((element._id = id), element);
|
||||
|
||||
for (let i=0; i<children.length; i++) {
|
||||
element.appendChild(createElement(children[i]));
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
element.appendChild(createElement(children[i]));
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
function _removeElement(parent, childrenToRemove) {
|
||||
childrenToRemove.forEach(function (id) {
|
||||
const child = getElement(id);
|
||||
_removeElement(child, asArray(child.childNodes).map(c => c._id)))
|
||||
function removeElement(element) {
|
||||
Array.from(element.childNodes).forEach(removeElement);
|
||||
|
||||
getEventList(child).forEach(eventName => {
|
||||
removeEvent(
|
||||
eventMap.get(eventName),
|
||||
child._id,
|
||||
eventName
|
||||
);
|
||||
});
|
||||
getEventList(element).forEach(eventName => {
|
||||
removeEvent(eventMap.get(eventName), element._id, eventName);
|
||||
});
|
||||
|
||||
parent.removeChild(child);
|
||||
});
|
||||
}
|
||||
element.parentNode.removeChild(element);
|
||||
elementMap.delete(element._id);
|
||||
}
|
||||
|
||||
const ACTION_METHODS = [
|
||||
function addElement(parentId, data, nextSiblingId) {
|
||||
getElement(parentId)
|
||||
.insertBefore(
|
||||
createElement(data),
|
||||
getElement(nextSiblingId)
|
||||
);
|
||||
},
|
||||
setAttributes,
|
||||
function removeElement(parentId, childrenToRemove) {
|
||||
_removeElement(getElement(parentId), childrenToRemove);
|
||||
},
|
||||
];
|
||||
const ACTION_METHODS = [
|
||||
function addElement(parent, data, nextSiblingId) {
|
||||
parent.insertBefore(createElement(data), getElement(nextSiblingId));
|
||||
},
|
||||
setAttributes,
|
||||
removeElement
|
||||
];
|
||||
|
||||
const queuePatch = (patchFrame) => {
|
||||
if (!patchFrame || !patchFrame.length) {
|
||||
return;
|
||||
}
|
||||
pendingFrames.unshift(patchFrame);
|
||||
if (!runningNextFrame) {
|
||||
updateFrame();
|
||||
}
|
||||
};
|
||||
const queueFrame = patchFrame => {
|
||||
if (!patchFrame || !patchFrame.length) {
|
||||
return;
|
||||
}
|
||||
pendingFrames.unshift(patchFrame);
|
||||
if (!runningNextFrame) {
|
||||
updateFrame();
|
||||
}
|
||||
};
|
||||
|
||||
const updateFrame = () => {
|
||||
const patches = pendingFrames.pop();
|
||||
// console.group('PatchSet');
|
||||
let patch;
|
||||
while (patch = patchSet.shift()) {
|
||||
// console.log(ACTION_METHODS[patch[0]].name, JSON.stringify(patch));
|
||||
ACTION_METHODS[patch[0]](patchParams[1], patchParams[2], patchParams[3]);
|
||||
}
|
||||
const updateFrame = () => {
|
||||
const patches = pendingFrames.pop();
|
||||
if (!patches) {
|
||||
runningNextFrame = null;
|
||||
return;
|
||||
}
|
||||
// console.group('PatchSet');
|
||||
let patch;
|
||||
while ((patch = patches.shift())) {
|
||||
// console.log(ACTION_METHODS[patch[0]].name, JSON.stringify(patch));
|
||||
ACTION_METHODS[patch[0]](getElement(patch[1]), patch[2], patch[3]);
|
||||
}
|
||||
// console.groupEnd('PatchSet');
|
||||
|
||||
while(postProcessing.length) { postProcessing.pop()(); }
|
||||
// console.groupEnd('PatchSet');
|
||||
runningNextFrame = requestAnimationFrame(updateFrame, domRoot);
|
||||
};
|
||||
|
||||
if (pendingFrames.length) {
|
||||
runningNextFrame = requestAnimationFrame(updateFrame, domRoot);
|
||||
} else {
|
||||
runningNextFrame = null;
|
||||
}
|
||||
};
|
||||
function getElement(id) {
|
||||
return id === null ? domRoot : elementMap.get(id);
|
||||
}
|
||||
|
||||
function getElement(id) {
|
||||
return elementMap.get(id);
|
||||
}
|
||||
function subscribe(fn) {
|
||||
eventCallbacks.push(fn);
|
||||
}
|
||||
|
||||
return {
|
||||
queuePatch,
|
||||
getElement,
|
||||
subscribe,
|
||||
};
|
||||
return {
|
||||
queueFrame,
|
||||
getElement,
|
||||
subscribe
|
||||
};
|
||||
}
|
||||
|
||||
146
packages/projector/vendor/jasmine-2.5.2/boot.js
vendored
Normal file
146
packages/projector/vendor/jasmine-2.5.2/boot.js
vendored
Normal file
@ -0,0 +1,146 @@
|
||||
/**
|
||||
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 catchingExceptions = queryString.getParam('catch');
|
||||
env.catchExceptions(typeof catchingExceptions === 'undefined' ? true : catchingExceptions);
|
||||
|
||||
var throwingExpectationFailures = queryString.getParam('throwFailures');
|
||||
env.throwOnExpectationFailure(throwingExpectationFailures);
|
||||
|
||||
var random = queryString.getParam('random');
|
||||
env.randomizeTests(random);
|
||||
|
||||
var seed = queryString.getParam('seed');
|
||||
if (seed) {
|
||||
env.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,
|
||||
onRaiseExceptionsClick: function() {
|
||||
queryString.navigateWithNewParam('catch', !env.catchingExceptions());
|
||||
},
|
||||
onThrowExpectationsClick: function() {
|
||||
queryString.navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
|
||||
},
|
||||
onRandomClick: function() {
|
||||
queryString.navigateWithNewParam('random', !env.randomTests());
|
||||
},
|
||||
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()
|
||||
});
|
||||
|
||||
/**
|
||||
* 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');
|
||||
}
|
||||
});
|
||||
|
||||
env.specFilter = function(spec) {
|
||||
return specFilter.matches(spec.getFullName());
|
||||
};
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
})();
|
||||
196
packages/projector/vendor/jasmine-2.5.2/console.js
vendored
Normal file
196
packages/projector/vendor/jasmine-2.5.2/console.js
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
/*
|
||||
Copyright (c) 2008-2016 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.
|
||||
*/
|
||||
function getJasmineRequireObj() {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
return exports;
|
||||
} else {
|
||||
window.jasmineRequire = window.jasmineRequire || {};
|
||||
return window.jasmineRequire;
|
||||
}
|
||||
}
|
||||
|
||||
getJasmineRequireObj().console = function(jRequire, j$) {
|
||||
j$.ConsoleReporter = jRequire.ConsoleReporter();
|
||||
};
|
||||
|
||||
getJasmineRequireObj().ConsoleReporter = function() {
|
||||
var noopTimer = {
|
||||
start: function() {},
|
||||
elapsed: function() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
function ConsoleReporter(options) {
|
||||
var print = options.print,
|
||||
showColors = options.showColors || false,
|
||||
onComplete = options.onComplete || function() {},
|
||||
timer = options.timer || noopTimer,
|
||||
specCount,
|
||||
failureCount,
|
||||
failedSpecs = [],
|
||||
pendingCount,
|
||||
ansi = {
|
||||
green: '\x1B[32m',
|
||||
red: '\x1B[31m',
|
||||
yellow: '\x1B[33m',
|
||||
none: '\x1B[0m'
|
||||
},
|
||||
failedSuites = [];
|
||||
|
||||
print('ConsoleReporter is deprecated and will be removed in a future version.');
|
||||
|
||||
this.jasmineStarted = function() {
|
||||
specCount = 0;
|
||||
failureCount = 0;
|
||||
pendingCount = 0;
|
||||
print('Started');
|
||||
printNewline();
|
||||
timer.start();
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
printNewline();
|
||||
for (var i = 0; i < failedSpecs.length; i++) {
|
||||
specFailureDetails(failedSpecs[i]);
|
||||
}
|
||||
|
||||
if (specCount > 0) {
|
||||
printNewline();
|
||||
|
||||
var specCounts =
|
||||
specCount +
|
||||
' ' +
|
||||
plural('spec', specCount) +
|
||||
', ' +
|
||||
failureCount +
|
||||
' ' +
|
||||
plural('failure', failureCount);
|
||||
|
||||
if (pendingCount) {
|
||||
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
|
||||
}
|
||||
|
||||
print(specCounts);
|
||||
} else {
|
||||
print('No specs found');
|
||||
}
|
||||
|
||||
printNewline();
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print('Finished in ' + seconds + ' ' + plural('second', seconds));
|
||||
printNewline();
|
||||
|
||||
for (i = 0; i < failedSuites.length; i++) {
|
||||
suiteFailureDetails(failedSuites[i]);
|
||||
}
|
||||
|
||||
onComplete(failureCount === 0);
|
||||
};
|
||||
|
||||
this.specDone = function(result) {
|
||||
specCount++;
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingCount++;
|
||||
print(colored('yellow', '*'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'passed') {
|
||||
print(colored('green', '.'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
failedSpecs.push(result);
|
||||
print(colored('red', 'F'));
|
||||
}
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.failedExpectations && result.failedExpectations.length > 0) {
|
||||
failureCount++;
|
||||
failedSuites.push(result);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function printNewline() {
|
||||
print('\n');
|
||||
}
|
||||
|
||||
function colored(color, str) {
|
||||
return showColors ? ansi[color] + str + ansi.none : str;
|
||||
}
|
||||
|
||||
function plural(str, count) {
|
||||
return count == 1 ? str : str + 's';
|
||||
}
|
||||
|
||||
function repeat(thing, times) {
|
||||
var arr = [];
|
||||
for (var i = 0; i < times; i++) {
|
||||
arr.push(thing);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
function indent(str, spaces) {
|
||||
var lines = (str || '').split('\n');
|
||||
var newArr = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
newArr.push(repeat(' ', spaces).join('') + lines[i]);
|
||||
}
|
||||
return newArr.join('\n');
|
||||
}
|
||||
|
||||
function specFailureDetails(result) {
|
||||
printNewline();
|
||||
print(result.fullName);
|
||||
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
var failedExpectation = result.failedExpectations[i];
|
||||
printNewline();
|
||||
print(indent(failedExpectation.message, 2));
|
||||
print(indent(failedExpectation.stack, 2));
|
||||
}
|
||||
|
||||
printNewline();
|
||||
}
|
||||
|
||||
function suiteFailureDetails(result) {
|
||||
for (var i = 0; i < result.failedExpectations.length; i++) {
|
||||
printNewline();
|
||||
print(colored('red', 'An error was thrown in an afterAll'));
|
||||
printNewline();
|
||||
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
|
||||
}
|
||||
printNewline();
|
||||
}
|
||||
}
|
||||
|
||||
return ConsoleReporter;
|
||||
};
|
||||
575
packages/projector/vendor/jasmine-2.5.2/jasmine-html.js
vendored
Normal file
575
packages/projector/vendor/jasmine-2.5.2/jasmine-html.js
vendored
Normal file
@ -0,0 +1,575 @@
|
||||
/*
|
||||
Copyright (c) 2008-2016 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 HtmlReporter(options) {
|
||||
var env = options.env || {},
|
||||
getContainer = options.getContainer,
|
||||
createElement = options.createElement,
|
||||
createTextNode = options.createTextNode,
|
||||
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
||||
onThrowExpectationsClick = options.onThrowExpectationsClick || function() {},
|
||||
onRandomClick = options.onRandomClick || function() {},
|
||||
addToExistingQueryString = options.addToExistingQueryString || defaultQueryString,
|
||||
timer = options.timer || noopTimer,
|
||||
results = [],
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
pendingSpecCount = 0,
|
||||
htmlReporterMain,
|
||||
symbols,
|
||||
failedSuites = [];
|
||||
|
||||
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 topResults = new j$.ResultsNode({}, '', null),
|
||||
currentParent = topResults;
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
currentParent.addChild(result, 'suite');
|
||||
currentParent = currentParent.last();
|
||||
};
|
||||
|
||||
this.suiteDone = function(result) {
|
||||
if (result.status == 'failed') {
|
||||
failedSuites.push(result);
|
||||
}
|
||||
|
||||
if (currentParent == topResults) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentParent = currentParent.parent;
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
currentParent.addChild(result, 'spec');
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if (
|
||||
noExpectations(result) &&
|
||||
typeof console !== 'undefined' &&
|
||||
typeof console.error !== 'undefined'
|
||||
) {
|
||||
console.error("Spec '" + result.fullName + "' has no expectations.");
|
||||
}
|
||||
|
||||
if (result.status != 'disabled') {
|
||||
specsExecuted++;
|
||||
}
|
||||
|
||||
if (!symbols) {
|
||||
symbols = find('.jasmine-symbol-summary');
|
||||
}
|
||||
|
||||
symbols.appendChild(
|
||||
createDom('li', {
|
||||
className: noExpectations(result) ? 'jasmine-empty' : 'jasmine-' + result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
})
|
||||
);
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
|
||||
var failure = createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-spec-detail jasmine-failed' },
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-description' },
|
||||
createDom('a', { title: result.fullName, href: specHref(result) }, result.fullName)
|
||||
),
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
failures.push(failure);
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function(doneResult) {
|
||||
var banner = find('.jasmine-banner');
|
||||
var alert = find('.jasmine-alert');
|
||||
var order = doneResult && doneResult.order;
|
||||
alert.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-duration' },
|
||||
'finished in ' + timer.elapsed() / 1000 + 's'
|
||||
)
|
||||
);
|
||||
|
||||
banner.appendChild(
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-run-options' },
|
||||
createDom('span', { className: 'jasmine-trigger' }, 'Options'),
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-payload' },
|
||||
createDom(
|
||||
'div',
|
||||
{ className: 'jasmine-exceptions' },
|
||||
createDom('input', {
|
||||
className: 'jasmine-raise',
|
||||
id: 'jasmine-raise-exceptions',
|
||||
type: 'checkbox'
|
||||
}),
|
||||
createDom(
|
||||
'label',
|
||||
{ className: 'jasmine-label', for: 'jasmine-raise-exceptions' },
|
||||
'raise exceptions'
|
||||
)
|
||||
),
|
||||
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'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
var raiseCheckbox = find('#jasmine-raise-exceptions');
|
||||
|
||||
raiseCheckbox.checked = !env.catchingExceptions();
|
||||
raiseCheckbox.onclick = onRaiseExceptionsClick;
|
||||
|
||||
var throwCheckbox = find('#jasmine-throw-failures');
|
||||
throwCheckbox.checked = env.throwingExpectationFailures();
|
||||
throwCheckbox.onclick = onThrowExpectationsClick;
|
||||
|
||||
var randomCheckbox = find('#jasmine-random-order');
|
||||
randomCheckbox.checked = env.randomTests();
|
||||
randomCheckbox.onclick = onRandomClick;
|
||||
|
||||
var optionsMenu = find('.jasmine-run-options'),
|
||||
optionsTrigger = optionsMenu.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenu.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';
|
||||
}
|
||||
};
|
||||
|
||||
if (specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
var skippedLink = order && order.random ? '?random=true' : '?';
|
||||
alert.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: 'jasmine-bar jasmine-skipped' },
|
||||
createDom('a', { href: skippedLink, title: 'Run all specs' }, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'jasmine-bar ';
|
||||
|
||||
if (totalSpecsDefined > 0) {
|
||||
statusBarMessage +=
|
||||
pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||
if (pendingSpecCount) {
|
||||
statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount);
|
||||
}
|
||||
statusBarClassName += failureCount > 0 ? 'jasmine-failed' : 'jasmine-passed';
|
||||
} else {
|
||||
statusBarClassName += 'jasmine-skipped';
|
||||
statusBarMessage += 'No specs found';
|
||||
}
|
||||
|
||||
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 errorBarMessagePrefix = 'AfterAll ';
|
||||
|
||||
for (var i = 0; i < failedSuites.length; i++) {
|
||||
var failedSuite = failedSuites[i];
|
||||
for (var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||
alert.appendChild(
|
||||
createDom(
|
||||
'span',
|
||||
{ className: errorBarClassName },
|
||||
errorBarMessagePrefix + failedSuite.failedExpectations[j].message
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var globalFailures = (doneResult && doneResult.failedExpectations) || [];
|
||||
for (i = 0; i < globalFailures.length; i++) {
|
||||
var failure = globalFailures[i];
|
||||
alert.appendChild(
|
||||
createDom('span', { className: errorBarClassName }, errorBarMessagePrefix + failure.message)
|
||||
);
|
||||
}
|
||||
|
||||
var results = find('.jasmine-results');
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(topResults, summary);
|
||||
|
||||
function summaryList(resultsTree, domParent) {
|
||||
var specListNode;
|
||||
for (var i = 0; i < resultsTree.children.length; i++) {
|
||||
var resultNode = resultsTree.children[i];
|
||||
if (resultNode.type == 'suite') {
|
||||
var suiteListNode = createDom(
|
||||
'ul',
|
||||
{ className: 'jasmine-suite', id: 'suite-' + resultNode.result.id },
|
||||
createDom(
|
||||
'li',
|
||||
{ className: 'jasmine-suite-detail' },
|
||||
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)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
58
packages/projector/vendor/jasmine-2.5.2/jasmine.css
vendored
Normal file
58
packages/projector/vendor/jasmine-2.5.2/jasmine.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3845
packages/projector/vendor/jasmine-2.5.2/jasmine.js
vendored
Normal file
3845
packages/projector/vendor/jasmine-2.5.2/jasmine.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/projector/vendor/jasmine-2.5.2/jasmine_favicon.png
vendored
Normal file
BIN
packages/projector/vendor/jasmine-2.5.2/jasmine_favicon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Loading…
x
Reference in New Issue
Block a user