Skip to content

Instantly share code, notes, and snippets.

@rozek
Created September 5, 2018 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozek/cabde4d258505dc04bafae28cb7c512c to your computer and use it in GitHub Desktop.
Save rozek/cabde4d258505dc04bafae28cb7c512c to your computer and use it in GitHub Desktop.
basic JavaScript object with properties useful for unit testing
/**** basic JavaScript object whose properties could be used for unit testing ****/
function newTestObject () {
return {
undefined:undefined,
null:null,
true:true, false:false,
negativeInteger:-123, zero:0, positiveInteger:123,
negativeInfinity:-Infinity, Number:Math.PI, positiveInfinity:Infinity, NaN:NaN,
emptyString:'', String:'Test',
lambda:function (x) { return x*x },
namedFunction:function Test () { return 'Hello, World!' },
emptyObject:{}, FoundationObject:Object.create(null), Object:{
undefined:undefined,
null:null,
true:true, false:false,
negativeInteger:-123, zero:0, positiveInteger:123,
negativeInfinity:-Infinity, Number:Math.PI, positiveInfinity:Infinity, NaN:NaN,
emptyString:'', String:'Test',
lambda:function (x) { return x*x },
namedFunction:function Test () { return 'Hello, World!' },
emptyObject:{}, FoundationObject:Object.create(null), Object:{
undefined:undefined,
null:null,
true:true, false:false,
negativeInteger:-123, zero:0, positiveInteger:123,
negativeInfinity:-Infinity, Number:Math.PI, positiveInfinity:Infinity, NaN:NaN,
emptyString:'', String:'Test',
lambda:function (x) { return x*x },
namedFunction:function Test () { return 'Hello, World!' },
emptyObject:{}, FoundationObject:Object.create(null),
emptyArray:[]
}, emptyArray:[], Array:[
undefined, null,
true, false, -123, 0, 123, -Infinity, Math.PI, Infinity, NaN, '', 'Test',
function (x) { return x*x }, function Test () { return 'Hello, World!' },
{}, Object.create(null), []
]
},
emptyArray:[], Array:[
undefined, null,
true, false, -123, 0, 123, -Infinity, Math.PI, Infinity, NaN, '', 'Test',
function (x) { return x*x }, function Test () { return 'Hello, World!' },
{}, Object.create(null), {
undefined:undefined,
null:null,
true:true, false:false,
negativeInteger:-123, zero:0, positiveInteger:123,
negativeInfinity:-Infinity, Number:Math.PI, positiveInfinity:Infinity, NaN:NaN,
emptyString:'', String:'Test',
lambda:function (x) { return x*x },
namedFunction:function Test () { return 'Hello, World!' },
emptyObject:{}, FoundationObject:Object.create(null),
emptyArray:[]
}, [], [
undefined, null,
true, false, -123, 0, 123, -Infinity, Math.PI, Infinity, NaN, '', 'Test',
function (x) { return x*x }, function Test () { return 'Hello, World!' },
{}, Object.create(null), []
]
]
};
};
var TestObject = newTestObject();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment