it('should require email', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('emailValidationStatus', 'error'); expect(validationResults).to.have.own.property('emailValidationText', 'Field is required.'); });
it('setParameters function', function(){ var serverVersion = '1201000000'; var serverType = 'ORACLE'; var qb = new QueryBuilder(serverType, serverVersion); qb.setParameters({ busId : 101, companyId : 1 }); expect(qb.queryParameters).to.be.an('object'); expect(qb.queryParameters).to.have.own.property('busId'); expect(qb.queryParameters).to.have.own.property('companyId'); expect(qb.queryParameters).to.have.deep.property('busId', 101); expect(qb.queryParameters).to.have.deep.property('companyId', 1); expect(Object.keys(qb.queryParameters).length).to.equal(2); });
it('should support the async iterator protocol', async () => { const cursor = db.a.findAsCursor({ name: 'Squirtle' }); const { next } = cursor[Symbol.asyncIterator](); const result = await next(); expect(result) .to.be.an('object') .that.has.all.keys('value', 'done') .and.has.own.property('done', false); expect(result.value) .to.be.an('object') .that.has.own.property('type', 'water'); expect(await next()).to.deep.equal({ done: true, value: undefined }); });
it('setParameter function', function(){ var serverVersion = '1201000000'; var serverType = 'ORACLE'; var qb = new QueryBuilder(serverType, serverVersion); qb.setParameter({ busId : 101 }); expect(qb.queryParameters).to.be.an('object'); expect(qb.queryParameters).to.have.own.property('busId'); expect(qb.queryParameters).to.have.deep.property('busId', 101); expect(Object.keys(qb.queryParameters).length).to.equal(1); });
it('should require date not in future', () => { const validationResults = validateClaim({ date: '3000-01-01' }); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('dateValidationStatus', 'error'); expect(validationResults).to.have.own.property( 'dateValidationText', 'Date cannot be in the future.', ); });
it('should require valid type', () => { const validationResults = validateClaim({ type: 'Unsupported type' }); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('typeValidationStatus', 'error'); expect(validationResults).to.have.own.property('typeValidationText', 'Provide valid type.'); });
it('should check amount validity', () => { const validationResults = validateClaim({ amount: 'abc' }); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('amountValidationStatus', 'error'); expect(validationResults).to.have.own.property('amountValidationText', 'Provide valid amount.'); });
it('should require date in valid format', () => { const validationResults = validateClaim({ date: '01-01-2017' }); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('dateValidationStatus', 'error'); expect(validationResults).to.have.own.property( 'dateValidationText', "Provide valid date with format 'YYYY-MM-DD'.", ); });
it('should check email validity', () => { const validationResults = validateClaim({ email: 'abc' }); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('emailValidationStatus', 'error'); expect(validationResults).to.have.own.property('emailValidationText', 'Provide valid email.'); });
it('should require type', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('typeValidationStatus', 'error'); expect(validationResults).to.have.own.property('typeValidationText', 'Field is required.'); });
it('should require name', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('nameValidationStatus', 'error'); expect(validationResults).to.have.own.property('nameValidationText', 'Field is required.'); });
it('should require policyId', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('policyIdValidationStatus', 'error'); expect(validationResults).to.have.own.property('policyIdValidationText', 'Field is required.'); });
it('should require amount', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('amountValidationStatus', 'error'); expect(validationResults).to.have.own.property('amountValidationText', 'Field is required.'); });
it('should require date', () => { const validationResults = validateClaim({}); expect(validationResults) .to.be.an('object') .to.have.own.property('isFormValid', false); expect(validationResults).to.have.own.property('dateValidationStatus', 'error'); expect(validationResults).to.have.own.property('dateValidationText', 'Field is required.'); });