Last active
March 14, 2019 09:51
-
-
Save Qquanwei/7f78aea738cbb83f674513b027ffc5c6 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
import { of, itShouldPath, itShouldProp, equals, allPass, large, less, always } from 'OverAssert'; | |
const data = { | |
user: { | |
name: 'Alice', | |
id: 200 | |
}, | |
expireTime: 200, | |
expireDay: 10, | |
} | |
of(data) | |
.map(itShouldPath( | |
['user', 'name'], | |
equals('Alice'), | |
always('user.name should be Alice') | |
)) | |
.map(itShouldPath( | |
['user', 'id'], | |
large(0), | |
always('user.id should large than 0') | |
)) | |
.map(itShouldProp( | |
'expireTime', | |
less(150), | |
always('expireTime should less than 150') | |
)) | |
.map(itShouldProp( | |
'expireDay', | |
allPass(less(20), large(0)), | |
always('expireDay should in range (0, 20)') | |
)) | |
.validate((success, reason) => { | |
// success = false, reason = "expireTime should less than 150" | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment