本文整理匯總了TypeScript中ava.AssertContext.fail方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AssertContext.fail方法的具體用法?TypeScript AssertContext.fail怎麽用?TypeScript AssertContext.fail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ava.AssertContext
的用法示例。
在下文中一共展示了AssertContext.fail方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: while
logFiles.forEach((file) => {
const data = fs.readFileSync(file, "utf8")
const log = JSON.parse(data)
// Has to set explicitly the type of richLogootSOps
// so that TypeScript does its job and infers the return type of richLogootSOps.map(...)
const richLogootSOps: unknown = log.richLogootSOps
if (richLogootSOps instanceof Array && richLogootSOps.length > 0) {
let isOk = true
let i = 0
const logootSOps: LogootSOperation[] = []
while (isOk && i < richLogootSOps.length) {
const plainLogootSOp: unknown = {
...richLogootSOps[i].logootSOp,
author: richLogootSOps[i].id,
}
let logootSOp: LogootSOperation | null = LogootSDel.fromPlain(plainLogootSOp)
if (logootSOp === null) {
logootSOp = LogootSAdd.fromPlain(plainLogootSOp)
}
if (logootSOp === null) {
isOk = false
} else {
logootSOps.push(logootSOp)
}
i++
}
if (isOk) {
logs.push(logootSOps)
} else {
t.fail("the log must contains only valid logoots operations")
}
} else {
t.fail("the log must not be empty")
}
})
示例2: test
test("fromPlain", (t: AssertContext) => {
const plain = {
random: 42,
replicaNumber: 1,
clock: 10,
offset: -5,
}
const tuple: IdentifierTuple | null = IdentifierTuple.fromPlain(plain)
if (tuple === null) {
t.fail("The identifier tuple should have been correctly instantiated")
} else {
t.is(tuple.random, plain.random)
t.is(tuple.replicaNumber, plain.replicaNumber)
t.is(tuple.clock, plain.clock)
t.is(tuple.offset, plain.offset)
}
})