describe( 'listAppend: Concatenates an element to a list.', function () {
it ('01. Throws an error when no parameters are passed in', function () {
expect( function(){ jList.listAppend(); } ).toThrow('Missing parameter: list and value must be provided');
});
it ('02. Throws an error when only 1 parameter is passed in', function () {
expect( function(){ jList.listAppend('cat,dog'); } ).toThrow('Missing parameter: list and value must be provided');
});
it ('03. Concatenates an element to an empty list that uses the default delimiter', function () {
expect( jList.listAppend('', 'rabbit') ).toEqual('rabbit');
});
it ('04. Concatenates an element to a list that uses the default delimiter and is populated with a single element', function () {
expect( jList.listAppend('cat', 'rabbit') ).toEqual('cat,rabbit');
});
it ('05. Concatenates an element to a list that uses the default delimiter and is populated with multiple elements', function () {
expect( jList.listAppend('cat,dog', 'rabbit' ) ).toEqual('cat,dog,rabbit');
});
it ('06. Concatenates an element to an empty list that uses a custom delimiter', function () {
expect( jList.listAppend('', 'rabbit', '~') ).toEqual('rabbit');
});
it ('07. Concatenates an element to a list that uses a custom delimiter and is populated with a single element', function () {
expect( jList.listAppend('cat', 'rabbit', '~') ).toEqual('cat~rabbit');
});
it ('08. Concatenates an element to a list that uses a custom delimiter and is populated with multiple elements', function () {
expect( jList.listAppend('cat~dog', 'rabbit', '~') ).toEqual('cat~dog~rabbit');
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.