Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/mocha-3.1.0/test/http-meta-2.spec.js')
-rw-r--r--tests/lib/mocha-3.1.0/test/http-meta-2.spec.js91
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/lib/mocha-3.1.0/test/http-meta-2.spec.js b/tests/lib/mocha-3.1.0/test/http-meta-2.spec.js
deleted file mode 100644
index fe9662b2e6..0000000000
--- a/tests/lib/mocha-3.1.0/test/http-meta-2.spec.js
+++ /dev/null
@@ -1,91 +0,0 @@
-var http = require('http');
-
-var PORT = 8899;
-
-var server = http.createServer(function(req, res){
- var accept = req.headers.accept || ''
- , json = ~accept.indexOf('json');
-
- switch (req.url) {
- case '/':
- res.end('hello');
- break;
- case '/users':
- if (json) {
- res.end('["tobi","loki","jane"]');
- } else {
- res.end('tobi, loki, jane');
- }
- break;
- }
-})
-
-function get(url) {
- var fields
- , expected
- , header = {};
-
- function request(done) {
- http.get({ path: url, port: PORT, headers: header }, function(res){
- var buf = '';
- res.should.have.property('statusCode', 200);
- res.setEncoding('utf8');
- res.on('data', function(chunk){ buf += chunk });
- res.on('end', function(){
- buf.should.equal(expected);
- done();
- });
- })
- }
-
- return {
- set: function(field, val){
- header[field] = val;
- return this;
- },
-
- should: {
- respond: function(body){
- fields = Object.keys(header).map(function(field){
- return field + ': ' + header[field];
- }).join(', ');
-
- expected = body;
- describe('GET ' + url, function(){
- this.timeout(500);
- if (fields) {
- describe('when given ' + fields, function(){
- it('should respond with "' + body + '"', request);
- });
- } else {
- it('should respond with "' + body + '"', request);
- }
- });
- }
- }
- };
-}
-
-describe('http server', function(){
-
- before(function(done) {
- server.listen(PORT, done);
- });
-
- after(function() {
- server.close();
- });
-
- get('/')
- .should
- .respond('hello')
-
- get('/users')
- .should
- .respond('tobi, loki, jane')
-
- get('/users')
- .set('Accept', 'application/json')
- .should
- .respond('["tobi","loki","jane"]')
-})