本文整理匯總了TypeScript中@quenk/test/lib/assert.assert函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript assert函數的具體用法?TypeScript assert怎麽用?TypeScript assert使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了assert函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should correctly test string', function() {
let email = /.+\@.+\..+/;
assert(matches(email)('m12@emale.com').takeRight()).equal('m12@emale.com');
assert(matches(email)('12').takeLeft()).be.instance.of(PrimFailure);
});
示例2: it
it('should work', function() {
assert(range(1, 3)([]).takeLeft().explain()).equal('range.min');
assert(range(1, 3)([1, 2, 3, 4]).takeLeft().explain()).equal('range.max');
assert(range(1, 3)([1, 2, 3]).takeRight()).equate([1, 2, 3]);
});
示例3: it
it('should fail if the value specified is not a boolean', function() {
assert(isBoolean(true).takeRight()).be.true();
assert(isBoolean(false).takeRight()).be.false();
assert(isBoolean('12').takeLeft()).be.instance.of(PrimFailure);
});
示例4: it
it('should work', function() {
assert(isRecord({}).takeRight()).equate({});
assert(isRecord('z').takeLeft().explain({})).equal('isRecord');
assert(isRecord([]).takeLeft().explain({})).equal('isRecord');
});
示例5: assert
const shouldWorkWithNestedConditions = (condition: Precondition<object, object>) => {
assert(condition(validAccess).takeRight()).equate(validAccess);
assert(condition(invalidAccess).takeLeft().explain())
.equate({
network: 'check', user: { roles: 'check' }, previous: { age: 'check' }
});
}
示例6: it
it('should correctly test string, number or arrays', function() {
let test = range(3, 5);
assert(test(1).takeLeft().explain()).equal('range.min');
assert(test(6).takeLeft().explain()).equal('range.max');
assert(test(3).takeRight()).equal(3);
assert(test(4).takeRight()).equal(4);
assert(test(5).takeRight()).equal(5);
})