This package has been deprecated

Author message:

Use @tepez/joi-jasmine-helpers instead

joi-jasmine-helpers

0.1.1 • Public • Published

joi-jasmine-helpers

Custom matchers for writing unit test for joi schemas and extensions

npm version Build Status

Usage

const Joi = require('joi');
const JoiJasmineHelpers = require('..');
 
 
beforeEach(() => {
   JoiJasmineHelpers.addMatchers();
});
 
const schema = Joi.number().integer();
 
it('toPassValidation', () => {
    expect(schema).toPassValidation(100);
    expect(schema).toPassValidation('100');
 
    expect(schema).toPassValidation(100, 100);
    expect(schema).toPassValidation('100', 100);
 
    expect(schema).toPassValidation(100, 100, { convert: true });
});
 
it('toFailValidation', () => {
    expect(schema).toFailValidation('xxx');
    expect(schema).toFailValidation('xxx', '"value" must be a number');
    expect(schema).toFailValidation('xxx', /^"value" must be a number$/);
    expect(schema).toFailValidation(10.5, /^"value" must be an integer$/);
 
    expect(schema).toFailValidation('100', '"value" must be a number', { convert: false });
});

Package Sidebar

Install

npm i joi-jasmine-helpers

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • tomyam1