First development of the deploy action (#6)
Some checks failed
Lint / pre-commit Linting (push) Has been cancelled
Some checks failed
Lint / pre-commit Linting (push) Has been cancelled
Deploy js code to an instance of screeps. Some debugging tools are implemented. Reviewed-on: #6 Co-authored-by: Philipp Horstenkamp <philipp@horstenkamp.de> Co-committed-by: Philipp Horstenkamp <philipp@horstenkamp.de>
This commit is contained in:
24
node_modules/yamljs/test/SpecRunner.html
generated
vendored
Normal file
24
node_modules/yamljs/test/SpecRunner.html
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Jasmine Spec Runner v2.0.0</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.0/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.0/jasmine.css">
|
||||
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="../dist/yaml.debug.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/YamlSpec.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
20
node_modules/yamljs/test/lib/jasmine-2.0.0/MIT.LICENSE
generated
vendored
Normal file
20
node_modules/yamljs/test/lib/jasmine-2.0.0/MIT.LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008-2011 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.
|
181
node_modules/yamljs/test/lib/jasmine-2.0.0/boot.js
generated
vendored
Normal file
181
node_modules/yamljs/test/lib/jasmine-2.0.0/boot.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
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`, 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 = {
|
||||
describe: function(description, specDefinitions) {
|
||||
return env.describe(description, specDefinitions);
|
||||
},
|
||||
|
||||
xdescribe: function(description, specDefinitions) {
|
||||
return env.xdescribe(description, specDefinitions);
|
||||
},
|
||||
|
||||
it: function(desc, func) {
|
||||
return env.it(desc, func);
|
||||
},
|
||||
|
||||
xit: function(desc, func) {
|
||||
return env.xit(desc, func);
|
||||
},
|
||||
|
||||
beforeEach: function(beforeEachFunction) {
|
||||
return env.beforeEach(beforeEachFunction);
|
||||
},
|
||||
|
||||
afterEach: function(afterEachFunction) {
|
||||
return env.afterEach(afterEachFunction);
|
||||
},
|
||||
|
||||
expect: function(actual) {
|
||||
return env.expect(actual);
|
||||
},
|
||||
|
||||
pending: function() {
|
||||
return env.pending();
|
||||
},
|
||||
|
||||
spyOn: function(obj, methodName) {
|
||||
return env.spyOn(obj, methodName);
|
||||
},
|
||||
|
||||
jsApiReporter: new jasmine.JsApiReporter({
|
||||
timer: new jasmine.Timer()
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose the interface for adding custom equality testers.
|
||||
*/
|
||||
jasmine.addCustomEqualityTester = function(tester) {
|
||||
env.addCustomEqualityTester(tester);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the interface for adding custom expectation matchers
|
||||
*/
|
||||
jasmine.addMatchers = function(matchers) {
|
||||
return env.addMatchers(matchers);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose the mock interface for the JavaScript timeout functions
|
||||
*/
|
||||
jasmine.clock = function() {
|
||||
return env.clock;
|
||||
};
|
||||
|
||||
/**
|
||||
* ## 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.setParam("catch", !env.catchingExceptions()); },
|
||||
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;
|
||||
}
|
||||
|
||||
}());
|
160
node_modules/yamljs/test/lib/jasmine-2.0.0/console.js
generated
vendored
Normal file
160
node_modules/yamljs/test/lib/jasmine-2.0.0/console.js
generated
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
Copyright (c) 2008-2013 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'
|
||||
};
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
printNewline();
|
||||
var specCounts = specCount + " " + plural("spec", specCount) + ", " +
|
||||
failureCount + " " + plural("failure", failureCount);
|
||||
|
||||
if (pendingCount) {
|
||||
specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount);
|
||||
}
|
||||
|
||||
print(specCounts);
|
||||
|
||||
printNewline();
|
||||
var seconds = timer.elapsed() / 1000;
|
||||
print("Finished in " + seconds + " " + plural("second", seconds));
|
||||
|
||||
printNewline();
|
||||
|
||||
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'));
|
||||
}
|
||||
};
|
||||
|
||||
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.stack, 2));
|
||||
}
|
||||
|
||||
printNewline();
|
||||
}
|
||||
}
|
||||
|
||||
return ConsoleReporter;
|
||||
};
|
359
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine-html.js
generated
vendored
Normal file
359
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine-html.js
generated
vendored
Normal file
@ -0,0 +1,359 @@
|
||||
/*
|
||||
Copyright (c) 2008-2013 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() {},
|
||||
timer = options.timer || noopTimer,
|
||||
results = [],
|
||||
specsExecuted = 0,
|
||||
failureCount = 0,
|
||||
pendingSpecCount = 0,
|
||||
htmlReporterMain,
|
||||
symbols;
|
||||
|
||||
this.initialize = function() {
|
||||
htmlReporterMain = createDom("div", {className: "html-reporter"},
|
||||
createDom("div", {className: "banner"},
|
||||
createDom("span", {className: "title"}, "Jasmine"),
|
||||
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 (currentParent == topResults) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentParent = currentParent.parent;
|
||||
};
|
||||
|
||||
this.specStarted = function(result) {
|
||||
currentParent.addChild(result, "spec");
|
||||
};
|
||||
|
||||
var failures = [];
|
||||
this.specDone = function(result) {
|
||||
if (result.status != "disabled") {
|
||||
specsExecuted++;
|
||||
}
|
||||
|
||||
symbols.appendChild(createDom("li", {
|
||||
className: 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("input");
|
||||
|
||||
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 = "" + pluralize("spec", specsExecuted) + ", " + pluralize("failure", failureCount);
|
||||
if (pendingSpecCount) { statusBarMessage += ", " + pluralize("pending spec", pendingSpecCount); }
|
||||
|
||||
var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed");
|
||||
alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage));
|
||||
|
||||
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);
|
||||
}
|
||||
specListNode.appendChild(
|
||||
createDom("li", {
|
||||
className: resultNode.result.status,
|
||||
id: "spec-" + resultNode.result.id
|
||||
},
|
||||
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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(selector);
|
||||
}
|
||||
|
||||
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 "?spec=" + encodeURIComponent(result.fullName);
|
||||
}
|
||||
|
||||
function setMenuModeTo(mode) {
|
||||
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
|
||||
}
|
||||
}
|
||||
|
||||
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.setParam = function(key, value) {
|
||||
var paramMap = queryStringToParamMap();
|
||||
paramMap[key] = value;
|
||||
options.getWindowLocation().search = 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;
|
||||
};
|
55
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine.css
generated
vendored
Normal file
55
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine.css
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
.html-reporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
.html-reporter a { text-decoration: none; }
|
||||
.html-reporter a:hover { text-decoration: underline; }
|
||||
.html-reporter p, .html-reporter h1, .html-reporter h2, .html-reporter h3, .html-reporter h4, .html-reporter h5, .html-reporter h6 { margin: 0; line-height: 14px; }
|
||||
.html-reporter .banner, .html-reporter .symbol-summary, .html-reporter .summary, .html-reporter .result-message, .html-reporter .spec .description, .html-reporter .spec-detail .description, .html-reporter .alert .bar, .html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; }
|
||||
.html-reporter .banner .version { margin-left: 14px; }
|
||||
.html-reporter #jasmine_content { position: fixed; right: 100%; }
|
||||
.html-reporter .version { color: #aaaaaa; }
|
||||
.html-reporter .banner { margin-top: 14px; }
|
||||
.html-reporter .duration { color: #aaaaaa; float: right; }
|
||||
.html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
.html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; }
|
||||
.html-reporter .symbol-summary li.passed { font-size: 14px; }
|
||||
.html-reporter .symbol-summary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
.html-reporter .symbol-summary li.failed { line-height: 9px; }
|
||||
.html-reporter .symbol-summary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
.html-reporter .symbol-summary li.disabled { font-size: 14px; }
|
||||
.html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; }
|
||||
.html-reporter .symbol-summary li.pending { line-height: 17px; }
|
||||
.html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; }
|
||||
.html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
.html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
.html-reporter .bar.failed { background-color: #b03911; }
|
||||
.html-reporter .bar.passed { background-color: #a6b779; }
|
||||
.html-reporter .bar.skipped { background-color: #bababa; }
|
||||
.html-reporter .bar.menu { background-color: #fff; color: #aaaaaa; }
|
||||
.html-reporter .bar.menu a { color: #333333; }
|
||||
.html-reporter .bar a { color: white; }
|
||||
.html-reporter.spec-list .bar.menu.failure-list, .html-reporter.spec-list .results .failures { display: none; }
|
||||
.html-reporter.failure-list .bar.menu.spec-list, .html-reporter.failure-list .summary { display: none; }
|
||||
.html-reporter .running-alert { background-color: #666666; }
|
||||
.html-reporter .results { margin-top: 14px; }
|
||||
.html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
.html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
.html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
.html-reporter.showDetails .summary { display: none; }
|
||||
.html-reporter.showDetails #details { display: block; }
|
||||
.html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
.html-reporter .summary { margin-top: 14px; }
|
||||
.html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; }
|
||||
.html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; }
|
||||
.html-reporter .summary li.passed a { color: #5e7d00; }
|
||||
.html-reporter .summary li.failed a { color: #b03911; }
|
||||
.html-reporter .summary li.pending a { color: #ba9d37; }
|
||||
.html-reporter .description + .suite { margin-top: 0; }
|
||||
.html-reporter .suite { margin-top: 14px; }
|
||||
.html-reporter .suite a { color: #333333; }
|
||||
.html-reporter .failures .spec-detail { margin-bottom: 28px; }
|
||||
.html-reporter .failures .spec-detail .description { background-color: #b03911; }
|
||||
.html-reporter .failures .spec-detail .description a { color: white; }
|
||||
.html-reporter .result-message { padding-top: 14px; color: #333333; white-space: pre; }
|
||||
.html-reporter .result-message span.result { display: block; }
|
||||
.html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
2402
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine.js
generated
vendored
Normal file
2402
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine_favicon.png
generated
vendored
Normal file
BIN
node_modules/yamljs/test/lib/jasmine-2.0.0/jasmine_favicon.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
1474
node_modules/yamljs/test/spec/YamlSpec.coffee
generated
vendored
Normal file
1474
node_modules/yamljs/test/spec/YamlSpec.coffee
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
764
node_modules/yamljs/test/spec/YamlSpec.js
generated
vendored
Normal file
764
node_modules/yamljs/test/spec/YamlSpec.js
generated
vendored
Normal file
@ -0,0 +1,764 @@
|
||||
// Generated by CoffeeScript 1.12.4
|
||||
var YAML, examplePath, ref, url;
|
||||
|
||||
if (typeof YAML === "undefined" || YAML === null) {
|
||||
YAML = require('../../src/Yaml');
|
||||
}
|
||||
|
||||
describe('Parsed YAML Collections', function() {
|
||||
it('can be simple sequence', function() {
|
||||
return expect(YAML.parse("- apple\n- banana\n- carrot")).toEqual(['apple', 'banana', 'carrot']);
|
||||
});
|
||||
it('can be nested sequences', function() {
|
||||
return expect(YAML.parse("-\n - foo\n - bar\n - baz")).toEqual([['foo', 'bar', 'baz']]);
|
||||
});
|
||||
it('can be mixed sequences', function() {
|
||||
return expect(YAML.parse("- apple\n-\n - foo\n - bar\n - x123\n- banana\n- carrot")).toEqual(['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot']);
|
||||
});
|
||||
it('can be deeply nested sequences', function() {
|
||||
return expect(YAML.parse("-\n -\n - uno\n - dos")).toEqual([[['uno', 'dos']]]);
|
||||
});
|
||||
it('can be simple mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar: stuff")).toEqual({
|
||||
foo: 'whatever',
|
||||
bar: 'stuff'
|
||||
});
|
||||
});
|
||||
it('can be sequence in a mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n - uno\n - dos")).toEqual({
|
||||
foo: 'whatever',
|
||||
bar: ['uno', 'dos']
|
||||
});
|
||||
});
|
||||
it('can be nested mappings', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n fruit: apple\n name: steve\n sport: baseball")).toEqual({
|
||||
foo: 'whatever',
|
||||
bar: {
|
||||
fruit: 'apple',
|
||||
name: 'steve',
|
||||
sport: 'baseball'
|
||||
}
|
||||
});
|
||||
});
|
||||
it('can be mixed mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n -\n fruit: apple\n name: steve\n sport: baseball\n - more\n -\n python: rocks\n perl: papers\n ruby: scissorses")).toEqual({
|
||||
foo: 'whatever',
|
||||
bar: [
|
||||
{
|
||||
fruit: 'apple',
|
||||
name: 'steve',
|
||||
sport: 'baseball'
|
||||
}, 'more', {
|
||||
python: 'rocks',
|
||||
perl: 'papers',
|
||||
ruby: 'scissorses'
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
it('can have mapping-in-sequence shortcut', function() {
|
||||
return expect(YAML.parse("- work on YAML.py:\n - work on Store")).toEqual([
|
||||
{
|
||||
'work on YAML.py': ['work on Store']
|
||||
}
|
||||
]);
|
||||
});
|
||||
it('can have unindented sequence-in-mapping shortcut', function() {
|
||||
return expect(YAML.parse("allow:\n- 'localhost'\n- '%.sourceforge.net'\n- '%.freepan.org'")).toEqual({
|
||||
allow: ['localhost', '%.sourceforge.net', '%.freepan.org']
|
||||
});
|
||||
});
|
||||
it('can merge key', function() {
|
||||
return expect(YAML.parse("mapping:\n name: Joe\n job: Accountant\n <<:\n age: 38")).toEqual({
|
||||
mapping: {
|
||||
name: 'Joe',
|
||||
job: 'Accountant',
|
||||
age: 38
|
||||
}
|
||||
});
|
||||
});
|
||||
return it('can ignore trailing empty lines for smallest indent', function() {
|
||||
return expect(YAML.parse(" trailing: empty lines\n")).toEqual({
|
||||
trailing: 'empty lines'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Inline Collections', function() {
|
||||
it('can be simple inline array', function() {
|
||||
return expect(YAML.parse("---\nseq: [ a, b, c ]")).toEqual({
|
||||
seq: ['a', 'b', 'c']
|
||||
});
|
||||
});
|
||||
it('can be simple inline hash', function() {
|
||||
return expect(YAML.parse("---\nhash: { name: Steve, foo: bar }")).toEqual({
|
||||
hash: {
|
||||
name: 'Steve',
|
||||
foo: 'bar'
|
||||
}
|
||||
});
|
||||
});
|
||||
it('can be nested inline hash', function() {
|
||||
return expect(YAML.parse("---\nhash: { val1: \"string\", val2: { v2k1: \"v2k1v\" } }")).toEqual({
|
||||
hash: {
|
||||
val1: 'string',
|
||||
val2: {
|
||||
v2k1: 'v2k1v'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
return it('can be multi-line inline collections', function() {
|
||||
return expect(YAML.parse("languages: [ Ruby,\n Perl,\n Python ]\nwebsites: { YAML: yaml.org,\n Ruby: ruby-lang.org,\n Python: python.org,\n Perl: use.perl.org }")).toEqual({
|
||||
languages: ['Ruby', 'Perl', 'Python'],
|
||||
websites: {
|
||||
YAML: 'yaml.org',
|
||||
Ruby: 'ruby-lang.org',
|
||||
Python: 'python.org',
|
||||
Perl: 'use.perl.org'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Basic Types', function() {
|
||||
it('can be strings', function() {
|
||||
return expect(YAML.parse("---\nString")).toEqual('String');
|
||||
});
|
||||
it('can be double-quoted strings with backslashes', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\\\ inside\"")).toEqual({
|
||||
str: 'string with \\ inside'
|
||||
});
|
||||
});
|
||||
it('can be single-quoted strings with backslashes', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\\\ inside'")).toEqual({
|
||||
str: 'string with \\\\ inside'
|
||||
});
|
||||
});
|
||||
it('can be double-quoted strings with line breaks', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\n inside\"")).toEqual({
|
||||
str: 'string with \n inside'
|
||||
});
|
||||
});
|
||||
it('can be single-quoted strings with escaped line breaks', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\n inside'")).toEqual({
|
||||
str: 'string with \\n inside'
|
||||
});
|
||||
});
|
||||
it('can be double-quoted strings with line breaks and backslashes', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\n inside and \\\\ also\"")).toEqual({
|
||||
str: 'string with \n inside and \\ also'
|
||||
});
|
||||
});
|
||||
it('can be single-quoted strings with line breaks and backslashes', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\n inside and \\\\ also'")).toEqual({
|
||||
str: 'string with \\n inside and \\\\ also'
|
||||
});
|
||||
});
|
||||
it('can have string characters in sequences', function() {
|
||||
return expect(YAML.parse("- What's Yaml?\n- It's for writing data structures in plain text.\n- And?\n- And what? That's not good enough for you?\n- No, I mean, \"And what about Yaml?\"\n- Oh, oh yeah. Uh.. Yaml for JavaScript.")).toEqual(["What's Yaml?", "It's for writing data structures in plain text.", "And?", "And what? That's not good enough for you?", "No, I mean, \"And what about Yaml?\"", "Oh, oh yeah. Uh.. Yaml for JavaScript."]);
|
||||
});
|
||||
it('can have indicators in strings', function() {
|
||||
return expect(YAML.parse("the colon followed by space is an indicator: but is a string:right here\nsame for the pound sign: here we have it#in a string\nthe comma can, honestly, be used in most cases: [ but not in, inline collections ]")).toEqual({
|
||||
'the colon followed by space is an indicator': 'but is a string:right here',
|
||||
'same for the pound sign': 'here we have it#in a string',
|
||||
'the comma can, honestly, be used in most cases': ['but not in', 'inline collections']
|
||||
});
|
||||
});
|
||||
it('can force strings', function() {
|
||||
return expect(YAML.parse("date string: !str 2001-08-01\nnumber string: !str 192\ndate string 2: !!str 2001-08-01\nnumber string 2: !!str 192")).toEqual({
|
||||
'date string': '2001-08-01',
|
||||
'number string': '192',
|
||||
'date string 2': '2001-08-01',
|
||||
'number string 2': '192'
|
||||
});
|
||||
});
|
||||
it('can be single-quoted strings', function() {
|
||||
return expect(YAML.parse("all my favorite symbols: '#:!/%.)'\na few i hate: '&(*'\nwhy do i hate them?: 'it''s very hard to explain'")).toEqual({
|
||||
'all my favorite symbols': '#:!/%.)',
|
||||
'a few i hate': '&(*',
|
||||
'why do i hate them?': 'it\'s very hard to explain'
|
||||
});
|
||||
});
|
||||
it('can be double-quoted strings', function() {
|
||||
return expect(YAML.parse("i know where i want my line breaks: \"one here\\nand another here\\n\"")).toEqual({
|
||||
'i know where i want my line breaks': "one here\nand another here\n"
|
||||
});
|
||||
});
|
||||
it('can be null', function() {
|
||||
return expect(YAML.parse("name: Mr. Show\nhosted by: Bob and David\ndate of next season: ~")).toEqual({
|
||||
'name': 'Mr. Show',
|
||||
'hosted by': 'Bob and David',
|
||||
'date of next season': null
|
||||
});
|
||||
});
|
||||
it('can be boolean', function() {
|
||||
return expect(YAML.parse("Is Gus a Liar?: true\nDo I rely on Gus for Sustenance?: false")).toEqual({
|
||||
'Is Gus a Liar?': true,
|
||||
'Do I rely on Gus for Sustenance?': false
|
||||
});
|
||||
});
|
||||
it('can be integers', function() {
|
||||
return expect(YAML.parse("zero: 0\nsimple: 12\none-thousand: 1,000\nnegative one-thousand: -1,000")).toEqual({
|
||||
'zero': 0,
|
||||
'simple': 12,
|
||||
'one-thousand': 1000,
|
||||
'negative one-thousand': -1000
|
||||
});
|
||||
});
|
||||
it('can be integers as map keys', function() {
|
||||
return expect(YAML.parse("1: one\n2: two\n3: three")).toEqual({
|
||||
1: 'one',
|
||||
2: 'two',
|
||||
3: 'three'
|
||||
});
|
||||
});
|
||||
it('can be floats', function() {
|
||||
return expect(YAML.parse("a simple float: 2.00\nlarger float: 1,000.09\nscientific notation: 1.00009e+3")).toEqual({
|
||||
'a simple float': 2.0,
|
||||
'larger float': 1000.09,
|
||||
'scientific notation': 1000.09
|
||||
});
|
||||
});
|
||||
it('can be time', function() {
|
||||
var iso8601Date, spaceSeparatedDate, withDatesToTime;
|
||||
iso8601Date = new Date(Date.UTC(2001, 12 - 1, 14, 21, 59, 43, 10));
|
||||
iso8601Date.setTime(iso8601Date.getTime() - 5 * 3600 * 1000);
|
||||
spaceSeparatedDate = new Date(Date.UTC(2001, 12 - 1, 14, 21, 59, 43, 10));
|
||||
spaceSeparatedDate.setTime(spaceSeparatedDate.getTime() + 5 * 3600 * 1000);
|
||||
withDatesToTime = function(input) {
|
||||
var key, res, val;
|
||||
res = {};
|
||||
for (key in input) {
|
||||
val = input[key];
|
||||
res[key] = val.getTime();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return expect(withDatesToTime(YAML.parse("iso8601: 2001-12-14t21:59:43.010+05:00\nspace separated: 2001-12-14 21:59:43.010 -05:00"))).toEqual(withDatesToTime({
|
||||
'iso8601': iso8601Date,
|
||||
'space separated': spaceSeparatedDate
|
||||
}));
|
||||
});
|
||||
return it('can be date', function() {
|
||||
var aDate, withDatesToTime;
|
||||
aDate = new Date(Date.UTC(1976, 7 - 1, 31, 0, 0, 0, 0));
|
||||
withDatesToTime = function(input) {
|
||||
var key, res, val;
|
||||
return input;
|
||||
res = {};
|
||||
for (key in input) {
|
||||
val = input[key];
|
||||
res[key] = val.getTime();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return expect(withDatesToTime(YAML.parse("date: 1976-07-31"))).toEqual(withDatesToTime({
|
||||
'date': aDate
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Blocks', function() {
|
||||
it('can be single ending newline', function() {
|
||||
return expect(YAML.parse("---\nthis: |\n Foo\n Bar")).toEqual({
|
||||
'this': "Foo\nBar\n"
|
||||
});
|
||||
});
|
||||
it('can be single ending newline with \'+\' indicator', function() {
|
||||
return expect(YAML.parse("normal: |\n extra new lines not kept\n\npreserving: |+\n extra new lines are kept\n\n\ndummy: value")).toEqual({
|
||||
'normal': "extra new lines not kept\n",
|
||||
'preserving': "extra new lines are kept\n\n\n",
|
||||
'dummy': 'value'
|
||||
});
|
||||
});
|
||||
it('can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', function() {
|
||||
return expect(YAML.parse("clipped: |\n This has one newline.\n\n\n\nsame as \"clipped\" above: \"This has one newline.\\n\"\n\nstripped: |-\n This has no newline.\n\n\n\nsame as \"stripped\" above: \"This has no newline.\"\n\nkept: |+\n This has four newlines.\n\n\n\nsame as \"kept\" above: \"This has four newlines.\\n\\n\\n\\n\"")).toEqual({
|
||||
'clipped': "This has one newline.\n",
|
||||
'same as "clipped" above': "This has one newline.\n",
|
||||
'stripped': 'This has no newline.',
|
||||
'same as "stripped" above': 'This has no newline.',
|
||||
'kept': "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above': "This has four newlines.\n\n\n\n"
|
||||
});
|
||||
});
|
||||
it('can be folded block in a sequence', function() {
|
||||
return expect(YAML.parse("---\n- apple\n- banana\n- >\n can't you see\n the beauty of yaml?\n hmm\n- dog")).toEqual(['apple', 'banana', "can't you see the beauty of yaml? hmm\n", 'dog']);
|
||||
});
|
||||
it('can be folded block as a mapping value', function() {
|
||||
return expect(YAML.parse("---\nquote: >\n Mark McGwire's\n year was crippled\n by a knee injury.\nsource: espn")).toEqual({
|
||||
'quote': "Mark McGwire's year was crippled by a knee injury.\n",
|
||||
'source': 'espn'
|
||||
});
|
||||
});
|
||||
it('can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', function() {
|
||||
return expect(YAML.parse("clipped: >\n This has one newline.\n\n\n\nsame as \"clipped\" above: \"This has one newline.\\n\"\n\nstripped: >-\n This has no newline.\n\n\n\nsame as \"stripped\" above: \"This has no newline.\"\n\nkept: >+\n This has four newlines.\n\n\n\nsame as \"kept\" above: \"This has four newlines.\\n\\n\\n\\n\"")).toEqual({
|
||||
'clipped': "This has one newline.\n",
|
||||
'same as "clipped" above': "This has one newline.\n",
|
||||
'stripped': 'This has no newline.',
|
||||
'same as "stripped" above': 'This has no newline.',
|
||||
'kept': "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above': "This has four newlines.\n\n\n\n"
|
||||
});
|
||||
});
|
||||
return it('can be the whole document as intented block', function() {
|
||||
return expect(YAML.parse("---\n foo: \"bar\"\n baz:\n - \"qux\"\n - \"quxx\"\n corge: null")).toEqual({
|
||||
'foo': "bar",
|
||||
'baz': ['qux', 'quxx'],
|
||||
'corge': null
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Comments', function() {
|
||||
it('can begin the document', function() {
|
||||
return expect(YAML.parse("# This is a comment\nhello: world")).toEqual({
|
||||
hello: 'world'
|
||||
});
|
||||
});
|
||||
it('can be less indented in mapping', function() {
|
||||
return expect(YAML.parse("parts:\n a: 'b'\n # normally indented comment\n c: 'd'\n# less indented comment\n e: 'f'")).toEqual({
|
||||
parts: {
|
||||
a: 'b',
|
||||
c: 'd',
|
||||
e: 'f'
|
||||
}
|
||||
});
|
||||
});
|
||||
it('can be less indented in sequence', function() {
|
||||
return expect(YAML.parse("list-header:\n - item1\n# - item2\n - item3\n # - item4")).toEqual({
|
||||
'list-header': ['item1', 'item3']
|
||||
});
|
||||
});
|
||||
it('can finish a line', function() {
|
||||
return expect(YAML.parse("hello: world # This is a comment")).toEqual({
|
||||
hello: 'world'
|
||||
});
|
||||
});
|
||||
return it('can end the document', function() {
|
||||
return expect(YAML.parse("hello: world\n# This is a comment")).toEqual({
|
||||
hello: 'world'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Aliases and Anchors', function() {
|
||||
it('can be simple alias', function() {
|
||||
return expect(YAML.parse("- &showell Steve\n- Clark\n- Brian\n- Oren\n- *showell")).toEqual(['Steve', 'Clark', 'Brian', 'Oren', 'Steve']);
|
||||
});
|
||||
return it('can be alias of a mapping', function() {
|
||||
return expect(YAML.parse("- &hello\n Meat: pork\n Starch: potato\n- banana\n- *hello")).toEqual([
|
||||
{
|
||||
Meat: 'pork',
|
||||
Starch: 'potato'
|
||||
}, 'banana', {
|
||||
Meat: 'pork',
|
||||
Starch: 'potato'
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Parsed YAML Documents', function() {
|
||||
it('can have YAML header', function() {
|
||||
return expect(YAML.parse("--- %YAML:1.0\nfoo: 1\nbar: 2")).toEqual({
|
||||
foo: 1,
|
||||
bar: 2
|
||||
});
|
||||
});
|
||||
it('can have leading document separator', function() {
|
||||
return expect(YAML.parse("---\n- foo: 1\n bar: 2")).toEqual([
|
||||
{
|
||||
foo: 1,
|
||||
bar: 2
|
||||
}
|
||||
]);
|
||||
});
|
||||
return it('can have multiple document separators in block', function() {
|
||||
return expect(YAML.parse("foo: |\n ---\n foo: bar\n ---\n yo: baz\nbar: |\n fooness")).toEqual({
|
||||
foo: "---\nfoo: bar\n---\nyo: baz\n",
|
||||
bar: "fooness\n"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Collections', function() {
|
||||
it('can be simple sequence', function() {
|
||||
return expect(YAML.parse("- apple\n- banana\n- carrot")).toEqual(YAML.parse(YAML.dump(['apple', 'banana', 'carrot'])));
|
||||
});
|
||||
it('can be nested sequences', function() {
|
||||
return expect(YAML.parse("-\n - foo\n - bar\n - baz")).toEqual(YAML.parse(YAML.dump([['foo', 'bar', 'baz']])));
|
||||
});
|
||||
it('can be mixed sequences', function() {
|
||||
return expect(YAML.parse("- apple\n-\n - foo\n - bar\n - x123\n- banana\n- carrot")).toEqual(YAML.parse(YAML.dump(['apple', ['foo', 'bar', 'x123'], 'banana', 'carrot'])));
|
||||
});
|
||||
it('can be deeply nested sequences', function() {
|
||||
return expect(YAML.parse("-\n -\n - uno\n - dos")).toEqual(YAML.parse(YAML.dump([[['uno', 'dos']]])));
|
||||
});
|
||||
it('can be simple mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar: stuff")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: 'whatever',
|
||||
bar: 'stuff'
|
||||
})));
|
||||
});
|
||||
it('can be sequence in a mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n - uno\n - dos")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: 'whatever',
|
||||
bar: ['uno', 'dos']
|
||||
})));
|
||||
});
|
||||
it('can be nested mappings', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n fruit: apple\n name: steve\n sport: baseball")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: 'whatever',
|
||||
bar: {
|
||||
fruit: 'apple',
|
||||
name: 'steve',
|
||||
sport: 'baseball'
|
||||
}
|
||||
})));
|
||||
});
|
||||
it('can be mixed mapping', function() {
|
||||
return expect(YAML.parse("foo: whatever\nbar:\n -\n fruit: apple\n name: steve\n sport: baseball\n - more\n -\n python: rocks\n perl: papers\n ruby: scissorses")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: 'whatever',
|
||||
bar: [
|
||||
{
|
||||
fruit: 'apple',
|
||||
name: 'steve',
|
||||
sport: 'baseball'
|
||||
}, 'more', {
|
||||
python: 'rocks',
|
||||
perl: 'papers',
|
||||
ruby: 'scissorses'
|
||||
}
|
||||
]
|
||||
})));
|
||||
});
|
||||
it('can have mapping-in-sequence shortcut', function() {
|
||||
return expect(YAML.parse("- work on YAML.py:\n - work on Store")).toEqual(YAML.parse(YAML.dump([
|
||||
{
|
||||
'work on YAML.py': ['work on Store']
|
||||
}
|
||||
])));
|
||||
});
|
||||
it('can have unindented sequence-in-mapping shortcut', function() {
|
||||
return expect(YAML.parse("allow:\n- 'localhost'\n- '%.sourceforge.net'\n- '%.freepan.org'")).toEqual(YAML.parse(YAML.dump({
|
||||
allow: ['localhost', '%.sourceforge.net', '%.freepan.org']
|
||||
})));
|
||||
});
|
||||
return it('can merge key', function() {
|
||||
return expect(YAML.parse("mapping:\n name: Joe\n job: Accountant\n <<:\n age: 38")).toEqual(YAML.parse(YAML.dump({
|
||||
mapping: {
|
||||
name: 'Joe',
|
||||
job: 'Accountant',
|
||||
age: 38
|
||||
}
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Inline Collections', function() {
|
||||
it('can be simple inline array', function() {
|
||||
return expect(YAML.parse("---\nseq: [ a, b, c ]")).toEqual(YAML.parse(YAML.dump({
|
||||
seq: ['a', 'b', 'c']
|
||||
})));
|
||||
});
|
||||
it('can be simple inline hash', function() {
|
||||
return expect(YAML.parse("---\nhash: { name: Steve, foo: bar }")).toEqual(YAML.parse(YAML.dump({
|
||||
hash: {
|
||||
name: 'Steve',
|
||||
foo: 'bar'
|
||||
}
|
||||
})));
|
||||
});
|
||||
it('can be multi-line inline collections', function() {
|
||||
return expect(YAML.parse("languages: [ Ruby,\n Perl,\n Python ]\nwebsites: { YAML: yaml.org,\n Ruby: ruby-lang.org,\n Python: python.org,\n Perl: use.perl.org }")).toEqual(YAML.parse(YAML.dump({
|
||||
languages: ['Ruby', 'Perl', 'Python'],
|
||||
websites: {
|
||||
YAML: 'yaml.org',
|
||||
Ruby: 'ruby-lang.org',
|
||||
Python: 'python.org',
|
||||
Perl: 'use.perl.org'
|
||||
}
|
||||
})));
|
||||
});
|
||||
it('can be dumped empty sequences in mappings', function() {
|
||||
return expect(YAML.parse(YAML.dump({
|
||||
key: []
|
||||
}))).toEqual({
|
||||
key: []
|
||||
});
|
||||
});
|
||||
return it('can be dumpted empty inline collections', function() {
|
||||
return expect(YAML.parse(YAML.dump({
|
||||
key: {}
|
||||
}))).toEqual({
|
||||
key: {}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Basic Types', function() {
|
||||
it('can be strings', function() {
|
||||
return expect(YAML.parse("---\nString")).toEqual(YAML.parse(YAML.dump('String')));
|
||||
});
|
||||
it('can be double-quoted strings with backslashes', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\\\ inside\"")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \\ inside'
|
||||
})));
|
||||
});
|
||||
it('can be single-quoted strings with backslashes', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\\\ inside'")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \\\\ inside'
|
||||
})));
|
||||
});
|
||||
it('can be double-quoted strings with line breaks', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\n inside\"")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \n inside'
|
||||
})));
|
||||
});
|
||||
it('can be double-quoted strings with line breaks and backslashes', function() {
|
||||
return expect(YAML.parse("str:\n \"string with \\n inside and \\\\ also\"")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \n inside and \\ also'
|
||||
})));
|
||||
});
|
||||
it('can be single-quoted strings with line breaks and backslashes', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\n inside and \\\\ also'")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \\n inside and \\\\ also'
|
||||
})));
|
||||
});
|
||||
it('can be single-quoted strings with escaped line breaks', function() {
|
||||
return expect(YAML.parse("str:\n 'string with \\n inside'")).toEqual(YAML.parse(YAML.dump({
|
||||
str: 'string with \\n inside'
|
||||
})));
|
||||
});
|
||||
it('can have string characters in sequences', function() {
|
||||
return expect(YAML.parse("- What's Yaml?\n- It's for writing data structures in plain text.\n- And?\n- And what? That's not good enough for you?\n- No, I mean, \"And what about Yaml?\"\n- Oh, oh yeah. Uh.. Yaml for JavaScript.")).toEqual(YAML.parse(YAML.dump(["What's Yaml?", "It's for writing data structures in plain text.", "And?", "And what? That's not good enough for you?", "No, I mean, \"And what about Yaml?\"", "Oh, oh yeah. Uh.. Yaml for JavaScript."])));
|
||||
});
|
||||
it('can have indicators in strings', function() {
|
||||
return expect(YAML.parse("the colon followed by space is an indicator: but is a string:right here\nsame for the pound sign: here we have it#in a string\nthe comma can, honestly, be used in most cases: [ but not in, inline collections ]")).toEqual(YAML.parse(YAML.dump({
|
||||
'the colon followed by space is an indicator': 'but is a string:right here',
|
||||
'same for the pound sign': 'here we have it#in a string',
|
||||
'the comma can, honestly, be used in most cases': ['but not in', 'inline collections']
|
||||
})));
|
||||
});
|
||||
it('can force strings', function() {
|
||||
return expect(YAML.parse("date string: !str 2001-08-01\nnumber string: !str 192\ndate string 2: !!str 2001-08-01\nnumber string 2: !!str 192")).toEqual(YAML.parse(YAML.dump({
|
||||
'date string': '2001-08-01',
|
||||
'number string': '192',
|
||||
'date string 2': '2001-08-01',
|
||||
'number string 2': '192'
|
||||
})));
|
||||
});
|
||||
it('can be single-quoted strings', function() {
|
||||
return expect(YAML.parse("all my favorite symbols: '#:!/%.)'\na few i hate: '&(*'\nwhy do i hate them?: 'it''s very hard to explain'")).toEqual(YAML.parse(YAML.dump({
|
||||
'all my favorite symbols': '#:!/%.)',
|
||||
'a few i hate': '&(*',
|
||||
'why do i hate them?': 'it\'s very hard to explain'
|
||||
})));
|
||||
});
|
||||
it('can be double-quoted strings', function() {
|
||||
return expect(YAML.parse("i know where i want my line breaks: \"one here\\nand another here\\n\"")).toEqual(YAML.parse(YAML.dump({
|
||||
'i know where i want my line breaks': "one here\nand another here\n"
|
||||
})));
|
||||
});
|
||||
it('can be null', function() {
|
||||
return expect(YAML.parse("name: Mr. Show\nhosted by: Bob and David\ndate of next season: ~")).toEqual(YAML.parse(YAML.dump({
|
||||
'name': 'Mr. Show',
|
||||
'hosted by': 'Bob and David',
|
||||
'date of next season': null
|
||||
})));
|
||||
});
|
||||
it('can be boolean', function() {
|
||||
return expect(YAML.parse("Is Gus a Liar?: true\nDo I rely on Gus for Sustenance?: false")).toEqual(YAML.parse(YAML.dump({
|
||||
'Is Gus a Liar?': true,
|
||||
'Do I rely on Gus for Sustenance?': false
|
||||
})));
|
||||
});
|
||||
it('can be integers', function() {
|
||||
return expect(YAML.parse("zero: 0\nsimple: 12\none-thousand: 1,000\nnegative one-thousand: -1,000")).toEqual(YAML.parse(YAML.dump({
|
||||
'zero': 0,
|
||||
'simple': 12,
|
||||
'one-thousand': 1000,
|
||||
'negative one-thousand': -1000
|
||||
})));
|
||||
});
|
||||
it('can be integers as map keys', function() {
|
||||
return expect(YAML.parse("1: one\n2: two\n3: three")).toEqual(YAML.parse(YAML.dump({
|
||||
1: 'one',
|
||||
2: 'two',
|
||||
3: 'three'
|
||||
})));
|
||||
});
|
||||
it('can be floats', function() {
|
||||
return expect(YAML.parse("a simple float: 2.00\nlarger float: 1,000.09\nscientific notation: 1.00009e+3")).toEqual(YAML.parse(YAML.dump({
|
||||
'a simple float': 2.0,
|
||||
'larger float': 1000.09,
|
||||
'scientific notation': 1000.09
|
||||
})));
|
||||
});
|
||||
it('can be time', function() {
|
||||
var iso8601Date, spaceSeparatedDate, withDatesToTime;
|
||||
iso8601Date = new Date(Date.UTC(2001, 12 - 1, 14, 21, 59, 43, 10));
|
||||
iso8601Date.setTime(iso8601Date.getTime() + 5 * 3600 * 1000);
|
||||
spaceSeparatedDate = new Date(Date.UTC(2001, 12 - 1, 14, 21, 59, 43, 10));
|
||||
spaceSeparatedDate.setTime(spaceSeparatedDate.getTime() - 5 * 3600 * 1000);
|
||||
withDatesToTime = function(input) {
|
||||
var key, res, val;
|
||||
res = {};
|
||||
for (key in input) {
|
||||
val = input[key];
|
||||
res[key] = val.getTime();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return expect(withDatesToTime(YAML.parse("iso8601: 2001-12-14t21:59:43.010-05:00\nspace separated: 2001-12-14 21:59:43.010 +05:00"))).toEqual(YAML.parse(YAML.dump(withDatesToTime({
|
||||
'iso8601': iso8601Date,
|
||||
'space separated': spaceSeparatedDate
|
||||
}))));
|
||||
});
|
||||
return it('can be date', function() {
|
||||
var aDate, withDatesToTime;
|
||||
aDate = new Date(Date.UTC(1976, 7 - 1, 31, 0, 0, 0, 0));
|
||||
withDatesToTime = function(input) {
|
||||
var key, res, val;
|
||||
return input;
|
||||
res = {};
|
||||
for (key in input) {
|
||||
val = input[key];
|
||||
res[key] = val.getTime();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
return expect(withDatesToTime(YAML.parse("date: 1976-07-31"))).toEqual(YAML.parse(YAML.dump(withDatesToTime({
|
||||
'date': aDate
|
||||
}))));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Blocks', function() {
|
||||
it('can be single ending newline', function() {
|
||||
return expect(YAML.parse("---\nthis: |\n Foo\n Bar")).toEqual(YAML.parse(YAML.dump({
|
||||
'this': "Foo\nBar\n"
|
||||
})));
|
||||
});
|
||||
it('can be single ending newline with \'+\' indicator', function() {
|
||||
return expect(YAML.parse("normal: |\n extra new lines not kept\n\npreserving: |+\n extra new lines are kept\n\n\ndummy: value")).toEqual(YAML.parse(YAML.dump({
|
||||
'normal': "extra new lines not kept\n",
|
||||
'preserving': "extra new lines are kept\n\n\n",
|
||||
'dummy': 'value'
|
||||
})));
|
||||
});
|
||||
it('can be multi-line block handling trailing newlines in function of \'+\', \'-\' indicators', function() {
|
||||
return expect(YAML.parse("clipped: |\n This has one newline.\n\n\n\nsame as \"clipped\" above: \"This has one newline.\\n\"\n\nstripped: |-\n This has no newline.\n\n\n\nsame as \"stripped\" above: \"This has no newline.\"\n\nkept: |+\n This has four newlines.\n\n\n\nsame as \"kept\" above: \"This has four newlines.\\n\\n\\n\\n\"")).toEqual(YAML.parse(YAML.dump({
|
||||
'clipped': "This has one newline.\n",
|
||||
'same as "clipped" above': "This has one newline.\n",
|
||||
'stripped': 'This has no newline.',
|
||||
'same as "stripped" above': 'This has no newline.',
|
||||
'kept': "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above': "This has four newlines.\n\n\n\n"
|
||||
})));
|
||||
});
|
||||
it('can be folded block in a sequence', function() {
|
||||
return expect(YAML.parse("---\n- apple\n- banana\n- >\n can't you see\n the beauty of yaml?\n hmm\n- dog")).toEqual(YAML.parse(YAML.dump(['apple', 'banana', "can't you see the beauty of yaml? hmm\n", 'dog'])));
|
||||
});
|
||||
it('can be folded block as a mapping value', function() {
|
||||
return expect(YAML.parse("---\nquote: >\n Mark McGwire's\n year was crippled\n by a knee injury.\nsource: espn")).toEqual(YAML.parse(YAML.dump({
|
||||
'quote': "Mark McGwire's year was crippled by a knee injury.\n",
|
||||
'source': 'espn'
|
||||
})));
|
||||
});
|
||||
return it('can be folded block handling trailing newlines in function of \'+\', \'-\' indicators', function() {
|
||||
return expect(YAML.parse("clipped: >\n This has one newline.\n\n\n\nsame as \"clipped\" above: \"This has one newline.\\n\"\n\nstripped: >-\n This has no newline.\n\n\n\nsame as \"stripped\" above: \"This has no newline.\"\n\nkept: >+\n This has four newlines.\n\n\n\nsame as \"kept\" above: \"This has four newlines.\\n\\n\\n\\n\"")).toEqual(YAML.parse(YAML.dump({
|
||||
'clipped': "This has one newline.\n",
|
||||
'same as "clipped" above': "This has one newline.\n",
|
||||
'stripped': 'This has no newline.',
|
||||
'same as "stripped" above': 'This has no newline.',
|
||||
'kept': "This has four newlines.\n\n\n\n",
|
||||
'same as "kept" above': "This has four newlines.\n\n\n\n"
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Comments', function() {
|
||||
it('can begin the document', function() {
|
||||
return expect(YAML.parse("# This is a comment\nhello: world")).toEqual(YAML.parse(YAML.dump({
|
||||
hello: 'world'
|
||||
})));
|
||||
});
|
||||
it('can finish a line', function() {
|
||||
return expect(YAML.parse("hello: world # This is a comment")).toEqual(YAML.parse(YAML.dump({
|
||||
hello: 'world'
|
||||
})));
|
||||
});
|
||||
return it('can end the document', function() {
|
||||
return expect(YAML.parse("hello: world\n# This is a comment")).toEqual(YAML.parse(YAML.dump({
|
||||
hello: 'world'
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Aliases and Anchors', function() {
|
||||
it('can be simple alias', function() {
|
||||
return expect(YAML.parse("- &showell Steve\n- Clark\n- Brian\n- Oren\n- *showell")).toEqual(YAML.parse(YAML.dump(['Steve', 'Clark', 'Brian', 'Oren', 'Steve'])));
|
||||
});
|
||||
return it('can be alias of a mapping', function() {
|
||||
return expect(YAML.parse("- &hello\n Meat: pork\n Starch: potato\n- banana\n- *hello")).toEqual(YAML.parse(YAML.dump([
|
||||
{
|
||||
Meat: 'pork',
|
||||
Starch: 'potato'
|
||||
}, 'banana', {
|
||||
Meat: 'pork',
|
||||
Starch: 'potato'
|
||||
}
|
||||
])));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Dumped YAML Documents', function() {
|
||||
it('can have YAML header', function() {
|
||||
return expect(YAML.parse("--- %YAML:1.0\nfoo: 1\nbar: 2")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: 1,
|
||||
bar: 2
|
||||
})));
|
||||
});
|
||||
it('can have leading document separator', function() {
|
||||
return expect(YAML.parse("---\n- foo: 1\n bar: 2")).toEqual(YAML.parse(YAML.dump([
|
||||
{
|
||||
foo: 1,
|
||||
bar: 2
|
||||
}
|
||||
])));
|
||||
});
|
||||
return it('can have multiple document separators in block', function() {
|
||||
return expect(YAML.parse("foo: |\n ---\n foo: bar\n ---\n yo: baz\nbar: |\n fooness")).toEqual(YAML.parse(YAML.dump({
|
||||
foo: "---\nfoo: bar\n---\nyo: baz\n",
|
||||
bar: "fooness\n"
|
||||
})));
|
||||
});
|
||||
});
|
||||
|
||||
url = typeof document !== "undefined" && document !== null ? (ref = document.location) != null ? ref.href : void 0 : void 0;
|
||||
|
||||
if (!(url != null) || url.indexOf('file://') === -1) {
|
||||
examplePath = 'spec/example.yml';
|
||||
if (typeof __dirname !== "undefined" && __dirname !== null) {
|
||||
examplePath = __dirname + '/example.yml';
|
||||
}
|
||||
describe('YAML loading', function() {
|
||||
it('can be done synchronously', function() {
|
||||
return expect(YAML.load(examplePath)).toEqual({
|
||||
"this": 'is',
|
||||
a: ['YAML', 'example']
|
||||
});
|
||||
});
|
||||
return it('can be done asynchronously', function(done) {
|
||||
return YAML.load(examplePath, function(result) {
|
||||
expect(result).toEqual({
|
||||
"this": 'is',
|
||||
a: ['YAML', 'example']
|
||||
});
|
||||
return done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
4
node_modules/yamljs/test/spec/example.yml
generated
vendored
Normal file
4
node_modules/yamljs/test/spec/example.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
this: is
|
||||
a:
|
||||
- YAML
|
||||
- example
|
Reference in New Issue
Block a user