Compare commits

...

3 Commits

Author SHA1 Message Date
jywarren
9e2403782b fixed tests 2020-12-04 18:23:17 +00:00
Jeffrey Warren
ea78ec8c6a Remove old default setting for integer 2020-12-04 12:33:39 -05:00
Jeffrey Warren
43f14f25b8 Add test for range step size for int (1) vs float (0.1) 2020-12-04 12:29:55 -05:00
3 changed files with 8 additions and 4 deletions

View File

@@ -136,7 +136,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
'"max="' +
inputDesc.max +
'"step="' +
(inputDesc.step ? inputDesc.step : 1) + '">' + '<span>' + paramVal + '</span>';
inputDesc.step + '">' + '<span>' + paramVal + '</span>';
}
else html += '">';

View File

@@ -7,6 +7,7 @@ function mapHtmlTypes(inputInfo){
switch(inputInfo.type.toLowerCase()){
case 'integer':
htmlType = inputInfo.min != undefined ? 'range' : 'number';
if (htmlType === 'range') inputInfo.step = inputInfo.step || 1; // default range step size for integer
break;
case 'string':
htmlType = 'text';
@@ -19,6 +20,7 @@ function mapHtmlTypes(inputInfo){
break;
case 'float':
htmlType = inputInfo.min != undefined ? 'range' : 'text';
if (htmlType === 'range') inputInfo.step = inputInfo.step || 0.1; // default range step size for float
break;
default:
htmlType = 'text';

View File

@@ -6,10 +6,12 @@ describe('HTML Types Mapping Function', function() {
expect(mapHtmlTypes({type: 'percentage'})).toEqual({type: 'number'});
expect(mapHtmlTypes({type: 'integer'})).toEqual({type: 'number'});
expect(mapHtmlTypes({type: 'integer', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100});
expect(mapHtmlTypes({type: 'integer', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 1});
expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1}); // should default to step = 1
expect(mapHtmlTypes({type: 'float'})).toEqual({type: 'text'});
expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100});
expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1});
expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100, step: 0.1}); // should default to step = 0.1
});
it('maps text type', function() {
@@ -21,4 +23,4 @@ describe('HTML Types Mapping Function', function() {
expect(mapHtmlTypes({type: 'select'})).toEqual({type: 'select'});
});
});
});