mirror of
https://github.com/RussellChamp/GrimoireJS.git
synced 2026-10-27 22:42:32 +00:00
Added jasmine standalone and tests
This commit is contained in:
1 parent
6a2f87e751
commit
e09411b27d
9 files changed
+4337
No files matched your search
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Jasmine Spec Runner v2.2.0</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="jasmine/lib/jasmine-2.2.0/jasmine_favicon.png">
|
||||
<link rel="stylesheet" href="jasmine/lib/jasmine-2.2.0/jasmine.css">
|
||||
|
||||
<script src="jasmine/lib/jasmine-2.2.0/jasmine.js"></script>
|
||||
<script src="jasmine/lib/jasmine-2.2.0/jasmine-html.js"></script>
|
||||
<script src="jasmine/lib/jasmine-2.2.0/boot.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script src="grimoire-core.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
|
||||
<script src="chance.min.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="jasmine/spec/grimoireSpec.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2014 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.
|
||||
@@ -0,0 +1,121 @@
|
||||
/**
|
||||
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 proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
||||
*/
|
||||
if (typeof window == "undefined" && typeof exports == "object") {
|
||||
extend(exports, jasmineInterface);
|
||||
} else {
|
||||
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);
|
||||
|
||||
/**
|
||||
* ## 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()); },
|
||||
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;
|
||||
}
|
||||
|
||||
}());
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 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;
|
||||
};
|
||||
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
Copyright (c) 2008-2015 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() {},
|
||||
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: 'banner'},
|
||||
createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}),
|
||||
createDom('span', {className: 'version'}, j$.version)
|
||||
),
|
||||
createDom('ul', {className: 'symbol-summary'}),
|
||||
createDom('div', {className: 'alert'}),
|
||||
createDom('div', {className: 'results'},
|
||||
createDom('div', {className: 'failures'})
|
||||
)
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
|
||||
symbols = find('.symbol-summary');
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
this.jasmineStarted = function(options) {
|
||||
totalSpecsDefined = options.totalSpecsDefined || 0;
|
||||
timer.start();
|
||||
};
|
||||
|
||||
var summary = createDom('div', {className: '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++;
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom('li', {
|
||||
className: noExpectations(result) ? 'empty' : result.status,
|
||||
id: 'spec_' + result.id,
|
||||
title: result.fullName
|
||||
}
|
||||
));
|
||||
|
||||
if (result.status == 'failed') {
|
||||
failureCount++;
|
||||
|
||||
var failure =
|
||||
createDom('div', {className: 'spec-detail failed'},
|
||||
createDom('div', {className: 'description'},
|
||||
createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName)
|
||||
),
|
||||
createDom('div', {className: '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: 'result-message'}, expectation.message));
|
||||
messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack));
|
||||
}
|
||||
|
||||
failures.push(failure);
|
||||
}
|
||||
|
||||
if (result.status == 'pending') {
|
||||
pendingSpecCount++;
|
||||
}
|
||||
};
|
||||
|
||||
this.jasmineDone = function() {
|
||||
var banner = find('.banner');
|
||||
banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
|
||||
|
||||
var alert = find('.alert');
|
||||
|
||||
alert.appendChild(createDom('span', { className: 'exceptions' },
|
||||
createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'),
|
||||
createDom('input', {
|
||||
className: 'raise',
|
||||
id: 'raise-exceptions',
|
||||
type: 'checkbox'
|
||||
})
|
||||
));
|
||||
var checkbox = find('#raise-exceptions');
|
||||
|
||||
checkbox.checked = !env.catchingExceptions();
|
||||
checkbox.onclick = onRaiseExceptionsClick;
|
||||
|
||||
if (specsExecuted < totalSpecsDefined) {
|
||||
var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'bar skipped'},
|
||||
createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage)
|
||||
)
|
||||
);
|
||||
}
|
||||
var statusBarMessage = '';
|
||||
var statusBarClassName = 'bar ';
|
||||
|
||||
if (totalSpecsDefined > 0) {
|
||||
statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount);
|
||||
if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); }
|
||||
statusBarClassName += (failureCount > 0) ? 'failed' : 'passed';
|
||||
} else {
|
||||
statusBarClassName += 'skipped';
|
||||
statusBarMessage += 'No specs found';
|
||||
}
|
||||
|
||||
alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage));
|
||||
|
||||
for(i = 0; i < failedSuites.length; i++) {
|
||||
var failedSuite = failedSuites[i];
|
||||
for(var j = 0; j < failedSuite.failedExpectations.length; j++) {
|
||||
var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message;
|
||||
var errorBarClassName = 'bar errored';
|
||||
alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage));
|
||||
}
|
||||
}
|
||||
|
||||
var results = find('.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: 'suite', id: 'suite-' + resultNode.result.id},
|
||||
createDom('li', {className: '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') != 'specs') {
|
||||
specListNode = createDom('ul', {className: '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: resultNode.result.status,
|
||||
id: 'spec-' + resultNode.result.id
|
||||
},
|
||||
createDom('a', {href: specHref(resultNode.result)}, specDescription)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (failures.length) {
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar spec-list'},
|
||||
createDom('span', {}, 'Spec List | '),
|
||||
createDom('a', {className: 'failures-menu', href: '#'}, 'Failures')));
|
||||
alert.appendChild(
|
||||
createDom('span', {className: 'menu bar failure-list'},
|
||||
createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'),
|
||||
createDom('span', {}, ' | Failures ')));
|
||||
|
||||
find('.failures-menu').onclick = function() {
|
||||
setMenuModeTo('failure-list');
|
||||
};
|
||||
find('.spec-list-menu').onclick = function() {
|
||||
setMenuModeTo('spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('failure-list');
|
||||
|
||||
var failureNode = find('.failures');
|
||||
for (var 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 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;
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
body { overflow-y: scroll; }
|
||||
|
||||
.jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
|
||||
.jasmine_html-reporter a { text-decoration: none; }
|
||||
.jasmine_html-reporter a:hover { text-decoration: underline; }
|
||||
.jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; }
|
||||
.jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
|
||||
.jasmine_html-reporter .banner { position: relative; }
|
||||
.jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4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IGMgMCw4MC43MDMgLTY2Ljk0LDE0NS44MTMgLTE0Ny42MywxNDUuODEzIC04My40NCwwIC0xNDcuNjMsLTY4Ljc4MSAtMTQ3LjYzLC0xNTEuMzAxIDAsLTc5Ljc4NSA2Ni45NCwtMTQ1LjgwMSAxNDUuOCwtMTQ1LjgwMSA4NC4zNSwwIDE0OS40Niw2Ny44NTIgMTQ5LjQ2LDE1MS4yODkgeiBtIC0xLjgzLC0xODEuNTQ3IGMgLTM1Ljc3LC01NC4wOTcgLTkzLjUzLC03OC44NTkgLTE1Ny43MiwtNzguODU5IC0xNDAuMywwIC0yNTEuMjQsMTE2LjQ0OSAtMjUxLjILine truncated
|
||||
.jasmine_html-reporter .banner .version { margin-left: 14px; position: relative; top: 6px; }
|
||||
.jasmine_html-reporter .banner .duration { position: absolute; right: 14px; top: 6px; }
|
||||
.jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; }
|
||||
.jasmine_html-reporter .version { color: #aaa; }
|
||||
.jasmine_html-reporter .banner { margin-top: 14px; }
|
||||
.jasmine_html-reporter .duration { color: #aaa; float: right; }
|
||||
.jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
.jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
|
||||
.jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; }
|
||||
.jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; }
|
||||
.jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; }
|
||||
.jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
|
||||
.jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; }
|
||||
.jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
|
||||
.jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; }
|
||||
.jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
|
||||
.jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; }
|
||||
.jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; }
|
||||
.jasmine_html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
.jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
.jasmine_html-reporter .bar.failed { background-color: #ca3a11; }
|
||||
.jasmine_html-reporter .bar.passed { background-color: #007069; }
|
||||
.jasmine_html-reporter .bar.skipped { background-color: #bababa; }
|
||||
.jasmine_html-reporter .bar.errored { background-color: #ca3a11; }
|
||||
.jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaa; }
|
||||
.jasmine_html-reporter .bar.menu a { color: #333; }
|
||||
.jasmine_html-reporter .bar a { color: white; }
|
||||
.jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; }
|
||||
.jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; }
|
||||
.jasmine_html-reporter .running-alert { background-color: #666; }
|
||||
.jasmine_html-reporter .results { margin-top: 14px; }
|
||||
.jasmine_html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
.jasmine_html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
.jasmine_html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
.jasmine_html-reporter.showDetails .summary { display: none; }
|
||||
.jasmine_html-reporter.showDetails #details { display: block; }
|
||||
.jasmine_html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
.jasmine_html-reporter .summary { margin-top: 14px; }
|
||||
.jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
|
||||
.jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
|
||||
.jasmine_html-reporter .summary li.passed a { color: #007069; }
|
||||
.jasmine_html-reporter .summary li.failed a { color: #ca3a11; }
|
||||
.jasmine_html-reporter .summary li.empty a { color: #ba9d37; }
|
||||
.jasmine_html-reporter .summary li.pending a { color: #ba9d37; }
|
||||
.jasmine_html-reporter .description + .suite { margin-top: 0; }
|
||||
.jasmine_html-reporter .suite { margin-top: 14px; }
|
||||
.jasmine_html-reporter .suite a { color: #333; }
|
||||
.jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; }
|
||||
.jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; }
|
||||
.jasmine_html-reporter .failures .spec-detail .description a { color: white; }
|
||||
.jasmine_html-reporter .result-message { padding-top: 14px; color: #333; white-space: pre; }
|
||||
.jasmine_html-reporter .result-message span.result { display: block; }
|
||||
.jasmine_html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,453 @@
|
||||
/*global Grimoire:true, _:true, jasmine:true, describe:true, beforeEach:true, it:true, expect:true*/
|
||||
'use strict';
|
||||
|
||||
xdescribe('Sources', function() {
|
||||
var grimoire = new Grimoire();
|
||||
it('should load sources', function() {
|
||||
expect(grimoire.SOURCES).toBeTruthy();
|
||||
});
|
||||
grimoire.SOURCES.forEach(function(source) {
|
||||
describe(source.name + ' (' + source.shortName + ')', function() {
|
||||
it('should list types', function() {
|
||||
expect(source.types).toBeTruthy();
|
||||
expect(source.types.length).toBeGreaterThan(0);
|
||||
});
|
||||
source.types.forEach(function(type) {
|
||||
describe(type.name, function() {
|
||||
it('should have a name', function() {
|
||||
expect(type.name).toBeTruthy();
|
||||
});
|
||||
it('should initialize itself', function() {
|
||||
expect(source.data[type.name]).toBeTruthy();
|
||||
});
|
||||
if(type.source) {
|
||||
it('should load data', function() {
|
||||
expect(source.data[type.name].data).toBeTruthy();
|
||||
});
|
||||
//CHECK SPECIFIC DATA NOW
|
||||
if(type.name == 'Armor and Shields' || type.name == 'Weapons') {
|
||||
//could contain uniques or specials
|
||||
for(var key in source.data[type.name].data) {
|
||||
var itemList = source.data[type.name].data[key];
|
||||
describe(key, function() {
|
||||
it('should have names', function() {
|
||||
for(var i in itemList) {
|
||||
expect(itemList[i].name).toBeTruthy();
|
||||
}
|
||||
});
|
||||
it('should have cost or bonus', function() {
|
||||
for(var i in itemList) {
|
||||
var costPlusBonus = (itemList[i].cost || 0) + (itemList[i].bonus || 0);
|
||||
expect(costPlusBonus).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
it('should have weights', function() {
|
||||
for(var i in itemList) {
|
||||
var weightSum = _.sum(_.values(itemList[i].weight));
|
||||
expect(weightSum).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
//These follow the same data format
|
||||
else if(type.name == 'Rings' || type.name == 'Rods' || type.name == 'Staves') {
|
||||
var itemList = source.data[type.name].data;
|
||||
it('should have names', function() {
|
||||
for(var i in itemList) {
|
||||
expect(itemList[i].name).toBeTruthy();
|
||||
}
|
||||
});
|
||||
it('should have costs', function() {
|
||||
for(var i in itemList) {
|
||||
expect(itemList[i].cost).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
//CURRENTLY MISSING WEIGHTS ON APG ITEMS
|
||||
xit('should have weights', function() {
|
||||
for(var i in itemList) {
|
||||
var weightSum = _.sum(_.values(itemList[i].weight));
|
||||
expect(weightSum).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if(type.name == 'Potions') {
|
||||
var potionList = source.data.Potions.data;
|
||||
it('should have potion levels 0-3', function() {
|
||||
expect(potionList.length).toEqual(4);
|
||||
})
|
||||
}
|
||||
else if(type.name == 'Scrolls') {
|
||||
; //nothing really to test
|
||||
}
|
||||
else if(type.name == 'Wands') {
|
||||
; //nothing really to test
|
||||
}
|
||||
else if(type.name == 'Spells') {
|
||||
for(var key in source.data.Spells.data) {
|
||||
describe(key, function() {
|
||||
var spellList = source.data.Spells.data[key];
|
||||
it('should have spell levels 0-9', function() {
|
||||
expect(spellList.length).toEqual(10);
|
||||
});
|
||||
//There MUST be 10 arrays within the spell type array
|
||||
//These do not have to contain data
|
||||
});
|
||||
}
|
||||
}
|
||||
//Do not have weights
|
||||
else if(type.name == 'Wondrous Items') {
|
||||
var items = source.data['Wondrous Items'].data;
|
||||
['minor', 'medium', 'major'].forEach(function(quality) {
|
||||
describe(quality, function() {
|
||||
it('should exist', function() {
|
||||
expect(items[quality]).toBeTruthy();
|
||||
});
|
||||
it('should have names', function() {
|
||||
for(var i in items[quality]) {
|
||||
expect(items[quality][i].name).toBeTruthy();
|
||||
}
|
||||
});
|
||||
it('should have costs', function() {
|
||||
for(var i in items[quality]) {
|
||||
expect(items[quality][i].cost).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}); //end describe type
|
||||
}); //end forEach type
|
||||
}); //end source name
|
||||
}); //end forEach source
|
||||
}); //end sources
|
||||
|
||||
describe('Grimoire', function() {
|
||||
var grimoire = new Grimoire();
|
||||
|
||||
beforeEach(function() {
|
||||
//grimoire = new Grimoire(); //load fresh?
|
||||
});
|
||||
|
||||
it('should exist', function() {
|
||||
expect(grimoire).toBeTruthy();
|
||||
});
|
||||
it('should contain sources', function() {
|
||||
expect(grimoire.SOURCES.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
describe('getBane', function() {
|
||||
it('should get a Bane', function() {
|
||||
//remove the humanoid or outsider type when getting the banes to avoid mismatching
|
||||
var allBanes = _.map(grimoire.Banes, function(b) { return b.name.replace(/\s\(.*\)/, ''); });
|
||||
var bane = grimoire.getBane().replace(/\s\(.*\)/, '');
|
||||
expect(allBanes).toContain(bane);
|
||||
});
|
||||
});
|
||||
describe('getHumanoid', function() {
|
||||
it('should get a Humanoid', function() {
|
||||
var allHumanoids = _.map(grimoire.Humanoids, function(h) { return h.name; });
|
||||
var humanoid = grimoire.getHumanoid();
|
||||
expect(allHumanoids).toContain(humanoid);
|
||||
});
|
||||
});
|
||||
describe('getOutsider', function() {
|
||||
it('should get a Outsider', function() {
|
||||
var allOutsiders = _.map(grimoire.Outsiders, function(o) { return o.name; });
|
||||
var outsider = grimoire.getOutsider();
|
||||
expect(allOutsiders).toContain(outsider);
|
||||
});
|
||||
});
|
||||
describe('getEnergyType', function() {
|
||||
it('should get an EnergyType', function() {
|
||||
var allEnergyTypes = _.values(ENERGY_TYPES);
|
||||
var energyType = grimoire.getEnergyType();
|
||||
expect(allEnergyTypes).toContain(energyType);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSpell', function() {
|
||||
it('should get a spell', function() {
|
||||
var spell = grimoire.getSpell(1);
|
||||
expect(spell.name).toBeDefined();
|
||||
});
|
||||
it('should get spells of the correct level', function() {
|
||||
var spell = grimoire.getSpell(3);
|
||||
expect(spell.level).toEqual(3);
|
||||
spell = grimoire.getSpell(7);
|
||||
expect(spell.level).toEqual(7);
|
||||
});
|
||||
it('should respect the spellType option', function() {
|
||||
var spell = grimoire.getSpell(2, {type: 'Divine'});
|
||||
expect(spell.type).toBe('Divine');
|
||||
spell = grimoire.getSpell(2, {type: 'Arcane'});
|
||||
expect(spell.type).toBe('Arcane');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSpells', function() {
|
||||
it('should get spells', function() {
|
||||
var spells = grimoire.getSpells(1, 3);
|
||||
expect(spells.length).toBe(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getScroll', function() {
|
||||
it('should get a Scroll', function() {
|
||||
var spell = grimoire.getScroll('minor');
|
||||
expect(spell.itemType).toBe('Scrolls');
|
||||
});
|
||||
it('should override with spellLevel option', function() {
|
||||
var spell = grimoire.getScroll('minor', {scrollLevel: 5});
|
||||
expect(spell.description).toMatch(/spell level 5/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPotion', function() {
|
||||
it('should get a Potion', function() {
|
||||
var potion = grimoire.getPotion('medium');
|
||||
expect(potion.itemType).toBe('Potions');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getWand', function() {
|
||||
it('should get a Wand', function() {
|
||||
var wand = grimoire.getWand('medium');
|
||||
expect(wand.itemType).toBe('Wands');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRing', function() {
|
||||
it('should get a Ring', function() {
|
||||
var ring = grimoire.getRing('medium');
|
||||
expect(ring.itemType).toBe('Rings');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRod', function() {
|
||||
it('should get a Rod', function() {
|
||||
var rod = grimoire.getRod('medium');
|
||||
expect(rod.itemType).toBe('Rods');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getStaff', function() {
|
||||
it('should get a Staff', function() {
|
||||
var staff = grimoire.getStaff('medium');
|
||||
expect(staff.itemType).toBe('Staves');
|
||||
});
|
||||
it('should not return a minor Staff', function() {
|
||||
var staff = grimoire.getStaff('minor');
|
||||
expect(staff).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSpecials', function() {
|
||||
describe('melee', function() {
|
||||
var specials = grimoire.getSpecials('medium', 'melee');
|
||||
it('should get melee specials', function() {
|
||||
expect(specials.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('should not exceed a bonus of 10', function() {
|
||||
var totalBonus = _.sum(_.map(specials, function(s) { return s.bonus; }));
|
||||
expect(totalBonus).toBeLessThan(11);
|
||||
});
|
||||
});
|
||||
describe('ranged', function() {
|
||||
var specials = grimoire.getSpecials('medium', 'ranged');
|
||||
it('should get melee specials', function() {
|
||||
expect(specials.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('should not exceed a bonus of 10', function() {
|
||||
var totalBonus = _.sum(_.map(specials, function(s) { return s.bonus; }));
|
||||
expect(totalBonus).toBeLessThan(11);
|
||||
});
|
||||
});
|
||||
describe('armor', function() {
|
||||
var specials = grimoire.getSpecials('medium', 'armor');
|
||||
it('should get armor specials', function() {
|
||||
expect(specials.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('should not exceed a bonus of 10', function() {
|
||||
var totalBonus = _.sum(_.map(specials, function(s) { return s.bonus; }));
|
||||
expect(totalBonus).toBeLessThan(11);
|
||||
});
|
||||
});
|
||||
describe('shield', function() {
|
||||
var specials = grimoire.getSpecials('medium', 'shield');
|
||||
it('should get shield specials', function() {
|
||||
expect(specials.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('should not exceed a bonus of 10', function() {
|
||||
var totalBonus = _.sum(_.map(specials, function(s) { return s.bonus; }));
|
||||
expect(totalBonus).toBeLessThan(11);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUniqueWeapon', function() {
|
||||
it('should get a unique weapon', function() {
|
||||
var weapon = grimoire.getUniqueWeapon('medium');
|
||||
expect(weapon.itemType).toBe('Weapons');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getWeapon', function() {
|
||||
it('should get a weapon', function() {
|
||||
var weapon = grimoire.getWeapon('medium');
|
||||
expect(weapon.itemType).toBe('Weapons');
|
||||
});
|
||||
});
|
||||
|
||||
//not written yet
|
||||
// describe('getArmorOrSheild', function() {
|
||||
// ;
|
||||
// });
|
||||
|
||||
describe('getAlignment', function() {
|
||||
it('should get an Alignment', function() {
|
||||
var alignment = grimoire.getAlignment();
|
||||
expect(alignment).toBeTruthy();
|
||||
});
|
||||
it('should respect weighting options', function() {
|
||||
var alignment = grimoire.getAlignment({clWeights:[1,0,0], geWeights:[1,0,0]});
|
||||
expect(alignment).toEqual('Chaotic Good');
|
||||
alignment = grimoire.getAlignment({clWeights:[0,0,1], geWeights:[0,0,1]});
|
||||
expect(alignment).toEqual('Lawful Evil');
|
||||
});
|
||||
it('should know True Neutral', function() {
|
||||
var alignment = grimoire.getAlignment({clWeights:[0,1,0], geWeights:[0,1,0]});
|
||||
expect(alignment).toEqual('True Neutral');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDeity', function() {
|
||||
it('should get a Deity', function() {
|
||||
var deity = grimoire.getDeity();
|
||||
expect(deity.name).toBeTruthy();
|
||||
});
|
||||
it('should respect alignment options', function() {
|
||||
var deity = grimoire.getDeity({cl:'Chaotic', ge:'Evil'});
|
||||
expect(deity.alignment).toEqual('Chaotic Evil');
|
||||
deity = grimoire.getDeity({cl:'Lawful', ge:'Good'});
|
||||
expect(deity.alignment).toEqual('Lawful Good');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getIntelligence', function() {
|
||||
var intelligence = grimoire.getIntelligence(5000, {purposeChance: 100});
|
||||
it('should have a cost', function() {
|
||||
expect(intelligence.cost).toBeTruthy();
|
||||
});
|
||||
it('should have an ego', function() {
|
||||
expect(intelligence.ego).toBeTruthy();
|
||||
});
|
||||
it('should have an alignment', function() {
|
||||
expect(intelligence.alignment).toBeTruthy();
|
||||
});
|
||||
it('should have stats', function() {
|
||||
expect(intelligence.stats.charisma).toBeGreaterThan(9);
|
||||
expect(intelligence.stats.intelligence).toBeGreaterThan(9);
|
||||
expect(intelligence.stats.wisdom).toBeGreaterThan(9);
|
||||
});
|
||||
it('should have languages', function() {
|
||||
expect(intelligence.languages.length).toBeGreaterThan(0);
|
||||
});
|
||||
it('should have senses', function() {
|
||||
expect(intelligence.senses).toBeTruthy();
|
||||
});
|
||||
it('should have powers', function() {
|
||||
expect(intelligence.powers).toBeTruthy();
|
||||
expect(intelligence.powers.length).toBeLessThan(4); //for a 5000gp item
|
||||
});
|
||||
it('should have a purpose', function() {
|
||||
expect(intelligence.purpose).toBeTruthy();
|
||||
});
|
||||
it('should have dedicated powers', function() {
|
||||
expect(intelligence.dedicatedPowers).toBeTruthy();
|
||||
});
|
||||
it('should have have a print function', function() {
|
||||
expect(intelligence.print).toBeTruthy();
|
||||
expect(intelligence.print()).toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('getItem', function() {
|
||||
it('should get a minor item', function() {
|
||||
var item = grimoire.getItem('minor');
|
||||
expect(item.name).toBeDefined();
|
||||
});
|
||||
it('should get a medium item', function() {
|
||||
var item = grimoire.getItem('medium');
|
||||
expect(item.name).toBeDefined();
|
||||
});
|
||||
it('should get a major item', function() {
|
||||
var item = grimoire.getItem('major');
|
||||
expect(item.name).toBeDefined();
|
||||
});
|
||||
|
||||
it('should get a Scroll', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Scrolls']});
|
||||
expect(item.itemType).toBe('Scrolls');
|
||||
});
|
||||
it('should get a Potion', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Potions']});
|
||||
expect(item.itemType).toBe('Potions');
|
||||
});
|
||||
it('should get a Wand', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Wands']});
|
||||
expect(item.itemType).toBe('Wands');
|
||||
});
|
||||
it('should get a Wondrous Item', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Wondrous Items']});
|
||||
expect(item.itemType).toBe('Wondrous Items');
|
||||
});
|
||||
it('should get a Weapon', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Weapons']});
|
||||
expect(item.itemType).toBe('Weapons');
|
||||
});
|
||||
it('should get a Armor or Shield', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Armor and Shields']});
|
||||
expect(item.itemType).toBe('Armor and Shields');
|
||||
});
|
||||
it('should get a Ring', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Rings']});
|
||||
expect(item.itemType).toBe('Rings');
|
||||
});
|
||||
it('should get a Rods', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Rods']});
|
||||
expect(item.itemType).toBe('Rods');
|
||||
});
|
||||
it('should get a Staff', function() {
|
||||
var item = grimoire.getItem('medium', {types: ['Staves']});
|
||||
expect(item.itemType).toBe('Staves');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getItems', function() {
|
||||
it('should get minor items', function() {
|
||||
var items = grimoire.getItems('minor', 3);
|
||||
expect(items.length).toEqual(3);
|
||||
});
|
||||
it('should get medium items', function() {
|
||||
var items = grimoire.getItems('medium', 3);
|
||||
expect(items.length).toEqual(3);
|
||||
});
|
||||
it('should get major items', function() {
|
||||
var items = grimoire.getItems('major', 3);
|
||||
expect(items.length).toEqual(3);
|
||||
});
|
||||
it('should respect the source option', function() {
|
||||
var source = _.find(grimoire.SOURCES, {shortName: 'CRB'});
|
||||
var item = grimoire.getItems('minor', 1, {sources: [source]})[0];
|
||||
expect(item.source).toBe(source.shortName);
|
||||
});
|
||||
it('should respect the types option', function() {
|
||||
var item = grimoire.getItems('minor', 1, {types: ['Rings']})[0];
|
||||
expect(item.itemType).toBe('Rings');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user