source: trip-planner-front/node_modules/needle/test/long_string_spec.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 928 bytes
Line 
1var needle = require('../'),
2 should = require('should');
3
4describe('when posting a very long string', function() {
5
6 this.timeout(20000);
7
8 function get_string(length) {
9 var str = '';
10 for (var i = 0; i < length; i++) {
11 str += 'x';
12 }
13 return str;
14 }
15
16 var major_version = process.version.split('.')[0];
17
18 it("shouldn't throw an EPIPE error out of nowhere", function(done) {
19
20 // for some reason this test fails in Github Actions with Node v8.x
21 // although in my Linux box passes without issues
22 if (process.env.CI && (major_version == 'v8' || major_version == 'v6')) {
23 return done();
24 }
25
26 var error;
27
28 function finished() {
29 setTimeout(function() {
30 should.not.exist(error);
31 done();
32 }, 300);
33 }
34
35 try {
36 needle.post('https://google.com', { data: get_string(Math.pow(2, 20)) }, finished)
37 } catch(e) {
38 error = e;
39 }
40
41 })
42
43})
Note: See TracBrowser for help on using the repository browser.