Created
March 4, 2014 09:29
-
-
Save ViswanathKari/9343141 to your computer and use it in GitHub Desktop.
Hello World Unit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HelloWorld_UnitTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="WEB_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
<orderEntry type="library" name="Node.js v0.10.26 Core Modules" level="application" /> | |
<orderEntry type="library" name="should-DefinitelyTyped" level="application" /> | |
<orderEntry type="library" name="mocha-DefinitelyTyped" level="application" /> | |
<orderEntry type="library" name="node-DefinitelyTyped" level="application" /> | |
</component> | |
</module> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="JavaScriptLibraryMappings"> | |
<file url="PROJECT" libraries="{Node.js v0.10.26 Core Modules, mocha-DefinitelyTyped, node-DefinitelyTyped, should-DefinitelyTyped}" /> | |
<includedPredefinedLibrary name="Node.js Globals" /> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/HelloWorld_UnitTest.iml" filepath="$PROJECT_DIR$/.idea/HelloWorld_UnitTest.iml" /> | |
</modules> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="DependencyValidationManager"> | |
<state> | |
<option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
</state> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var server = http.createServer(function (req, res) { | |
console.log('Received request'); | |
res.writeHead(200, { 'Content-Type': 'text/plain' }); | |
res.write('Hello World!\n'); | |
res.end() | |
}); | |
var listen = function (port) { | |
server.listen(port, function() { | |
console.log('Listening on port: ' + port); | |
}); | |
}; | |
var close = function () { | |
server.close(function(){ | |
console.log('Closing connection!'); | |
}); | |
}; | |
module.exports.listen = listen; | |
module.exports.close = close; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = require('../src/server.js'); | |
var http = require('http'); | |
var assert = require('assert'); | |
before(function () { | |
server.listen(8888); | |
}); | |
after(function () { | |
server.close(); | |
}); | |
it('should return 200', function (done) { | |
http.get('http://localhost:8888', function (res) { | |
assert.equal(res.statusCode, '200'); | |
done(); | |
}); | |
}); | |
it('should say Hello World\n', function (done) { | |
http.get('http://localhost:8888', function (res) { | |
var data = ''; | |
res.on('data', function (chunk) { | |
data += chunk; | |
}); | |
res.on('end', function () { | |
assert.equal(data, "Hello World!\n"); | |
done(); | |
}); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment