Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

effects-as-data-semantic-test

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effects-as-data-semantic-test

Based on https://github.com/orourkedd/effects-as-data#usage:

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Based on https://github.com/orourkedd/effects-as-data#usage:

Given this function:

const { actions, isFailure } = require('effects-as-data/node')
const { pluck } = require('ramda')
const getListOfNames = pluck(['name'])

const saveRepositories = function * (filename) {
  const {payload: username} = yield actions.prompt('\nEnter a github username: ')
  const repos = yield actions.httpGet(`https://api.github.com/users/${username}/repos`)
  const names = getListOfNames(repos.payload)
  yield actions.logInfo(names.join('\n'))
  return names
}

module.exports = {
  saveRepositories
}
The effects-as-data test would look like:
it('should get repositories and print names', testSaveRepositories(() => {
  const repos = [
    { name: 'foo' },
    { name: 'bar' }
  ]
  return [
    ['repos.json', actions.prompt('\nEnter a github username: ')],
    ['orourkedd', actions.httpGet('https://api.github.com/users/orourkedd/repos')],
    [repos, actions.logInfo('foo\nbar')],
    [null, ['foo', 'bar']]
  ]
}))
The effects-as-data-semantic-test test would look like:
const { args } = require('./effects-as-data-semantic-test');

it('should get repositories and print names', testSaveRepositories(() => {
  const repos = [
    { name: 'foo' },
    { name: 'bar' }
  ]
  return args('repos.json')
    .calls(actions.prompt('\nEnter a github username: ')).returns('orourkedd')
    .calls(actions.httpGet('https://api.github.com/users/orourkedd/repos')).returns(repos)
    .calls(actions.logInfo('foo\nbar')).returns(null)
    .end(['foo', 'bar']);
}))

API

args is the only function exposed initially. Should be what the functions arguments are. Returns { calls }

calls is the action/command object that is called. Returns { returns }

returns is what the action/command returns. Use calls for additional action/command calls or end to finish the function. Returns { calls, end }

end what the function returns. Returns the expected array of tuples for ead testing.

FAQs

Package last updated on 24 Jul 2017

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