diff --git a/test/characteristicValueToItsProperType.js b/test/characteristicValueToItsProperType.js index 368f934..1afb0bd 100644 --- a/test/characteristicValueToItsProperType.js +++ b/test/characteristicValueToItsProperType.js @@ -107,6 +107,47 @@ describe('Test characteristicValueToItsProperType.', ( ) => assert.equal( result, expectedResult, "configHasCharacteristicProps of valid data with full properties returned incorrect result: " + result ); }); + it('characteristicValueToItsProperType of TargetTemperature of Float "0.0" should be 0.0', ( ) => + { + let accTypeEnumIndex = CMD4_ACC_TYPE_ENUM.TargetTemperature; + let displayName = "testDevice"; + let characteristicString = CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].type; + let format = CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].props.format; + let value = "0.0"; + let expectedResult = 0.0; + let expectedResultType = "number"; // There is no float type + + + let result = characteristicValueToItsProperType( console, format, displayName, Characteristic, characteristicString, value ); + + assert.equal( result, expectedResult, "configHasCharacteristicProps of valid data with full properties returned incorrect result: " + result ); + + let resultType = typeof result; + + assert.equal( resultType, expectedResultType, "configHasCharacteristicProps of valid data with full properties returned incorrect result. Expected: : " + expectedResultType + " received: " + resultType ); + }); + + it('characteristicValueToItsProperType of TargetTemperature of Float "0" should be float', ( ) => + { + let accTypeEnumIndex = CMD4_ACC_TYPE_ENUM.TargetTemperature; + let displayName = "testDevice"; + let characteristicString = CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].type; + let format = CMD4_ACC_TYPE_ENUM.properties[ accTypeEnumIndex ].props.format; + let value = "0"; + let expectedResult = 0; + let expectedResultType = "number"; // There is no float type + + + let result = characteristicValueToItsProperType( console, format, displayName, Characteristic, characteristicString, value ); + + assert.equal( result, expectedResult, "configHasCharacteristicProps of valid data with full properties returned incorrect result: " + result ); + + let resultType = typeof result; + + assert.equal( resultType, expectedResultType, "configHasCharacteristicProps of valid data with full properties returned incorrect result. Expected: : " + expectedResultType + " received: " + resultType ); + }); + + it('characteristicValueToItsProperType of Name of string1 should be String.', ( ) => { let accTypeEnumIndex = CMD4_ACC_TYPE_ENUM.Name; diff --git a/test/isNumeric.js b/test/isNumeric.js index dd9f7cf..9f19690 100644 --- a/test/isNumeric.js +++ b/test/isNumeric.js @@ -49,6 +49,24 @@ describe( "Testing isNumeric", ( ) => assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); }); + it( "isNumeric should correctly identify a 0", ( ) => + { + let data = 0; + let expectedResult = true; + let result = isNumeric( data ); + assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); + }); + + it( `isNumeric should correctly identify a "0"`, ( ) => + { + let data = "0"; + let expectedResult = true; + let result = isNumeric( data ); + assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); + }); + + + it( "isNumeric should correctly fail a character string", ( ) => { let data = "One"; @@ -57,12 +75,19 @@ describe( "Testing isNumeric", ( ) => assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); }); - it( "isNumeric should correctly fail a undefined", ( ) => + it( "isNumeric should correctly fail an undefined", ( ) => { let data = undefined; let expectedResult = false; let result = isNumeric( data ); assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); }); + it( "isNumeric should correctly fail a null", ( ) => + { + let data = null; + let expectedResult = false; + let result = isNumeric( data ); + assert.equal( result, expectedResult, "isNumeric( " + data + " ) returned: " + result + " expected: " + expectedResult ); + }); })