aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/test/byte_buffer_test.js~
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/test/byte_buffer_test.js~')
-rw-r--r--src/node/test/byte_buffer_test.js~35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/node/test/byte_buffer_test.js~ b/src/node/test/byte_buffer_test.js~
new file mode 100644
index 0000000000..8f272e5bd6
--- /dev/null
+++ b/src/node/test/byte_buffer_test.js~
@@ -0,0 +1,35 @@
+var assert = require('assert');
+var grpc = require('..build/Release/grpc');
+
+describe('byte buffer', function() {
+ describe('constructor', function() {
+ it('should reject bad constructor calls', function() {
+ it('should require at least one argument', function() {
+ assert.throws(new grpc.ByteBuffer(), TypeError);
+ });
+ it('should reject non-string arguments', function() {
+ assert.throws(new grpc.ByteBuffer(0), TypeError);
+ assert.throws(new grpc.ByteBuffer(1.5), TypeError);
+ assert.throws(new grpc.ByteBuffer(null), TypeError);
+ assert.throws(new grpc.ByteBuffer(Date.now()), TypeError);
+ });
+ it('should accept string arguments', function() {
+ assert.doesNotThrow(new grpc.ByteBuffer(''));
+ assert.doesNotThrow(new grpc.ByteBuffer('test'));
+ assert.doesNotThrow(new grpc.ByteBuffer('\0'));
+ });
+ });
+ });
+ describe('bytes', function() {
+ it('should return the passed string', function() {
+ it('should preserve simple strings', function() {
+ var buffer = new grpc.ByteBuffer('test');
+ assert.strictEqual(buffer.bytes(), 'test');
+ });
+ it('should preserve null characters', function() {
+ var buffer = new grpc.ByteBuffer('test\0test');
+ assert.strictEqual(buffer.bytes(), 'test\0test');
+ });
+ });
+ });
+});