var assert = require("assert")
var fs = require('fs');
var h2frame = require('../lib/frame');

describe('Http2PingFrame:', function () {
    describe('Created frame', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should have 8 octets of payload', function () {
            assert.equal(frame.length, 8);
        });
    });
    describe('Created frame', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should have type value of PING frame', function () {
            assert.equal(frame.flags, 0);
        });
    });
    describe('Created frame', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should have no flags', function () {
            assert.equal(frame.flags, 0);
        });
    });
    describe('Created frame', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should have streamId zero', function () {
            assert.equal(frame.streamId, 0);
        });
    });
    describe('#getBuffer()', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should return a buffer, and its length should be 16 octets', function () {
            assert(frame.getBuffer() instanceof Buffer);
            assert.equal(frame.getBuffer().length, 16);
        });
    });
    describe('#getPayload()', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should return a buffer, and its length should be 8 octets', function () {
            assert(frame.getPayload() instanceof Buffer);
            assert.equal(frame.getPayload().length, 8);
        });
    });
    describe('#setPayload()', function () {
        var frame = new h2frame.Http2PingFrame();
        it('should set the given data into the buffer', function () {
            var expected = new Buffer([0x11, 0x22, 0x33, 0x44, 0xAA, 0xBB, 0xCC, 0xDD]);
            frame.setPayload(expected);
            assert.deepEqual(frame.getPayload(), expected);
            assert.deepEqual(frame.getBuffer().slice(8, 16), expected);
        });
    });
});

@@ -140,37 +140,54 @@
   describe('
-Created frame
+A frame created without buffer
 ', function 
@@ -374,37 +374,54 @@
   describe('
-Created frame
+A frame created without buffer
 ', function 
@@ -612,37 +612,54 @@
   describe('
-Created frame
+A frame created without buffer
 ', function 
@@ -842,21 +842,38 @@
 be('
-Created frame
+A frame created without buffer
 ', f
@@ -981,32 +981,32 @@
 , function () %7B%0A
-
             asse
@@ -1046,32 +1046,951 @@
     %7D);%0A    %7D);%0A
+    describe('A frame created with buffer', function () %7B%0A        var buf = new Buffer(%5B0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10%5D);%0A        var frame = new h2frame.Http2PingFrame(buf);%0A        it('should have the buffer', function () %7B%0A            assert.equal(frame.getBuffer(), buf);%0A        %7D);%0A    %7D);%0A    describe('FLAG_ACK', function () %7B%0A        it('should be a constant value for ACK flag', function () %7B%0A            assert.equal(h2frame.Http2PingFrame.FLAG_ACK, 0x1);%0A            h2frame.Http2PingFrame.FLAG_ACK = 9999;%0A            assert.equal(h2frame.Http2PingFrame.FLAG_ACK, 0x1);%0A        %7D);%0A    %7D);%0A    describe('#toString()', function () %7B%0A        var frame = new h2frame.Http2PingFrame();%0A        it('should return a string containing frame name', function () %7B%0A            assert.notEqual(frame.toString().indexOf('PING'), -1);%0A        %7D);%0A    %7D);%0A
     describe('#g

add tests for PING frame