[Pkg-javascript-commits] [node-stream-http] 62/208: Add abort() test
    Bastien Roucariès 
    rouca at moszumanska.debian.org
       
    Sun Aug 13 13:39:29 UTC 2017
    
    
  
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-http.
commit 29a2ad20326af03db9c5733ce60939fa302a8f9c
Author: John Hiesey <john at hiesey.com>
Date:   Mon Jul 13 16:57:31 2015 -0700
    Add abort() test
---
 test/browser/abort.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
diff --git a/test/browser/abort.js b/test/browser/abort.js
new file mode 100644
index 0000000..59a92ba
--- /dev/null
+++ b/test/browser/abort.js
@@ -0,0 +1,48 @@
+var Buffer = require('buffer').Buffer
+var fs = require('fs')
+var test = require('tape')
+
+var http = require('../..')
+
+test('abort before response', function (t) {
+	var req = http.get('/basic.txt', function (res) {
+		t.fail('unexpected response')
+	})
+	req.abort()
+	t.end()
+})
+
+test('abort on response', function (t) {
+	var req = http.get('/basic.txt', function (res) {
+		req.abort()
+		t.end()
+
+		res.on('end', function () {
+			t.fail('unexpected end')
+		})
+
+		res.on('data', function (data) {
+			t.fail('unexpected data')
+		})
+	})
+})
+
+test('abort on data', function (t) {
+	var req = http.get('/browserify.png?copies=5', function (res) {
+		var firstData = true
+
+		res.on('end', function () {
+			t.fail('unexpected end')
+		})
+
+		res.on('data', function (data) {
+			if (firstData) {
+				firstData = false
+				req.abort()
+				t.end()
+			} else {
+				t.fail('unexpected data')
+			}
+		})
+	})
+})
\ No newline at end of file
-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git
    
    
More information about the Pkg-javascript-commits
mailing list