(validatorDetails, i, validator)
| 179 | }; |
| 180 | |
| 181 | const applyFailTest = function applyFailTest(validatorDetails, i, validator) { |
| 182 | const failingValue = validatorDetails.fail[i]; |
| 183 | it(`correctly specifies an instance as invalid using a value of class="st">"${failingValue}" for the validation class="st">"${validator}"`, async function() { |
| 184 | const validations = {}, |
| 185 | message = `${validator}(${failingValue})`; |
| 186 | |
| 187 | validations[validator] = validatorDetails.spec || {}; |
| 188 | validations[validator].msg = message; |
| 189 | |
| 190 | const UserFail = this.sequelize.define(`User${Support.rand()}`, { |
| 191 | name: { |
| 192 | type: Sequelize.STRING, |
| 193 | validate: validations |
| 194 | } |
| 195 | }); |
| 196 | |
| 197 | const failingUser = UserFail.build({ name: failingValue }); |
| 198 | |
| 199 | const _errors = await expect(failingUser.validate()).to.be.rejected; |
| 200 | expect(_errors.get(class="st">'name')[0].message).to.equal(message); |
| 201 | expect(_errors.get(class="st">'name')[0].value).to.equal(failingValue); |
| 202 | }); |
| 203 | }, |
| 204 | applyPassTest = function applyPassTest(validatorDetails, j, validator, type) { |
| 205 | const succeedingValue = validatorDetails.pass[j]; |
| 206 | it(`correctly specifies an instance as valid using a value of class="st">"${succeedingValue}" for the validation class="st">"${validator}"`, async function() { |
no test coverage detected