MCPcopy
hub / github.com/sequelize/sequelize / applyFailTest

Function applyFailTest

test/unit/model/validation.test.js:181–203  ·  test/unit/model/validation.test.js::applyFailTest
(validatorDetails, i, validator)

Source from the content-addressed store, hash-verified

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() {

Callers 1

validation.test.jsFile · 0.85

Calls 4

defineMethod · 0.80
buildMethod · 0.80
validateMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected