How to use parseValue method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

GradeOverrideEntry.test.js

Source:GradeOverrideEntry.test.js Github

copy

Full Screen

...62      previousValue = null63    })64    function hasGradeChanged() {65      const gradeEntry = new GradeOverrideEntry(options)66      const assignedGradeInfo = gradeEntry.parseValue(assignedValue)67      const currentGradeInfo = gradeEntry.parseValue(currentValue)68      const previousGradeInfo = previousValue == null ? null : gradeEntry.parseValue(previousValue)69      return gradeEntry.hasGradeChanged(assignedGradeInfo, currentGradeInfo, previousGradeInfo)70    }71    describe('when no grade is assigned and no grade was previously entered', () => {72      it('returns false when no value has been entered', () => {73        expect(hasGradeChanged()).toBe(false)74      })75      it('returns false when only whitespace has been entered', () => {76        currentValue = '     '77        expect(hasGradeChanged()).toBe(false)78      })79      it('returns true when any other value has been entered', () => {80        currentValue = 'invalid'81        expect(hasGradeChanged()).toBe(true)82      })83    })84    describe('when no grade is assigned and a valid grade was previously entered', () => {85      beforeEach(() => {86        previousValue = '91.1%'87        currentValue = '91.1%'88      })89      it('returns false when the same grade is entered', () => {90        expect(hasGradeChanged()).toBe(false)91      })92      it('returns true when a different valid grade is entered', () => {93        currentValue = '89.9%'94        expect(hasGradeChanged()).toBe(true)95      })96      it('returns true when an invalid grade is entered', () => {97        currentValue = 'invalid'98        expect(hasGradeChanged()).toBe(true)99      })100      it('returns true when the grade is cleared', () => {101        currentValue = ''102        expect(hasGradeChanged()).toBe(true)103      })104    })105    describe('when no grade is assigned and an invalid grade was previously entered', () => {106      beforeEach(() => {107        previousValue = 'invalid'108        currentValue = 'invalid'109      })110      it('returns false when the same invalid grade is entered', () => {111        expect(hasGradeChanged()).toBe(false)112      })113      it('returns true when a different invalid grade is entered', () => {114        currentValue = 'also invalid'115        expect(hasGradeChanged()).toBe(true)116      })117      it('returns true when a valid grade is entered', () => {118        currentValue = '91.1%'119        expect(hasGradeChanged()).toBe(true)120      })121      it('returns true when the invalid grade is cleared', () => {122        currentValue = ''123        expect(hasGradeChanged()).toBe(true)124      })125    })126    describe('when a grade is assigned and no different grade was previously entered', () => {127      beforeEach(() => {128        assignedValue = '89.9%'129        currentValue = '89.9%'130      })131      it('returns false when the same percentage grade is entered', () => {132        expect(hasGradeChanged()).toBe(false)133      })134      it('returns false when the same percentage grade is entered with extra zeros', () => {135        currentValue = '89.9000%'136        expect(hasGradeChanged()).toBe(false)137      })138      it('returns false when the same scheme key is entered using the grading scheme', () => {139        assignedValue = '80%' // Becomes an "B" in the grading scheme140        currentValue = 'B'141        expect(hasGradeChanged()).toBe(false)142      })143      it('returns false when the same scheme key is entered but the percentage was different', () => {144        assignedValue = '95.0%' // Becomes an "A" in the grading scheme145        /*146         * A value of "A" is not considered different, even though the147         * percentage would ordinarily be interpreted as 90%, because the user148         * might not have actually changed the value of the input.149         */150        currentValue = 'A'151        expect(hasGradeChanged()).toBe(false)152      })153      it('returns true when a different valid percentage is entered', () => {154        currentValue = '91.1%'155        expect(hasGradeChanged()).toBe(true)156      })157      it('returns true when an invalid grade is entered', () => {158        currentValue = 'invalid'159        expect(hasGradeChanged()).toBe(true)160      })161      it('returns true when the grade is cleared', () => {162        currentValue = ''163        expect(hasGradeChanged()).toBe(true)164      })165    })166    describe('when a grade is assigned and a different valid grade was previously entered', () => {167      beforeEach(() => {168        assignedValue = '89.9%'169        previousValue = '90.0%'170        currentValue = '90.0%'171      })172      it('returns false when the previously entered percentage grade is entered', () => {173        expect(hasGradeChanged()).toBe(false)174      })175      it('returns false when the previously entered percentage grade is entered with extra zeros', () => {176        currentValue = '90.0000%'177        expect(hasGradeChanged()).toBe(false)178      })179      it('returns false when the previously entered scheme key is entered using the grading scheme', () => {180        currentValue = 'A'181        expect(hasGradeChanged()).toBe(false)182      })183      it('returns false when the previously entered scheme key is entered but the percentage was different', () => {184        previousValue = '95.0%' // Becomes an "A" in the grading scheme185        /*186         * A value of "A" is not considered different, even though the187         * percentage would ordinarily be interpreted as 90%, because the user188         * might not have actually changed the value of the input.189         */190        currentValue = 'A'191        expect(hasGradeChanged()).toBe(false)192      })193      it('returns true when a different valid percentage is entered', () => {194        currentValue = '91.1%'195        expect(hasGradeChanged()).toBe(true)196      })197      it('returns true when an invalid grade is entered', () => {198        currentValue = 'invalid'199        expect(hasGradeChanged()).toBe(true)200      })201      it('returns true when the grade is cleared', () => {202        currentValue = ''203        expect(hasGradeChanged()).toBe(true)204      })205    })206    describe('when a grade is assigned and an invalid grade was previously entered', () => {207      beforeEach(() => {208        assignedValue = '89.9%'209        previousValue = 'invalid'210        currentValue = 'invalid'211      })212      it('returns false when the same invalid grade is entered', () => {213        expect(hasGradeChanged()).toBe(false)214      })215      it('returns true when a different invalid grade is entered', () => {216        currentValue = 'also invalid'217        expect(hasGradeChanged()).toBe(true)218      })219      it('returns true when a valid grade is entered', () => {220        currentValue = '91.1%'221        expect(hasGradeChanged()).toBe(true)222      })223      it('returns true when the assigned grade is entered as a percentage', () => {224        currentValue = '89.9%'225        expect(hasGradeChanged()).toBe(true)226      })227      it('returns true when the assigned grade is entered using the scheme key', () => {228        currentValue = 'B'229        expect(hasGradeChanged()).toBe(true)230      })231      it('returns true when the invalid grade is cleared', () => {232        currentValue = ''233        expect(hasGradeChanged()).toBe(true)234      })235    })236  })237  describe('#parseValue()', () => {238    function parseValue(value) {239      return new GradeOverrideEntry(options).parseValue(value)240    }241    describe('.grade', () => {242      it('is set to null when given non-numerical string not in the grading scheme', () => {243        expect(parseValue('B-').grade).toEqual(null)244      })245      it('is set to null when the value is blank', () => {246        expect(parseValue('  ').grade).toEqual(null)247      })248      it('is set to null when the value is "EX"', () => {249        expect(parseValue('EX').grade).toEqual(null)250      })251      describe('.percentage', () => {252        it('is set to the lower bound for a matching scheme key', () => {253          expect(parseValue('B').grade.percentage).toEqual(80.0)254        })255        it('is set to the decimal form of an explicit percentage', () => {256          expect(parseValue('83.45%').grade.percentage).toEqual(83.45)257        })258        it('is set to the decimal of a given integer', () => {259          expect(parseValue(83).grade.percentage).toEqual(83.0)260        })261        it('is set to the decimal of a given stringified integer', () => {262          expect(parseValue('73').grade.percentage).toEqual(73.0)263        })264        it('is set to the given decimal', () => {265          expect(parseValue(73.45).grade.percentage).toEqual(73.45)266        })267        it('is set to the decimal of a given stringified decimal', () => {268          expect(parseValue('73.45').grade.percentage).toEqual(73.45)269        })270        it('converts percentages using the "%" symbol', () => {271          expect(parseValue('83.35%').grade.percentage).toEqual(83.35)272        })273        it('converts percentages using the "﹪" symbol', () => {274          expect(parseValue('83.35﹪').grade.percentage).toEqual(83.35)275        })276        it('converts percentages using the "٪" symbol', () => {277          expect(parseValue('83.35٪').grade.percentage).toEqual(83.35)278        })279        it('is rounded to 15 decimal places', () => {280          const {percentage} = parseValue(81.1234567890123456789).grade281          expect(String(percentage)).toEqual('81.12345678901235')282        })283        it('is set to the lower bound for a matching numerical scheme key', () => {284          options.gradingScheme.data = [285            ['4.0', 0.9],286            ['3.0', 0.8],287            ['2.0', 0.7],288            ['1.0', 0.6],289            ['0.0', 0.5]290          ]291          expect(parseValue('3.0').grade.percentage).toEqual(80.0)292        })293        it('is set to the lower bound for a matching percentage scheme key', () => {294          options.gradingScheme.data = [295            ['95%', 0.9],296            ['85%', 0.8],297            ['75%', 0.7],298            ['65%', 0.6],299            ['0%', 0.5]300          ]301          expect(parseValue('85%').grade.percentage).toEqual(80.0)302        })303        it('is set to zero when given zero', () => {304          expect(parseValue(0).grade.percentage).toEqual(0)305        })306        it('is set to the given numerical value when not using a grading scheme', () => {307          options.gradingScheme = null308          expect(parseValue('81.45').grade.percentage).toEqual(81.45)309        })310      })311      describe('.schemeKey', () => {312        it('is set to the matching scheme key when given an integer', () => {313          expect(parseValue(81).grade.schemeKey).toEqual('B')314        })315        it('is set to the matching scheme key with the same case', () => {316          expect(parseValue('B').grade.schemeKey).toEqual('B')317        })318        it('uses the exact scheme key when matching with different case', () => {319          expect(parseValue('b').grade.schemeKey).toEqual('B')320        })321        it('matches an explicit percentage value to a scheme value for the grade scheme key', () => {322          expect(parseValue('83.45%').grade.schemeKey).toEqual('B')323        })324        it('uses numerical values as implicit percentage values', () => {325          expect(parseValue(83).grade.schemeKey).toEqual('B')326        })327        it('is set to the matching scheme key when given a stringified integer', () => {328          expect(parseValue('73').grade.schemeKey).toEqual('C')329        })330        it('is set to the matching scheme key when given an decimal', () => {331          expect(parseValue(73.45).grade.schemeKey).toEqual('C')332        })333        it('is set to the matching scheme key when given a stringified decimal', () => {334          expect(parseValue('73.45').grade.schemeKey).toEqual('C')335        })336        it('converts percentages using the "%" symbol', () => {337          expect(parseValue('83.35%').grade.schemeKey).toEqual('B')338        })339        it('converts percentages using the "﹪" symbol', () => {340          expect(parseValue('83.35﹪').grade.schemeKey).toEqual('B')341        })342        it('converts percentages using the "٪" symbol', () => {343          expect(parseValue('83.35٪').grade.schemeKey).toEqual('B')344        })345        it('is set to the matching scheme key when given a numerical scheme key', () => {346          options.gradingScheme.data = [347            ['4.0', 0.9],348            ['3.0', 0.8],349            ['2.0', 0.7],350            ['1.0', 0.6],351            ['0.0', 0.5]352          ]353          expect(parseValue('3.0').grade.schemeKey).toEqual('3.0')354        })355        it('is set to the matching scheme key when given a percentage scheme key', () => {356          options.gradingScheme.data = [357            ['95%', 0.9],358            ['85%', 0.8],359            ['75%', 0.7],360            ['65%', 0.6],361            ['0%', 0.5]362          ]363          expect(parseValue('95%').grade.schemeKey).toEqual('95%')364        })365        it('is set to the lowest scheme key when given zero', () => {366          expect(parseValue(0).grade.schemeKey).toEqual('F')367        })368        it('ignores whitespace from the given value when setting the grade', () => {369          expect(parseValue(' B ').grade.schemeKey).toEqual('B')370        })371        it('is set to null when not using a grading scheme', () => {372          options.gradingScheme = null373          expect(parseValue('81.45').grade.schemeKey).toEqual(null)374        })375      })376      describe('when not using a grading scheme', () => {377        it('is set to null when given a non-numerical value', () => {378          options.gradingScheme = null379          expect(parseValue('B').grade).toEqual(null)380        })381      })382    })383    describe('.enteredAs', () => {384      const {GRADING_SCHEME, PERCENTAGE} = EnterGradesAs385      it(`is set to "${PERCENTAGE}" when given a number`, () => {386        expect(parseValue('8.34').enteredAs).toEqual(PERCENTAGE)387      })388      it(`is set to "${PERCENTAGE}" when given a percentage`, () => {389        expect(parseValue('83.45%').enteredAs).toEqual(PERCENTAGE)390      })391      it(`is set to "${GRADING_SCHEME}" when given a grading scheme key`, () => {392        expect(parseValue('B').enteredAs).toEqual(GRADING_SCHEME)393      })394      it(`is set to "${GRADING_SCHEME}" when given a numerical value which matches a grading scheme key`, () => {395        options.gradingScheme.data = [396          ['4.0', 0.9],397          ['3.0', 0.8],398          ['2.0', 0.7],399          ['1.0', 0.6],400          ['0.0', 0.5]401        ]402        expect(parseValue('3.0').enteredAs).toEqual(GRADING_SCHEME)403      })404      it(`is set to "${GRADING_SCHEME}" when given a percentage value which matches a grading scheme key`, () => {405        options.gradingScheme.data = [406          ['95%', 0.9],407          ['85%', 0.8],408          ['75%', 0.7],409          ['65%', 0.6],410          ['0%', 0.5]411        ]412        expect(parseValue('85%').enteredAs).toEqual(GRADING_SCHEME)413      })414      it('is set to null when given a non-numerical string not in the grading scheme', () => {415        expect(parseValue('B-').enteredAs).toEqual(null)416      })417      it('is set to null when given "EX"', () => {418        expect(parseValue('EX').enteredAs).toEqual(null)419      })420      it('is set to null when the grade is cleared', () => {421        expect(parseValue('').enteredAs).toEqual(null)422      })423      describe('when not using a grading scheme', () => {424        beforeEach(() => {425          options.gradingScheme = null426        })427        it(`is set to "${PERCENTAGE}" when given a number`, () => {428          expect(parseValue('81.45%').enteredAs).toEqual(PERCENTAGE)429        })430        it(`is set to "${PERCENTAGE}" when given a percentage`, () => {431          expect(parseValue('81.45').enteredAs).toEqual(PERCENTAGE)432        })433        it('is set to false when given a non-numerical value', () => {434          expect(parseValue('B').valid).toBe(false)435        })436      })437    })438    describe('.valid', () => {439      it('is set to true when the grade is a valid number', () => {440        expect(parseValue('8.34').valid).toBe(true)441      })442      it('is set to true when the grade is a valid percentage', () => {443        expect(parseValue('83.4%').valid).toBe(true)444      })445      it('is set to true when the grade is a valid grading scheme key', () => {446        expect(parseValue('B').valid).toBe(true)447      })448      it('is set to true when the grade is cleared', () => {449        expect(parseValue('').valid).toBe(true)450      })451      it('is set to false when the value is "EX"', () => {452        expect(parseValue('EX').valid).toBe(false)453      })454      it('is set to false when given non-numerical string not in the grading scheme', () => {455        expect(parseValue('B-').valid).toBe(false)456      })457      describe('when not using a grading scheme', () => {458        beforeEach(() => {459          options.gradingScheme = null460        })461        it('is set to true when given a number', () => {462          expect(parseValue('81.45').valid).toBe(true)463        })464        it('is set to true when given a percentage', () => {465          expect(parseValue('81.45%').valid).toBe(true)466        })467        it('is set to false when given a non-numerical value', () => {468          expect(parseValue('B').valid).toBe(false)469        })470      })471    })472  })473  describe('#gradeInfoFromGrade()', () => {474    function gradeInfoFromGrade(grade) {475      return new GradeOverrideEntry(options).gradeInfoFromGrade(grade)476    }477    describe('.grade', () => {478      it('is set to null when the given grade is null', () => {479        expect(gradeInfoFromGrade(null).grade).toEqual(null)480      })481      it('is set to null when the given grade percentage is null', () => {482        expect(gradeInfoFromGrade({percentage: null}).grade).toEqual(null)...

Full Screen

Full Screen

scalars-test.js

Source:scalars-test.js Github

copy

Full Screen

...4import { GraphQLID, GraphQLInt, GraphQLFloat, GraphQLString, GraphQLBoolean } from '../scalars.js';5describe('Type System: Specified scalar types', () => {6  describe('GraphQLInt', () => {7    it('parseValue', () => {8      function parseValue(value) {9        return GraphQLInt.parseValue(value);10      }11      expect(parseValue(1)).to.equal(1);12      expect(parseValue(0)).to.equal(0);13      expect(parseValue(-1)).to.equal(-1);14      expect(() => parseValue(9876504321)).to.throw('Int cannot represent non 32-bit signed integer value: 9876504321');15      expect(() => parseValue(-9876504321)).to.throw('Int cannot represent non 32-bit signed integer value: -9876504321');16      expect(() => parseValue(0.1)).to.throw('Int cannot represent non-integer value: 0.1');17      expect(() => parseValue(NaN)).to.throw('Int cannot represent non-integer value: NaN');18      expect(() => parseValue(Infinity)).to.throw('Int cannot represent non-integer value: Infinity');19      expect(() => parseValue(undefined)).to.throw('Int cannot represent non-integer value: undefined');20      expect(() => parseValue(null)).to.throw('Int cannot represent non-integer value: null');21      expect(() => parseValue('')).to.throw('Int cannot represent non-integer value: ""');22      expect(() => parseValue('123')).to.throw('Int cannot represent non-integer value: "123"');23      expect(() => parseValue(false)).to.throw('Int cannot represent non-integer value: false');24      expect(() => parseValue(true)).to.throw('Int cannot represent non-integer value: true');25      expect(() => parseValue([1])).to.throw('Int cannot represent non-integer value: [1]');26      expect(() => parseValue({27        value: 128      })).to.throw('Int cannot represent non-integer value: { value: 1 }');29    });30    it('parseLiteral', () => {31      function parseLiteral(str) {32        return GraphQLInt.parseLiteral(parseValueToAST(str));33      }34      expect(parseLiteral('1')).to.equal(1);35      expect(parseLiteral('0')).to.equal(0);36      expect(parseLiteral('-1')).to.equal(-1);37      expect(() => parseLiteral('9876504321')).to.throw('Int cannot represent non 32-bit signed integer value: 9876504321');38      expect(() => parseLiteral('-9876504321')).to.throw('Int cannot represent non 32-bit signed integer value: -9876504321');39      expect(() => parseLiteral('1.0')).to.throw('Int cannot represent non-integer value: 1.0');40      expect(() => parseLiteral('null')).to.throw('Int cannot represent non-integer value: null');41      expect(() => parseLiteral('""')).to.throw('Int cannot represent non-integer value: ""');42      expect(() => parseLiteral('"123"')).to.throw('Int cannot represent non-integer value: "123"');43      expect(() => parseLiteral('false')).to.throw('Int cannot represent non-integer value: false');44      expect(() => parseLiteral('[1]')).to.throw('Int cannot represent non-integer value: [1]');45      expect(() => parseLiteral('{ value: 1 }')).to.throw('Int cannot represent non-integer value: {value: 1}');46      expect(() => parseLiteral('ENUM_VALUE')).to.throw('Int cannot represent non-integer value: ENUM_VALUE');47      expect(() => parseLiteral('$var')).to.throw('Int cannot represent non-integer value: $var');48    });49  });50  describe('GraphQLFloat', () => {51    it('parseValue', () => {52      function parseValue(value) {53        return GraphQLFloat.parseValue(value);54      }55      expect(parseValue(1)).to.equal(1);56      expect(parseValue(0)).to.equal(0);57      expect(parseValue(-1)).to.equal(-1);58      expect(parseValue(0.1)).to.equal(0.1);59      expect(parseValue(Math.PI)).to.equal(Math.PI);60      expect(() => parseValue(NaN)).to.throw('Float cannot represent non numeric value: NaN');61      expect(() => parseValue(Infinity)).to.throw('Float cannot represent non numeric value: Infinity');62      expect(() => parseValue(undefined)).to.throw('Float cannot represent non numeric value: undefined');63      expect(() => parseValue(null)).to.throw('Float cannot represent non numeric value: null');64      expect(() => parseValue('')).to.throw('Float cannot represent non numeric value: ""');65      expect(() => parseValue('123')).to.throw('Float cannot represent non numeric value: "123"');66      expect(() => parseValue('123.5')).to.throw('Float cannot represent non numeric value: "123.5"');67      expect(() => parseValue(false)).to.throw('Float cannot represent non numeric value: false');68      expect(() => parseValue(true)).to.throw('Float cannot represent non numeric value: true');69      expect(() => parseValue([0.1])).to.throw('Float cannot represent non numeric value: [0.1]');70      expect(() => parseValue({71        value: 0.172      })).to.throw('Float cannot represent non numeric value: { value: 0.1 }');73    });74    it('parseLiteral', () => {75      function parseLiteral(str) {76        return GraphQLFloat.parseLiteral(parseValueToAST(str));77      }78      expect(parseLiteral('1')).to.equal(1);79      expect(parseLiteral('0')).to.equal(0);80      expect(parseLiteral('-1')).to.equal(-1);81      expect(parseLiteral('0.1')).to.equal(0.1);82      expect(parseLiteral(Math.PI.toString())).to.equal(Math.PI);83      expect(() => parseLiteral('null')).to.throw('Float cannot represent non numeric value: null');84      expect(() => parseLiteral('""')).to.throw('Float cannot represent non numeric value: ""');85      expect(() => parseLiteral('"123"')).to.throw('Float cannot represent non numeric value: "123"');86      expect(() => parseLiteral('"123.5"')).to.throw('Float cannot represent non numeric value: "123.5"');87      expect(() => parseLiteral('false')).to.throw('Float cannot represent non numeric value: false');88      expect(() => parseLiteral('[0.1]')).to.throw('Float cannot represent non numeric value: [0.1]');89      expect(() => parseLiteral('{ value: 0.1 }')).to.throw('Float cannot represent non numeric value: {value: 0.1}');90      expect(() => parseLiteral('ENUM_VALUE')).to.throw('Float cannot represent non numeric value: ENUM_VALUE');91      expect(() => parseLiteral('$var')).to.throw('Float cannot represent non numeric value: $var');92    });93  });94  describe('GraphQLString', () => {95    it('parseValue', () => {96      function parseValue(value) {97        return GraphQLString.parseValue(value);98      }99      expect(parseValue('foo')).to.equal('foo');100      expect(() => parseValue(undefined)).to.throw('String cannot represent a non string value: undefined');101      expect(() => parseValue(null)).to.throw('String cannot represent a non string value: null');102      expect(() => parseValue(1)).to.throw('String cannot represent a non string value: 1');103      expect(() => parseValue(NaN)).to.throw('String cannot represent a non string value: NaN');104      expect(() => parseValue(false)).to.throw('String cannot represent a non string value: false');105      expect(() => parseValue(['foo'])).to.throw('String cannot represent a non string value: ["foo"]');106      expect(() => parseValue({107        value: 'foo'108      })).to.throw('String cannot represent a non string value: { value: "foo" }');109    });110    it('parseLiteral', () => {111      function parseLiteral(str) {112        return GraphQLString.parseLiteral(parseValueToAST(str));113      }114      expect(parseLiteral('"foo"')).to.equal('foo');115      expect(parseLiteral('"""bar"""')).to.equal('bar');116      expect(() => parseLiteral('null')).to.throw('String cannot represent a non string value: null');117      expect(() => parseLiteral('1')).to.throw('String cannot represent a non string value: 1');118      expect(() => parseLiteral('0.1')).to.throw('String cannot represent a non string value: 0.1');119      expect(() => parseLiteral('false')).to.throw('String cannot represent a non string value: false');120      expect(() => parseLiteral('["foo"]')).to.throw('String cannot represent a non string value: ["foo"]');121      expect(() => parseLiteral('{ value: "foo" }')).to.throw('String cannot represent a non string value: {value: "foo"}');122      expect(() => parseLiteral('ENUM_VALUE')).to.throw('String cannot represent a non string value: ENUM_VALUE');123      expect(() => parseLiteral('$var')).to.throw('String cannot represent a non string value: $var');124    });125  });126  describe('GraphQLBoolean', () => {127    it('parseValue', () => {128      function parseValue(value) {129        return GraphQLBoolean.parseValue(value);130      }131      expect(parseValue(true)).to.equal(true);132      expect(parseValue(false)).to.equal(false);133      expect(() => parseValue(undefined)).to.throw('Boolean cannot represent a non boolean value: undefined');134      expect(() => parseValue(null)).to.throw('Boolean cannot represent a non boolean value: null');135      expect(() => parseValue(0)).to.throw('Boolean cannot represent a non boolean value: 0');136      expect(() => parseValue(1)).to.throw('Boolean cannot represent a non boolean value: 1');137      expect(() => parseValue(NaN)).to.throw('Boolean cannot represent a non boolean value: NaN');138      expect(() => parseValue('')).to.throw('Boolean cannot represent a non boolean value: ""');139      expect(() => parseValue('false')).to.throw('Boolean cannot represent a non boolean value: "false"');140      expect(() => parseValue([false])).to.throw('Boolean cannot represent a non boolean value: [false]');141      expect(() => parseValue({142        value: false143      })).to.throw('Boolean cannot represent a non boolean value: { value: false }');144    });145    it('parseLiteral', () => {146      function parseLiteral(str) {147        return GraphQLBoolean.parseLiteral(parseValueToAST(str));148      }149      expect(parseLiteral('true')).to.equal(true);150      expect(parseLiteral('false')).to.equal(false);151      expect(() => parseLiteral('null')).to.throw('Boolean cannot represent a non boolean value: null');152      expect(() => parseLiteral('0')).to.throw('Boolean cannot represent a non boolean value: 0');153      expect(() => parseLiteral('1')).to.throw('Boolean cannot represent a non boolean value: 1');154      expect(() => parseLiteral('0.1')).to.throw('Boolean cannot represent a non boolean value: 0.1');155      expect(() => parseLiteral('""')).to.throw('Boolean cannot represent a non boolean value: ""');156      expect(() => parseLiteral('"false"')).to.throw('Boolean cannot represent a non boolean value: "false"');157      expect(() => parseLiteral('[false]')).to.throw('Boolean cannot represent a non boolean value: [false]');158      expect(() => parseLiteral('{ value: false }')).to.throw('Boolean cannot represent a non boolean value: {value: false}');159      expect(() => parseLiteral('ENUM_VALUE')).to.throw('Boolean cannot represent a non boolean value: ENUM_VALUE');160      expect(() => parseLiteral('$var')).to.throw('Boolean cannot represent a non boolean value: $var');161    });162  });163  describe('GraphQLID', () => {164    it('parseValue', () => {165      function parseValue(value) {166        return GraphQLID.parseValue(value);167      }168      expect(parseValue('')).to.equal('');169      expect(parseValue('1')).to.equal('1');170      expect(parseValue('foo')).to.equal('foo');171      expect(parseValue(1)).to.equal('1');172      expect(parseValue(0)).to.equal('0');173      expect(parseValue(-1)).to.equal('-1'); // Maximum and minimum safe numbers in JS174      expect(parseValue(9007199254740991)).to.equal('9007199254740991');175      expect(parseValue(-9007199254740991)).to.equal('-9007199254740991');176      expect(() => parseValue(undefined)).to.throw('ID cannot represent value: undefined');177      expect(() => parseValue(null)).to.throw('ID cannot represent value: null');178      expect(() => parseValue(0.1)).to.throw('ID cannot represent value: 0.1');179      expect(() => parseValue(NaN)).to.throw('ID cannot represent value: NaN');180      expect(() => parseValue(Infinity)).to.throw('ID cannot represent value: Inf');181      expect(() => parseValue(false)).to.throw('ID cannot represent value: false');182      expect(() => GraphQLID.parseValue(['1'])).to.throw('ID cannot represent value: ["1"]');183      expect(() => GraphQLID.parseValue({184        value: '1'185      })).to.throw('ID cannot represent value: { value: "1" }');186    });187    it('parseLiteral', () => {188      function parseLiteral(str) {189        return GraphQLID.parseLiteral(parseValueToAST(str));190      }191      expect(parseLiteral('""')).to.equal('');192      expect(parseLiteral('"1"')).to.equal('1');193      expect(parseLiteral('"foo"')).to.equal('foo');194      expect(parseLiteral('"""foo"""')).to.equal('foo');195      expect(parseLiteral('1')).to.equal('1');196      expect(parseLiteral('0')).to.equal('0');197      expect(parseLiteral('-1')).to.equal('-1'); // Support arbitrary long numbers even if they can't be represented in JS...

Full Screen

Full Screen

loanDetail.save.js

Source:loanDetail.save.js Github

copy

Full Screen

1const validation = require('../../shared/util/validation');2const parseValue = require('../util/parseValue');3module.exports = function LoanDetailResponse(params, ShortLoanTerm, MidLoanTerm, LongLoanTerm, OtherLoanTerm, niceSessionKey, sysDtim, workID) {4    const {5        cicFiCode,6        cicFiName,7        recentReportDate,8        seq,9        shortTermLoanVnd,10        shortTermLoanUsd,11        midTermLoadVnd,12        midTermLoadUsd,13        longTermLoanVnd,14        longTermLoanUsd,15        otherLoanVnd,16        otherLoanUsd,17        otherBadLoanVnd,18        otherBadLoanUsd,19        totalLoanVnd,20        totalLoanUsd,21        waitData22    } = params;23    const {24        shortTermNormalLoanVnd,25        shortTermNormalLoanUsd,26        shortTermCautiousLoanVnd,27        shortTermCautiousLoanUsd,28        shortTermFixedLoanVnd,29        shortTermFixedLoanUsd,30        shortTermDaubtLoanVnd,31        shortTermDaubtLoanUsd,32        shortTermEstLossLoanVnd,33        shortTermEstLossLoanUsd,34    } = ShortLoanTerm;35    const {36        midTermNormalLoanVnd,37        midTermNormalLoanUsd,38        midTermCautiousLoanVnd,39        midTermCautiousLoanUsd,40        midTermFixedLoanVnd,41        midTermFixedLoanUsd,42        midTermDaubtLoanVnd,43        midTermDaubtLoanUsd,44        midTermEstLossLoanVnd,45        midTermEstLossLoanUsd,46    } = MidLoanTerm;47    const {48        longTermNormalLoanVnd,49        longTermNormalLoanUsd,50        longTermCautiousLoanVnd,51        longTermCautiousLoanUsd,52        longTermFixedLoanVnd,53        longTermfixedLoanUsd,54        longTermDaubtLoanVnd,55        longTermDaubtLOanUsd,56        longTermEstLossLoanVnd,57        longTermEstLossLoanUsd,58    } = LongLoanTerm;59    const {60        otherNormalLoanVnd,61        otherNormalLoanUsd,62        otherCautousLoanVnd,63        otherCautousLoanUsd,64        otherFixedLoanVnd,65        otherFixedLoanUsd,66        otherDaubtLoanVnd,67        otherDaubtLoanUsd,68        otherEstLossLoanVnd,69        otherEstLossLoanUsd,70    } = OtherLoanTerm;71    this.NICE_SSIN_ID = niceSessionKey;72    this.SEQ = parseInt(seq);73    this.LOAD_DATE = sysDtim.substr(0, 8);74    this.LOAD_TIME = sysDtim.substr(8);75    this.OGZ_CD = cicFiCode ? cicFiCode : null;76    this.OGZ_NM = cicFiName ? cicFiName : null;77    this.RCT_RPT_DATE = recentReportDate ? recentReportDate : null;78    this.ST_LOAN_VND = shortTermLoanVnd ? parseValue.parseFloat(shortTermLoanVnd) : validation.setEmptyValue(shortTermLoanVnd);79    this.ST_LOAN_USD = shortTermLoanUsd ? parseValue.parseFloat(shortTermLoanUsd) : validation.setEmptyValue(shortTermLoanUsd);80    this.ST_NORM_LOAN_VND = shortTermNormalLoanVnd ? parseValue.parseFloat(shortTermNormalLoanVnd) : validation.setEmptyValue(shortTermNormalLoanVnd);81    this.ST_NORM_LOAN_USD = shortTermNormalLoanUsd ? parseValue.parseFloat(shortTermNormalLoanUsd) : validation.setEmptyValue(shortTermNormalLoanUsd);82    this.ST_CAT_LOAN_VND = shortTermCautiousLoanVnd ? parseValue.parseFloat(shortTermCautiousLoanVnd) : validation.setEmptyValue(shortTermCautiousLoanVnd);83    this.ST_CAT_LOAN_USD = shortTermCautiousLoanUsd ? parseValue.parseFloat(shortTermCautiousLoanUsd) : validation.setEmptyValue(shortTermCautiousLoanUsd);84    this.ST_FIX_LOAN_VND = shortTermFixedLoanVnd ? parseValue.parseFloat(shortTermFixedLoanVnd) : validation.setEmptyValue(shortTermFixedLoanVnd);85    this.ST_FIX_LOAN_USD = shortTermFixedLoanUsd ? parseValue.parseFloat(shortTermFixedLoanUsd) : validation.setEmptyValue(shortTermFixedLoanUsd);86    this.ST_CQ_LOAN_VND = shortTermDaubtLoanVnd ? parseValue.parseFloat(shortTermDaubtLoanVnd) : validation.setEmptyValue(shortTermDaubtLoanVnd);87    this.ST_CQ_LOAN_USD = shortTermDaubtLoanUsd ? parseValue.parseFloat(shortTermDaubtLoanUsd) : validation.setEmptyValue(shortTermDaubtLoanUsd);88    this.ST_EL_LOAN_VND = shortTermEstLossLoanVnd ? parseValue.parseFloat(shortTermEstLossLoanVnd) : validation.setEmptyValue(shortTermEstLossLoanVnd);89    this.ST_EL_LOAN_USD = shortTermEstLossLoanUsd ? parseValue.parseFloat(shortTermEstLossLoanUsd) : validation.setEmptyValue(shortTermEstLossLoanUsd);90    this.MT_LOAN_VND = midTermLoadVnd ? parseValue.parseFloat(midTermLoadVnd) : validation.setEmptyValue(midTermLoadVnd);91    this.MT_LOAN_UDS = midTermLoadUsd ? parseValue.parseFloat(midTermLoadUsd) : validation.setEmptyValue(midTermLoadUsd);92    this.MT_NORM_LOAN_VND = midTermNormalLoanVnd ? parseValue.parseFloat(midTermNormalLoanVnd) : validation.setEmptyValue(midTermNormalLoanVnd);93    this.MT_NORM_LOAN_USD = midTermNormalLoanUsd ? parseValue.parseFloat(midTermNormalLoanUsd) : validation.setEmptyValue(midTermNormalLoanUsd);94    this.MT_CAT_LOAN_VND = midTermCautiousLoanVnd ? parseValue.parseFloat(midTermCautiousLoanVnd) : validation.setEmptyValue(midTermCautiousLoanVnd);95    this.MT_CAT_LOAN_USD = midTermCautiousLoanUsd ? parseValue.parseFloat(midTermCautiousLoanUsd) : validation.setEmptyValue(midTermCautiousLoanUsd);96    this.MT_FIX_LOAN_VND = midTermFixedLoanVnd ? parseValue.parseFloat(midTermFixedLoanVnd) : validation.setEmptyValue(midTermFixedLoanVnd);97    this.MT_FIX_LOAN_USD = midTermFixedLoanUsd ? parseValue.parseFloat(midTermFixedLoanUsd) : validation.setEmptyValue(midTermFixedLoanUsd);98    this.MT_CQ_LOAN_VND = midTermDaubtLoanVnd ? parseValue.parseFloat(midTermDaubtLoanVnd) : validation.setEmptyValue(midTermDaubtLoanVnd);99    this.MT_CQ_LOAN_USD = midTermDaubtLoanUsd ? parseValue.parseFloat(midTermDaubtLoanUsd) : validation.setEmptyValue(midTermDaubtLoanUsd);100    this.MT_EL_LOAN_VND = midTermEstLossLoanVnd ? parseValue.parseFloat(midTermEstLossLoanVnd) : validation.setEmptyValue(midTermEstLossLoanVnd);101    this.MT_EL_LOAN_USD = midTermEstLossLoanUsd ? parseValue.parseFloat(midTermEstLossLoanUsd) : validation.setEmptyValue(midTermEstLossLoanUsd);102    this.LT_LOAN_VND = longTermLoanVnd ? parseValue.parseFloat(longTermLoanVnd) : validation.setEmptyValue(longTermLoanVnd);103    this.LT_LOAN_USD = longTermLoanUsd ? parseValue.parseFloat(longTermLoanUsd) : validation.setEmptyValue(longTermLoanUsd);104    this.LT_NORM_LOAN_VND = longTermNormalLoanVnd ? parseValue.parseFloat(longTermNormalLoanVnd) : validation.setEmptyValue(longTermNormalLoanVnd);105    this.LT_NORM_LOAN_USD = longTermNormalLoanUsd ? parseValue.parseFloat(longTermNormalLoanUsd) : validation.setEmptyValue(longTermNormalLoanUsd);106    this.LT_CAT_LOAN_VND = longTermCautiousLoanVnd ? parseValue.parseFloat(longTermCautiousLoanVnd) : validation.setEmptyValue(longTermCautiousLoanVnd);107    this.LT_CAT_LOAN_USD = longTermCautiousLoanUsd ? parseValue.parseFloat(longTermCautiousLoanUsd) : validation.setEmptyValue(longTermCautiousLoanUsd);108    this.LT_FIX_LOAN_VND = longTermFixedLoanVnd ? parseValue.parseFloat(longTermFixedLoanVnd) : validation.setEmptyValue(longTermFixedLoanVnd);109    this.LT_FIX_LOAN_USD = longTermfixedLoanUsd ? parseValue.parseFloat(longTermfixedLoanUsd) : validation.setEmptyValue(longTermfixedLoanUsd);110    this.LT_CQ_LOAN_VND = longTermDaubtLoanVnd ? parseValue.parseFloat(longTermDaubtLoanVnd) : validation.setEmptyValue(longTermDaubtLoanVnd);111    this.LT_CQ_LOAN_USD = longTermDaubtLOanUsd ? parseValue.parseFloat(longTermDaubtLOanUsd) : validation.setEmptyValue(longTermDaubtLOanUsd);112    this.LT_EL_LOAN_VND = longTermEstLossLoanVnd ? parseValue.parseFloat(longTermEstLossLoanVnd) : validation.setEmptyValue(longTermEstLossLoanVnd);113    this.LT_EL_LOAN_USD = longTermEstLossLoanUsd ? parseValue.parseFloat(longTermEstLossLoanUsd) : validation.setEmptyValue(longTermEstLossLoanUsd);114    this.OTR_LOAN_VND = otherLoanVnd ? parseValue.parseFloat(otherLoanVnd) : validation.setEmptyValue(otherLoanVnd);115    this.OTR_LOAN_USD = otherLoanUsd ? parseValue.parseFloat(otherLoanUsd) : validation.setEmptyValue(otherLoanUsd);116    this.OTR_NORM_LOAN_VND = otherNormalLoanVnd ? parseValue.parseFloat(otherNormalLoanVnd) : validation.setEmptyValueotherNormalLoanVnd117    this.OTR_NORM_LOAN_USD = otherNormalLoanUsd ? parseValue.parseFloat(otherNormalLoanUsd) : validation.setEmptyValue(otherNormalLoanUsd);118    this.OTR_CAT_LOAN_VND = otherCautousLoanVnd ? parseValue.parseFloat(otherCautousLoanVnd) : validation.setEmptyValue(otherCautousLoanVnd);119    this.OTR_CAT_LOAN_USD = otherCautousLoanUsd ? parseValue.parseFloat(otherCautousLoanUsd) : validation.setEmptyValue(otherCautousLoanUsd);120    this.OTR_FIX_LOAN_VND = otherFixedLoanVnd ? parseValue.parseFloat(otherFixedLoanVnd) : validation.setEmptyValue(otherFixedLoanVnd);121    this.OTR_FIX_LOAN_USD = otherFixedLoanUsd ? parseValue.parseFloat(otherFixedLoanUsd) : validation.setEmptyValue(otherFixedLoanUsd);122    this.OTR_CQ_LOAN_VND = otherDaubtLoanVnd ? parseValue.parseFloat(otherDaubtLoanVnd) : validation.setEmptyValue(otherDaubtLoanVnd);123    this.OTR_CQ_LOAN_USD = otherDaubtLoanUsd ? parseValue.parseFloat(otherDaubtLoanUsd) : validation.setEmptyValue(otherDaubtLoanUsd);124    this.OTR_EL_LOAN_VND = otherEstLossLoanVnd ? parseValue.parseFloat(otherEstLossLoanVnd) : validation.setEmptyValue(otherEstLossLoanVnd);125    this.OTR_EL_LOAN_USD = otherEstLossLoanUsd ? parseValue.parseFloat(otherEstLossLoanUsd) : validation.setEmptyValue(otherEstLossLoanUsd);126    this.OTR_BAD_LOAN_VND = otherBadLoanVnd ? parseValue.parseFloat(otherBadLoanVnd) : validation.setEmptyValue(otherBadLoanVnd);127    this.OTR_BAD_LOAN_USD = otherBadLoanUsd ? parseValue.parseFloat(otherBadLoanUsd) : validation.setEmptyValue(otherBadLoanUsd);128    let _shortTermLoanVnd = shortTermLoanVnd ? parseFloat(shortTermLoanVnd) : 0;129    let _midTermLoadVnd = midTermLoadVnd ? parseFloat(midTermLoadVnd) : 0;130    let _longTermLoanVnd = longTermLoanVnd ? parseFloat(longTermLoanVnd) : 0;131    let _otherBadLoanVnd = otherBadLoanVnd ? parseFloat(otherBadLoanVnd) : 0;132    let _shortTermLoanUsd = shortTermLoanUsd ? parseFloat(shortTermLoanUsd) : 0;133    let _midTermLoadUsd = midTermLoadUsd ? parseFloat(midTermLoadUsd) : 0;134    let _longTermLoanUsd = longTermLoanUsd ? parseFloat(longTermLoanUsd) : 0;135    let _otherBadLoanUsd = otherBadLoanUsd ? parseFloat(otherBadLoanUsd) : 0;136    this.OGZ_TOT_LOAN_VND = parseFloat(_shortTermLoanVnd + _midTermLoadVnd + _longTermLoanVnd + _otherBadLoanVnd);137    this.OGZ_TOT_LOAN_USD = parseFloat(_shortTermLoanUsd + _midTermLoadUsd + _longTermLoanUsd + _otherBadLoanUsd);138    this.SUM_TOT_OGZ_VND = waitData ? waitData : null;139    this.SUM_TOT_OGZ_USD = waitData ? waitData : null;140    this.SYS_DTIM = sysDtim;141    this.WORK_ID = workID;...

Full Screen

Full Screen

Parser.test.js

Source:Parser.test.js Github

copy

Full Screen

...31		});32	});33	describe('parseValue', () => {34		it('should parse boolean representation', () => {35			expect(Parser.parseValue('true', DEF_CONTEXT).value).toBe(true);36			expect(Parser.parseValue('TrUe', DEF_CONTEXT).value).toBe(true);37			expect(Parser.parseValue('false', DEF_CONTEXT).value).toBe(false);38			expect(Parser.parseValue('fAlsE', DEF_CONTEXT).value).toBe(false);39		});40		it('should parse number representation', () => {41			expect(Parser.parseValue('0', DEF_CONTEXT).value).toBe(0);42			expect(Parser.parseValue('56', DEF_CONTEXT).value).toBe(56);43			expect(Parser.parseValue('-23', DEF_CONTEXT).value).toBe(-23);44			expect(Parser.parseValue('1234.56789', DEF_CONTEXT).value).toBe(1234.56789);45		});46		it('should parse number with custom decimal separators', () => {47			const contextDE = new ParserContext();48			contextDE.separators = Locale.DE.separators;49			// note that internally we use JS numbers!!50			expect(Parser.parseValue('0,00', contextDE).value).toBe(0.00);51			expect(Parser.parseValue('0,123', contextDE).value).toBe(0.123);52			expect(Parser.parseValue('1234,56789', contextDE).value).toBe(1234.56789);53		});54		it('should parse any string', () => {55			expect(Parser.parseValue('2,4 + 5,6', DEF_CONTEXT).value).toBe('2,4 + 5,6');56			expect(Parser.parseValue('A1:D4', DEF_CONTEXT).value).toBe('A1:D4');57			expect(Parser.parseValue('SUM(1;2)', DEF_CONTEXT).value).toBe('SUM(1;2)');58			expect(Parser.parseValue('400 / 2 + 400 / 2 * 0,5 * (1 - 2 * 2)', DEF_CONTEXT).value)59				.toBe('400 / 2 + 400 / 2 * 0,5 * (1 - 2 * 2)');60			expect(Parser.parseValue('SUM (1,2,MAX  (0,3,2,1),4,MAX (5,3,4))', DEF_CONTEXT).value)61				.toBe('SUM (1,2,MAX  (0,3,2,1),4,MAX (5,3,4))');62		});63		// DL-152964		it('should keep leading or trailing spaces when parsing string', () => {65			expect(Parser.parseValue('   hello', DEF_CONTEXT).value).toBe('   hello');66			expect(Parser.parseValue('hello    ', DEF_CONTEXT).value).toBe('hello    ');67			expect(Parser.parseValue('   hi    ', DEF_CONTEXT).value).toBe('   hi    ');68		});69		it('should return string term if provided value is not a valid boolean or number', () => {70			expect(Parser.parseValue('true 12', DEF_CONTEXT).value).toBe('true 12');71			expect(Parser.parseValue('false42', DEF_CONTEXT).value).toBe('false42');72			expect(Parser.parseValue('0,00', DEF_CONTEXT).value).toBe('0,00');73			expect(Parser.parseValue('0,123', DEF_CONTEXT).value).toBe('0,123');74			// octal values in excel?75			expect(Parser.parseValue('0x00', DEF_CONTEXT).value).toBe('0x00');76			expect(Parser.parseValue('1 means', DEF_CONTEXT).value).toBe('1 means');77			expect(Parser.parseValue('42,', DEF_CONTEXT).value).toBe('42,');78			expect(Parser.parseValue('1. 23', DEF_CONTEXT).value).toBe('1. 23');79			expect(Parser.parseValue('1. topic', DEF_CONTEXT).value).toBe('1. topic');80			// change parameter separators81			const contextDE = new ParserContext();82			contextDE.separators = Locale.DE.separators;83			expect(Parser.parseValue('42,', contextDE).value).toBe(42);84			expect(Parser.parseValue('42,00', contextDE).value).toBe(42.00);85			expect(Parser.parseValue('23,ab', contextDE).value).toBe('23,ab');86			expect(Parser.parseValue('1.', contextDE).value).toBe('1.');87			expect(Parser.parseValue('23.45', contextDE).value).toBe('23.45');88		});89	});90	describe('getFormulaInfos', () => {91		it('should return a list of info objects for given formula', () => {92			const ctxt = new ParserContext();93			const infos = Parser.getFormulaInfos('sum(B1)', ctxt);94			expect(infos).toBeDefined();95			expect(infos.length).toBe(2);96		});97		it('should sort returned list by start position', () => {98			const ctxt = new ParserContext();99			const infos = Parser.getFormulaInfos('sum(B1,sum(A1))', ctxt);100			expect(infos.length).toBe(4);101			const ascending = infos.every((info, index) => index < 1 || info.start > infos[index - 1].start);...

Full Screen

Full Screen

eosio_types.test.mjs

Source:eosio_types.test.mjs Github

copy

Full Screen

...18import varint32 from '../private/eosio_types/varint32_type.js'19import varuint32 from '../private/eosio_types/varuint32_type.js'20export default tests => {21  tests.add('EOSIO types - validating parse values', async () => {22    deepStrictEqual(varint32.parseValue(''), '')23    deepStrictEqual(varuint32.parseValue(''), '')24    strictEqual(time_point.parseValue('1616667468'), '1616667468')25    strictEqual(time_point_sec.parseValue('1616667453647'), '1616667453647')26    deepStrictEqual(symbol.parseValue('3,EOS'), '3,EOS')27    deepStrictEqual(symbol_code.parseValue('EOS'), 'EOS')28    deepStrictEqual(29      signature.parseValue(30        'SIG_K1_K4jhCs4S3hVfXNhX4t6QSSGgdYTYNk6LhKTphcYoLH6EYatq3zvU38CNEj7VDtMmHWq24KhmR6CLBqyT5tFiFmXndthr7X'31      ),32      'SIG_K1_K4jhCs4S3hVfXNhX4t6QSSGgdYTYNk6LhKTphcYoLH6EYatq3zvU38CNEj7VDtMmHWq24KhmR6CLBqyT5tFiFmXndthr7X'33    )34    ok(signature.parseValue('') == '')35    throws(() =>36      signature.parseValue(37        'NOT_SIG_K4jhCs4S3hVfXNhX4t6QSSGgdYTYNk6LhKTphcYoLH6EYatq3zvU38CNEj7VDtMmHWq24KhmR6CLBqyT5tFiFmXndthr4x'38      )39    )40    throws(() => signature.parseValue(1848))41    ok(asset_type.parseValue('') == '')42    strictEqual(asset_type.parseValue('1.000 EOS'), '1.000 EOS')43    deepStrictEqual(block_time_stamp.parseValue(''), '')44    throws(() => block_time_stamp.parseValue('not a time'))45    deepStrictEqual(46      block_time_stamp.parseValue('2021-03-01T12:26:42.147'),47      '2021-03-01T12:26:42.147'48    )49    deepStrictEqual(bool.parseValue(true), true)50    ok(bytes.parseValue('ff') == '02ff')51    throws(() => bytes.parseValue('kl'))52    ok(bytes.parseValue('') == '')53    deepStrictEqual(54      extended_asset.parseValue('1.000 EOS@eosio'),55      '1.000 EOS@eosio'56    )57    deepStrictEqual(58      generate_checksum(20).parseValue(59        'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'60      ),61      'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'62    )63    ok(generate_float_type(32).parseValue('1.0'), '1.0')64    deepStrictEqual(generate_int_type(8).parseValue(127), '127')65    deepStrictEqual(generate_int_type(8).parseValue(-128), '-128')66    throws(() => generate_int_type(8).parseValue(-129))67    throws(() => generate_int_type(8).parseValue(128))68    ok(generate_int_type(8).parseValue('') == '')69    deepStrictEqual(generate_uint_type(8).parseValue(0), '0')70    deepStrictEqual(generate_uint_type(8).parseValue(255), '255')71    deepStrictEqual(generate_uint_type(16).parseValue(0xffff), '65535')72    throws(() => generate_uint_type(16).parseValue(0x10000))73    throws(() => generate_uint_type(8).parseValue(-1))74    ok(generate_uint_type(8).parseValue('') == '')75    deepStrictEqual(name.parseValue('eosio'), 'eosio')76    deepStrictEqual(name.parseValue(''), '')77    throws(() => name.parseValue('NOT A NAME'))78    deepStrictEqual(79      'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',80      await public_key.parseValue(81        'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV'82      )83    )84    deepStrictEqual('', await public_key.parseValue(''))85    rejects(86      () =>87        public_key.parseValue(88          'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW533'89        ),90      'expected invalid checksum'91    )92    rejects(93      () =>94        public_key.parseValue(95          'NOT_EOS_6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW533'96        ),97      'Expected invalid prefix'98    )99  })...

Full Screen

Full Screen

GraphQLValidatedNumber.test.js

Source:GraphQLValidatedNumber.test.js Github

copy

Full Screen

...9  });10  it('should throw on empty string', ()=> {11    const input = '';12    Assert.throws(()=> {13      Number.parseValue(input);14    }, /is not number/);15  });16  it('should support min value', ()=> {17    Number.min(10);18    Assert.equal(Number.parseValue(11), 11);19    Assert.throws(()=> {20      Number.parseValue(9);21    }, /below minimum value/);22  });23  it('should support max value', ()=> {24    Number.max(10);25    Assert.equal(Number.parseValue(10), 10);26    Assert.throws(()=> {27      Number.parseValue(11);28    }, /above maximum value/);29  });30  it('should support min and max values', ()=> {31    Number.max(10).min(5);32    Assert.equal(Number.parseValue(8), 8);33    Assert.throws(()=> {34      Number.parseValue(12);35    }, /above maximum value/);36    Assert.throws(()=> {37      Number.parseValue(3);38    }, /below minimum value/);39  });40  it('should support range', ()=> {41    Number.range([10, 20]);42    Assert.equal(Number.parseValue(12), 12);43    Assert.throws(()=> {44      Number.parseValue(24);45    }, /Number is not within range/);46  });47  it('should support lower limit', ()=> {48    Number.above(10);49    Assert.equal(Number.parseValue(11), 11);50    Assert.throws(()=> {51      Number.parseValue(10);52    }, /not above limit/);53  });54  it('should support upper limit', ()=> {55    Number.below(10);56    Assert.equal(Number.parseValue(9), 9);57    Assert.throws(()=> {58      Number.parseValue(10);59    }, /not below limit/);60  });61  it('should support upper and lower limits', ()=> {62    Number.above(2).below(10);63    Assert.equal(Number.parseValue(9), 9);64    Assert.throws(()=> {65      Number.parseValue(2);66    }, /not above limit/);67    Assert.throws(()=> {68      Number.parseValue(10);69    }, /not below limit/);70  });71  it('should support within', ()=> {72    Number.between([10, 20]);73    Assert.equal(Number.parseValue(10.1), 10.1);74    Assert.throws(()=> {75      Number.parseValue(20);76    }, /Number is not between limits/);77  });78  it('should support positive', ()=> {79    Number.positive();80    Assert.equal(Number.parseValue(9), 9);81    Assert.throws(()=> {82      Number.parseValue(-2);83    }, /not positive/);84  });85  it('should support negative', ()=> {86    Number.negative();87    Assert.equal(Number.parseValue(-9), -9);88    Assert.throws(()=> {89      Number.parseValue(0);90    }, /not negative/);91  });92  it('should support nonnegative', ()=> {93    Number.nonnegative();94    Assert.equal(Number.parseValue(0), 0);95    Assert.throws(()=> {96      Number.parseValue(-2);97    }, /negative/);98  });99  describe('.default(value)', ()=> {100    const DEFAULT = 10;101    const SometimesTen = new GraphQLValidatedNumber({102      name: 'SometimesTen'103    }).range([8, 16]).default(DEFAULT);104    it('should default null', ()=> {105      Assert.equal(SometimesTen.parseValue(null), DEFAULT);106    });107    it('should default undefined', ()=> {108      Assert.equal(SometimesTen.parseValue(undefined), DEFAULT);109    });110    it('should not default when numeric passed', ()=> {111      Assert.throws(()=> {112        SometimesTen.parseValue(40);113      }, /not within range/);114    });115    it('should not default when 0 passed', ()=> {116      Assert.throws(()=> {117        SometimesTen.parseValue(0);118      }, /not within range/);119    });120  });...

Full Screen

Full Screen

parseValue.spec.js

Source:parseValue.spec.js Github

copy

Full Screen

1import {2    parseValue,3} from '../transformData';4test('parseValue', () => {5    expect(parseValue(1234)).toEqual({6        sign: '',7        unsignedValue: '1234',8        integerValue: '1234',9        decimals: '',10    });11    expect(parseValue('1234')).toEqual({12        sign: '',13        unsignedValue: '1234',14        integerValue: '1234',15        decimals: '',16    });17    expect(parseValue('12,345')).toEqual({18        sign: '',19        unsignedValue: '12345',20        integerValue: '12345',21        decimals: '',22    });23    expect(parseValue(-123)).toEqual({24        sign: '-',25        unsignedValue: '123',26        integerValue: '123',27        decimals: '',28    });29    expect(parseValue('-1,234,567')).toEqual({30        sign: '-',31        unsignedValue: '1234567',32        integerValue: '1234567',33        decimals: '',34    });35    expect(parseValue('1,234,567,890,123,456,789')).toEqual({36        sign: '',37        unsignedValue: '1234567890123456789',38        integerValue: '1234567890123456789',39        decimals: '',40    });41    expect(parseValue(1000.12)).toEqual({42        sign: '',43        unsignedValue: '1000.12',44        integerValue: '1000',45        decimals: '12',46    });47    expect(parseValue('12,345.001')).toEqual({48        sign: '',49        unsignedValue: '12345.001',50        integerValue: '12345',51        decimals: '001',52    });53    expect(parseValue('-1,234,567.890')).toEqual({54        sign: '-',55        unsignedValue: '1234567.89',56        integerValue: '1234567',57        decimals: '89',58    });59    expect(parseValue('-1,234,567.000')).toEqual({60        sign: '-',61        unsignedValue: '1234567',62        integerValue: '1234567',63        decimals: '',64    });65    expect(parseValue(0)).toEqual({66        sign: '',67        unsignedValue: '0',68        integerValue: '0',69        decimals: '',70    });71    expect(parseValue('')).toEqual({72        sign: '',73        unsignedValue: '',74        integerValue: '',75        decimals: '',76    });77    expect(parseValue('00012')).toEqual({78        sign: '',79        unsignedValue: '12',80        integerValue: '12',81        decimals: '',82    });83    expect(parseValue('-00012')).toEqual({84        sign: '-',85        unsignedValue: '12',86        integerValue: '12',87        decimals: '',88    });89    expect(parseValue('-00012.0012')).toEqual({90        sign: '-',91        unsignedValue: '12.0012',92        integerValue: '12',93        decimals: '0012',94    });...

Full Screen

Full Screen

utility.js

Source:utility.js Github

copy

Full Screen

1import { REGEX } from "../common/constants";2export const formValidatorRules = { 3  number: (min=undefined, max=undefined) => ({4    validator(rule, value) {           5      let parseValue = parseInt(value)6      if (!parseValue) {7        return Promise.resolve();8      }            9      if (!Number(parseValue) || !REGEX.NUMBER.test(Number(parseValue))) {10        return Promise.reject('Should be a valid Number');11      } else if ((min > parseInt(parseValue)) || (max < parseInt(parseValue))) {        12        return Promise.reject(`should be between ${min} and ${max}`);13      }14      return Promise.resolve();15    },16  }),17  decimalNumber: (min = undefined, max = undefined) => ({18    validator(rule, value) {   19      let parseValue = parseFloat(value)20      if (!parseValue) {21        return Promise.resolve();22      }            23      if (!Number(parseValue) || !REGEX.DECIMAL_NUMBER.test(Number(parseValue))) {24        return Promise.reject('Should be a valid Number');25      } else if ((min > parseFloat(parseValue)) || (max < parseFloat(parseValue))) {26        console.log('else if parseValue: ', parseValue)27        return Promise.reject(`should be between ${min} and ${max}`);28      }29      return Promise.resolve();30    },31  }),...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');2const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');3const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');4const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');5const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');6const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');7const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');8const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');9const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');10const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');11const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');12const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');13const { parseValue } = require('appium-xcuitest-driver/lib/commands/element');14const { parseValue } = require('appium-xcuitest-driver/lib/

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseValue } = require('appium-xcuitest-driver').ios;2const { parseValue } = require('appium-xcuitest-driver').ios;3const { parseValue } = require('appium-xcuitest-driver').ios;4const { parseValue } = require('appium-xcuitest-driver').ios;5const { parseValue } = require('appium-xcuitest-driver').ios;6const { parseValue } = require('appium-xcuitest-driver').ios;7const { parseValue } = require('appium-xcuitest-driver').ios;8const { parseValue } = require('appium-xcuitest-driver').ios;9const { parseValue } = require('appium-xcuitest-driver').ios;10const { parseValue } = require('appium-xcuitest-driver').ios;11const { parseValue } = require('appium-xcuitest-driver').ios;12const { parseValue } = require('appium-xcuitest-driver').ios;13const { parseValue } = require('appium-xcuitest-driver').ios;14const { parseValue } = require('appium-xcuitest-driver').ios;15const { parseValue } = require('appium-xcuitest-driver').ios;

Full Screen

Using AI Code Generation

copy

Full Screen

1var XCUITestDriver = require('appium-xcuitest-driver');2var driver = new XCUITestDriver();3driver.parseValue('{"hello": "world"}');4var XCUITestDriver = require('appium-xcuitest-driver');5var driver = new XCUITestDriver();6driver.parseValue('{"hello": "world"}');7var XCUITestDriver = require('appium-xcuitest-driver');8var driver = new XCUITestDriver();9driver.parseValue('{"hello": "world"}');10var XCUITestDriver = require('appium-xcuitest-driver');11var driver = new XCUITestDriver();12driver.parseValue('{"hello": "world"}');13var XCUITestDriver = require('appium-xcuitest-driver');14var driver = new XCUITestDriver();15driver.parseValue('{"hello": "world"}');16var XCUITestDriver = require('appium-xcuitest-driver');17var driver = new XCUITestDriver();18driver.parseValue('{"hello": "world"}');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parseValue } = require('appium-xcuitest-driver');2const value = parseValue('true');3console.log(value);4const { parseValue } = require('appium-mac-driver');5const value = parseValue('true');6console.log(value);

Full Screen

Using AI Code Generation

copy

Full Screen

1async function getParseValue(){2    const driver = await wdio.remote(options);3    let value = await driver.parseValue("10");4    console.log(value);5    await driver.deleteSession();6}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful