Created
July 9, 2017 14:11
-
-
Save kossnocorp/1e64228a60f0613cc821cc03659bf681 to your computer and use it in GitHub Desktop.
A task for Twitch stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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