Initial commit
This commit is contained in:
60
node_modules/inspect-property/test/data/main-data.js
generated
vendored
Normal file
60
node_modules/inspect-property/test/data/main-data.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
function functionObject() {
|
||||
this.inner = 'property';
|
||||
}
|
||||
|
||||
// Function Inner Property
|
||||
functionObject.functionObjectEnumerablePropEnumerable = 'functionObjectEnumerablePropEnumerableVALUE';
|
||||
|
||||
Object.defineProperty(functionObject, 'functionObjectEnumerablePropNonEnumerable', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: 'functionObjectEnumerablePropNonEnumerableVALUE'
|
||||
});
|
||||
|
||||
Object.defineProperty(functionObject.prototype, 'protoEnumerableProp', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: 'protoEnumerablePropVALUE'
|
||||
});
|
||||
|
||||
Object.defineProperty(functionObject.prototype, 'protoNonEnumerableProp', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: 'nonEnumerablePropVALUE'
|
||||
});
|
||||
|
||||
const instanceFromFunctionObject = new functionObject();
|
||||
|
||||
Object.defineProperty(instanceFromFunctionObject, 'propEnumerable', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
value: 'propEnumerableVALUE'
|
||||
});
|
||||
|
||||
Object.defineProperty(instanceFromFunctionObject, 'propNonEnumerable', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: 'propNonEnumerableVALUE'
|
||||
});
|
||||
|
||||
instanceFromFunctionObject.a = {
|
||||
b: {
|
||||
c: x => x
|
||||
},
|
||||
d: 3,
|
||||
f: {
|
||||
g: 'h'
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
instanceFromFunctionObject,
|
||||
functionObject
|
||||
}
|
||||
17
node_modules/inspect-property/test/main.test.js
generated
vendored
Normal file
17
node_modules/inspect-property/test/main.test.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const inspectProperty = require('../');
|
||||
const testSpecs = require('./specs/main-specs.js');
|
||||
|
||||
testSpecs.forEach(spec => {
|
||||
describe(spec.description, function(){
|
||||
const method = spec.method ? inspectProperty[spec.method] : inspectProperty;
|
||||
const input = spec.input;
|
||||
const output = spec.fn(method, input);
|
||||
spec.tests.forEach(test => {
|
||||
it(test.description, function(){
|
||||
return test.fn(output, input);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
120
node_modules/inspect-property/test/specs/main-specs.js
generated
vendored
Normal file
120
node_modules/inspect-property/test/specs/main-specs.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const { functionObject, instanceFromFunctionObject } = require('../data/main-data.js');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
description: `Test functionObject {enumerability: 'enumerable'}`,
|
||||
input: functionObject,
|
||||
fn: (method, input) => method(input, null, { enumerability: 'enumerable' }),
|
||||
tests: [{
|
||||
description: "Check Type",
|
||||
fn: (output, input) => assert(output.type, 'function'),
|
||||
}, {
|
||||
description: "Check Constructor Name",
|
||||
fn: (output, input) => assert(output.constructor.name, 'Function'),
|
||||
}, {
|
||||
description: "Check functionInspection name",
|
||||
fn: (output, input) => assert(output.functionInspection.name, 'functionObject'),
|
||||
}, {
|
||||
description: "Check Properties",
|
||||
fn: (output, input) => {
|
||||
const mustInclude = ['functionObjectEnumerablePropEnumerable'];
|
||||
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
|
||||
}
|
||||
}, {
|
||||
description: "Property Type",
|
||||
fn: (output, input) => {
|
||||
return assert(output.properties.functionObjectEnumerablePropEnumerable.type, 'string');
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
description: `Test instanceFromFunctionObject {enumerability: 'enumerable'}`,
|
||||
input: instanceFromFunctionObject,
|
||||
fn: (method, input) => method(input, null, { enumerability: 'enumerable' }),
|
||||
tests: [{
|
||||
description: "Check Type Name",
|
||||
fn: (output, input) => assert(output.type, 'object'),
|
||||
}, {
|
||||
description: "Check Constructor Name",
|
||||
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
|
||||
}, {
|
||||
description: "Check Properties",
|
||||
fn: (output, input) => {
|
||||
const mustInclude = [
|
||||
'inner',
|
||||
'propEnumerable',
|
||||
'propNonEnumerable',
|
||||
'a',
|
||||
'a.b',
|
||||
'a.b.c',
|
||||
'a.d',
|
||||
'a.f',
|
||||
'a.f.g',
|
||||
'protoEnumerableProp',
|
||||
'protoNonEnumerableProp'
|
||||
];
|
||||
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
description: `Test instanceFromFunctionObject {enumerability: 'all', inherited: true}`,
|
||||
input: instanceFromFunctionObject,
|
||||
fn: (method, input) => method(input, null, { enumerability: 'all', inherited: true }),
|
||||
tests: [{
|
||||
description: "Check Type Name",
|
||||
fn: (output, input) => assert(output.type, 'object'),
|
||||
}, {
|
||||
description: "Check Constructor Name",
|
||||
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
|
||||
}, {
|
||||
description: "Check Properties",
|
||||
fn: (output, input) => {
|
||||
const mustInclude = [
|
||||
'inner',
|
||||
'propEnumerable',
|
||||
'propNonEnumerable',
|
||||
'a',
|
||||
'a.b',
|
||||
'a.b.c',
|
||||
'a.d',
|
||||
'a.f',
|
||||
'a.f.g',
|
||||
'protoEnumerableProp',
|
||||
'protoNonEnumerableProp'
|
||||
];
|
||||
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
description: `Test instanceFromFunctionObject {delimiter: '|'}`,
|
||||
input: instanceFromFunctionObject,
|
||||
fn: (method, input) => method(input, null, { delimiter: '|' }),
|
||||
tests: [{
|
||||
description: "Check Type Name",
|
||||
fn: (output, input) => assert(output.type, 'object'),
|
||||
}, {
|
||||
description: "Check Constructor Name",
|
||||
fn: (output, input) => assert(output.constructor.name, 'functionObject'),
|
||||
}, {
|
||||
description: "Check Properties",
|
||||
fn: (output, input) => {
|
||||
const mustInclude = [
|
||||
'inner',
|
||||
'propEnumerable',
|
||||
'a',
|
||||
'a|b',
|
||||
'a|b|c',
|
||||
'a|d',
|
||||
'a|f',
|
||||
'a|f|g'
|
||||
];
|
||||
return assert(Object.keys(output.properties).every(key => mustInclude.includes(key)));
|
||||
}
|
||||
}]
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user