Skip to content

Files

Latest commit

1a087d4 · Jul 8, 2019

History

History
46 lines (41 loc) · 975 Bytes

README.md

File metadata and controls

46 lines (41 loc) · 975 Bytes

expecto('cast', patronum => {...})

Function with predicates

Not supposed to have a lot of usage, it's made just for fun.

npm i expecto-patronum
import { expecto } from 'expecto-patronum'

/**
 * For now works with sync stuff only
 */
expecto(
  'All tests should PASS',
  patronum => {
    /**
     * For now that's all predicates here listed, lol
     */
    patronum(0).beFalsy()
    patronum(1).beEqual(1)
    patronum(2).beSame(2)
    patronum(3).beTruthy()
    patronum({ a: 'a', b: 'b' }).beEquallyStringified({ a: 'a', b: 'b' })
  },
  /**
   * Callback gets { fail: number; success: number; }
   * So it could be just console.log as a callback
   */
  tests => console.log(tests)
)

expecto(
  'All tests should FAIL',
  patronum => {
    patronum(1).beFalsy()
    patronum(2).beEqual(3)
    patronum([]).beSame([])
    patronum(0).beTruthy()
    patronum({ a: 'a', b: 'b' }).beEquallyStringified({ b: 'b', a: 'a' })
  },
  console.log
)