New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pacote/jest-either

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pacote/jest-either

Jest matcher for Either objects.

  • 2.1.0
  • npm
  • Socket score

Version published
Weekly downloads
90
decreased by-29.13%
Maintainers
1
Weekly downloads
 
Created
Source

@pacote/jest-either

Build Status version minified minified + gzip

Additional matchers for Jest making it easier to test Either objects.

Installation

yarn add @pacote/jest-either

Usage

import matchers from '@pacote/jest-either'

expect.extend(matchers)

.toBeEither()

import { left, right } from 'fp-ts/lib/Either'

test('passes when value is an Either', () => {
  expect(left(true)).toBeEither()
  expect(right(true)).toBeEither()
})

test('passes when value is not an Either', () => {
  expect(undefined).not.toBeEither()
})

.toBeRight()

import { left, right } from 'fp-ts/lib/Either'

test('passes when Either is a right', () => {
  const actual = right({ test: 'ok' })
  expect(actual).toBeRight()
})

test('passes when Either is a left', () => {
  const actual = left(Error())
  expect(actual).not.toBeRight()
})

.toBeLeft()

import { left, right } from 'fp-ts/lib/Either'

test('passes when Either is a left', () => {
  const actual = left(Error())
  expect(actual).toBeLeft()
})

test('passes when Either is a right', () => {
  const actual = right({ test: 'ok' })
  expect(actual).not.toBeLeft()
})

.toEqualRight(value)

import { right } from 'fp-ts/lib/Either'

test('passes when right of Either equals a value', () => {
  const actual = right({ test: 'ok' })
  expect(actual).toEqualRight({ test: 'ok' })
})

test('passes when right of Either does not equal a value', () => {
  const actual = right({ test: 'unexpected' })
  expect(actual).not.toEqualRight({ test: 'ok' })
})

.toEqualLeft(value)

import { left } from 'fp-ts/lib/Either'

test('passes when left of Either equals a value', () => {
  const actual = left(Error('message'))
  expect(actual).toEqualLeft(Error('message'))
})

test('passes when left of Either does not equal a value', () => {
  const actual = left(Error('unexpected'))
  expect(actual).not.toEqualLeft(Error('message'))
})

.toMatchRight(object)

import { right } from 'fp-ts/lib/Either'

test('passes when right of Either matches an object', () => {
  const actual = right({ test: 'ok', foo: 'bar' })
  expect(actual).toMatchRight({ test: 'ok' })
})

test('passes when right of Either does not match an object', () => {
  const actual = right({ test: 'unexpected', foo: 'bar' })
  expect(actual).not.toMatchRight({ test: 'ok' })
})

.toMatchLeft(object)

import { left } from 'fp-ts/lib/Either'

test('passes when left of Either matches an object', () => {
  const actual = left({ test: 'ok', foo: 'bar' })
  expect(actual).toMatchLeft({ test: 'ok' })
})

test('passes when left of Either does not match an object', () => {
  const actual = left({ test: 'unexpected', foo: 'bar' })
  expect(actual).not.toMatchLeft({ test: 'ok' })
})

License

MIT © Luís Rodrigues.

Keywords

FAQs

Package last updated on 12 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc