Last active
November 4, 2019 15:09
-
-
Save apaleslimghost/f3901c756ba39c1b34d1a86e74b5d13a to your computer and use it in GitHub Desktop.
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 {diffChars} = require('diff') | |
const c = require('ansi-colors') | |
const Result = require('folktale/result') | |
module.exports = ({ expected, value }) => ( | |
expected === value | |
? Result.Ok() | |
: Result.Error( | |
c.red('- expected ') + c.green('+ actual\n') + | |
diffChars(expected, value) | |
.map(change => ( | |
change.added | |
? c.green(change.value) | |
: change.removed | |
? c.red(change.value) | |
: change.value | |
)) | |
.join('') | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment