import test from 'ava' ; import { DataBuffer } from '../src/databuffer' ; test ( 'empty' , ( t ) => { t . plan ( 4 ) ; let buf = new DataBuffer ( ) ; buf . fill ( undefined ) ; t . is ( 0 , buf . length ( ) ) ; t . is ( 0 , buf . size ( ) ) ; t . is ( 0 , buf . drain ( 1000 ) . byteLength ) ; t . is ( 0 , buf . peek ( ) . byteLength ) ; } ) ; test ( 'simple' , ( t ) => { t . plan ( 6 ) ; let buf = new DataBuffer ( ) ; buf . fill ( Buffer . from ( 'Hello' ) ) ; buf . fill ( Buffer . from ( ' ' ) ) ; buf . fill ( Buffer . from ( 'World' ) ) ; t . is ( 3 , buf . length ( ) ) ; t . is ( 11 , buf . size ( ) ) ; let p = buf . peek ( ) ; t . is ( 11 , p . byteLength ) ; t . is ( 'Hello World' , p . toString ( ) ) ; let d = buf . drain ( ) ; t . is ( 11 , d . byteLength ) ; t . is ( 'Hello World' , d . toString ( ) ) ; } ) ;