fluentnode
Version:
Fluent apis for node (based on the concepts used in C#'s FluentSharp
310 lines (206 loc) • 12.2 kB
HTML
<html>
<head>
<title>process.test.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="Array.html">
Array.litcoffee
</a>
<a class="source" href="Boolean.html">
Boolean.litcoffee
</a>
<a class="source" href="Function.html">
Function.litcoffee
</a>
<a class="source" href="Number.html">
Number.litcoffee
</a>
<a class="source" href="Object.html">
Object.litcoffee
</a>
<a class="source" href="String.html">
String.litcoffee
</a>
<a class="source" href="_register.html">
_register.js
</a>
<a class="source" href="_to_map_and_write_Tests.html">
_to_map_and_write_Tests.litcoffee
</a>
<a class="source" href="assert_Array.html">
assert_Array.litcoffee
</a>
<a class="source" href="assert_Boolean.html">
assert_Boolean.litcoffee
</a>
<a class="source" href="assert_Function.html">
assert_Function.litcoffee
</a>
<a class="source" href="assert_Number.html">
assert_Number.litcoffee
</a>
<a class="source" href="assert_Object.html">
assert_Object.litcoffee
</a>
<a class="source" href="assert_String.html">
assert_String.litcoffee
</a>
<a class="source" href="console.html">
console.litcoffee
</a>
<a class="source" href="fs.html">
fs.litcoffee
</a>
<a class="source" href="globals.html">
globals.litcoffee
</a>
<a class="source" href="http.html">
http.litcoffee
</a>
<a class="source" href="index.html">
index.md
</a>
<a class="source" href="path.html">
path.litcoffee
</a>
<a class="source" href="process.html">
process.litcoffee
</a>
<a class="source" href="Array.test.html">
Array.test.coffee
</a>
<a class="source" href="Boolean.test.html">
Boolean.test.coffee
</a>
<a class="source" href="Function.test.html">
Function.test.coffee
</a>
<a class="source" href="Number.test.html">
Number.test.coffee
</a>
<a class="source" href="Object.test.html">
Object.test.coffee
</a>
<a class="source" href="String.test.html">
String.test.coffee
</a>
<a class="source" href="Array.test.html">
Array.test.coffee
</a>
<a class="source" href="Boolean.test.html">
Boolean.test.coffee
</a>
<a class="source" href="Function.test.html">
Function.test.coffee
</a>
<a class="source" href="Number.test.html">
Number.test.coffee
</a>
<a class="source" href="Object.test.html">
Object.test.coffee
</a>
<a class="source" href="String.test.html">
String.test.coffee
</a>
<a class="source" href="console.test.html">
console.test.coffee
</a>
<a class="source" href="fs.test.html">
fs.test.coffee
</a>
<a class="source" href="globals.test.html">
globals.test.coffee
</a>
<a class="source" href="http.test.html">
http.test.coffee
</a>
<a class="source" href="path.test.html">
path.test.coffee
</a>
<a class="source" href="process.test.html">
process.test.coffee
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>process.test.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-built_in">require</span>(<span class="hljs-string">'../src/process'</span>)
<span class="hljs-built_in">require</span>(<span class="hljs-string">'../src/Array'</span>)
describe <span class="hljs-string">'process'</span>,<span class="hljs-function">-></span>
it <span class="hljs-string">'start_Process'</span>, <span class="hljs-function">-></span>
<span class="hljs-string">''</span>.start_Process.assert_Is_Function()
<span class="hljs-string">'echo'</span>.start_Process().assert_Is_Object()
.constructor.name.assert_Is(<span class="hljs-string">'ChildProcess'</span>)
<span class="hljs-string">'echo'</span>.start_Process().pid.assert_Is_Number()
it <span class="hljs-string">'start_Process_Redirect_Console'</span>, <span class="hljs-function"><span class="hljs-params">(done)</span>-></span>
original_log = <span class="hljs-built_in">console</span>.log
log_Messages = []
<span class="hljs-built_in">console</span>.log = <span class="hljs-function"><span class="hljs-params">(logMsg)</span>-></span> log_Messages.push(logMsg)
childProcess = <span class="hljs-string">'ls'</span>.start_Process_Redirect_Console(<span class="hljs-string">'.'</span>)
childProcess.<span class="hljs-literal">on</span> <span class="hljs-string">'exit'</span>, <span class="hljs-function">-></span>
<span class="hljs-built_in">console</span>.log <span class="hljs-string">'process ended'</span>
log_Messages.first() .assert_Contains(<span class="hljs-string">'README.md'</span>)
log_Messages.second().assert_Is(<span class="hljs-string">'process ended'</span>)
<span class="hljs-built_in">console</span>.log = original_log
done()
it <span class="hljs-string">'String::start_Process_Capture_Console_Out'</span>, <span class="hljs-function"><span class="hljs-params">(done)</span>-></span>
<span class="hljs-function">
<span class="hljs-title">runTest</span> = <span class="hljs-params">(testData,next)</span>-></span>
name = testData.process_Name
parameter = testData.process_Parameter
expected_Data = testData.expected_Data
name.start_Process_Capture_Console_Out parameter, <span class="hljs-function"><span class="hljs-params">(data)</span>-></span>
data.assert_Is(expected_Data)
next()
<span class="hljs-function">
<span class="hljs-title">runTests</span> = <span class="hljs-params">(testsData, next)</span>-></span>
<span class="hljs-keyword">if</span> testsData.empty()
next()
<span class="hljs-keyword">else</span>
runTest testsData.pop(), <span class="hljs-function"><span class="hljs-params">()</span>-></span> runTests(testsData, next)
testsData = [
{<span class="hljs-attribute">process_Name</span>: <span class="hljs-string">'echo'</span> , <span class="hljs-attribute">process_Parameter</span>: <span class="hljs-string">'hello'</span> , <span class="hljs-attribute">expected_Data</span>:<span class="hljs-string">'hello\n'</span> }
{<span class="hljs-attribute">process_Name</span>: <span class="hljs-string">'echo'</span> , <span class="hljs-attribute">process_Parameter</span>: [<span class="hljs-string">'hello'</span>,<span class="hljs-string">'me'</span>], <span class="hljs-attribute">expected_Data</span>:<span class="hljs-string">'hello,me\n'</span> }
{<span class="hljs-attribute">process_Name</span>: <span class="hljs-string">'echo'</span> , <span class="hljs-attribute">process_Parameter</span>: [] , <span class="hljs-attribute">expected_Data</span>:<span class="hljs-string">'\n'</span> }
{<span class="hljs-attribute">process_Name</span>: <span class="hljs-string">'echo'</span> , <span class="hljs-attribute">process_Parameter</span>: [<span class="hljs-literal">null</span>] , <span class="hljs-attribute">expected_Data</span>:<span class="hljs-string">'\n'</span> }
{<span class="hljs-attribute">process_Name</span>: <span class="hljs-string">'git'</span> , <span class="hljs-attribute">process_Parameter</span>: [<span class="hljs-string">'xyz'</span> ], <span class="hljs-attribute">expected_Data</span>:<span class="hljs-string">'git: \'xyz\' is not a git command. See \'git --help\'.\n'</span> }</pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<p>travis and cloud9 sometimes failed on a couple of these (not in an consistent/repeatable way)</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-comment">#{process_Name: 'ls' , process_Parameter: '.' , expected_Data:'Cakefile\nLICENSE\nREADME.md\ndocs\npackage.json\nsrc\ntest\n' }</span>
<span class="hljs-comment">#{process_Name: 'ls' , process_Parameter: null , expected_Data:'ls: null: No such file or directory\n' }</span>
]
runTests(testsData, done)</pre></div></div>
</li>
</ul>
</div>
</body>
</html>