Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,30 @@ import CircularBuffer = require( './index' );

// TESTS //

// The function returns a circular buffer instance...
// The function returns a circular buffer instance if the constructor function is provided a first argument which is a number...
{
new CircularBuffer( 3 ); // $ExpectType CircularBuffer<unknown>
}

// The function returns a circular buffer instance if the constructor function is provided a first argument which is an array-like object...
{
new CircularBuffer( [ 1, 2, 3 ] ); // $ExpectType CircularBuffer<number>
new CircularBuffer( 'abc' ); // $ExpectType CircularBuffer<string>
new CircularBuffer( { 'length': 10 } ); // $ExpectType CircularBuffer<unknown>
}

// The compiler throws an error if the constructor function is provided an invalid number of arguments...
{
new CircularBuffer(); // $ExpectError
new CircularBuffer( 3, 4 ); // $ExpectError
}

// The compiler throws an error if the constructor function is provided a first argument which is not a number or an array-like object...
{
new CircularBuffer( true ); // $ExpectError
new CircularBuffer( false ); // $ExpectError
new CircularBuffer( null ); // $ExpectError
new CircularBuffer( undefined ); // $ExpectError
new CircularBuffer( {} ); // $ExpectError
new CircularBuffer( ( x: number ): number => x ); // $ExpectError
}