Skip to content

Instantly share code, notes, and snippets.

@kossnocorp
Created July 9, 2017 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kossnocorp/1e64228a60f0613cc821cc03659bf681 to your computer and use it in GitHub Desktop.
Save kossnocorp/1e64228a60f0613cc821cc03659bf681 to your computer and use it in GitHub Desktop.
A task for Twitch stream
const { context, when } = require('sorceress')
const assert = require('assert')
const test = context('Some module name', { a: 1, b: 2 })
// Simple test
test(() => {
assert(true)
})
// Test with context
test(({ a, b }) => {
assert(a === 1)
assert(b === 2)
})
// Test with conditions
const withUser = when(context => ({ ...context, user: { name: 'Sasha' } }))
const withSomethingElse = when(context => ({ ...context, wut: 'Whatever' }))
test([withUser, withSomethingElse], ({ user: { name }, wut }) => {
assert(name === 'Sasha')
assert(wut === 'Whatever')
})
// Test with annotations
const withRememberMe = when('remember me is checked', context => ({
...context,
rememberMe: true
}))
test('session is stored', [withRememberMe], ({ rememberMe }) => {
assert(rememberMe)
})
// Scenario
import UserInfo from 'app/ui/_lib/UserInfo'
import { withUser } from 'test/_lib/factories'
const scenario = context('UserInfo')
scenario('renders user infromation', [withUser], ({ user }) => (
<UserInfo user={user} />
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment