Skip to content

Instantly share code, notes, and snippets.

@rozek rozek/TestObject.js
Created Sep 5, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.