本文整理汇总了TypeScript中@ephox/bedrock.assert类的典型用法代码示例。如果您正苦于以下问题:TypeScript assert类的具体用法?TypeScript assert怎么用?TypeScript assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了assert类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: clearHistory
UnitTest.test('HistoryTest', () => {
const filetype = 'test';
clearHistory();
assert.eq([], getHistory(filetype));
addToHistory('http://example.com', filetype);
assert.eq(['http://example.com'], getHistory(filetype));
// non-http/https urls will be silently discarded
addToHistory('#id', filetype);
assert.eq(['http://example.com'], getHistory(filetype));
// new urls will be put at the front
addToHistory('https://tiny.cloud', filetype);
assert.eq(['https://tiny.cloud', 'http://example.com'], getHistory(filetype));
// existing urls will be moved to the front
addToHistory('http://example.com', filetype);
assert.eq(['http://example.com', 'https://tiny.cloud'], getHistory(filetype));
// only 5 urls will be kept
for (let i = 1; i <= 5; i++) {
addToHistory('http://example.com/' + i + '/', filetype);
}
assert.eq(['http://example.com/5/', 'http://example.com/4/', 'http://example.com/3/', 'http://example.com/2/', 'http://example.com/1/'], getHistory(filetype));
// multiple types of history can be kept independently
const filetype2 = 'test2';
assert.eq([], getHistory(filetype2));
addToHistory('http://www.abc.net.au/news/', filetype2);
assert.eq(['http://www.abc.net.au/news/'], getHistory(filetype2));
assert.eq(['http://example.com/5/', 'http://example.com/4/', 'http://example.com/3/', 'http://example.com/2/', 'http://example.com/1/'], getHistory(filetype));
});
示例2: function
const assertInfo = function (label, expected, info) {
assert.eq(
expected.current,
info.current,
'Test: ' + label + '. Expected current: ' + expected.current + ', but was: ' + info.current
);
assert.eq(
expected.values,
info.values,
'Test: ' + label + '. Expected values: ' + expected.values + ', but was: ' + info.values
);
};
示例3:
Obj.each(expected.pattern, (value, key) => {
if (Obj.has<any, string>(pattern, key)) {
Assertions.assertEq('Pattern ' + (i + 1) + ' property `' + key + '` is not equal', value, pattern[key]);
} else {
assert.fail('Pattern ' + (i + 1) + ' property `' + key + '` is missing');
}
});
示例4: function
const testCalcSmallContentRect = function () {
const contentAreaRect = rect(0, 0, 25, 25);
const targetRect = rect(40, 0, 10, 10);
const panelRect = rect(0, 20, 50, 50);
const foundRect = Layout.calc(targetRect, contentAreaRect, panelRect);
assert.eq(foundRect, { rect: rect(20, 10, 50, 50), position: 'bc-tc' });
};
示例5: convertUnit
const check = (expected: Option<number>, size: Size, unit: SizeUnit) => {
const result = convertUnit(size, unit);
assert.eq(
true, expected.equals(result),
'Expected conversion of ' + JSON.stringify(size) +
' to ' + unit + ' = ' + result.toString()
);
};
示例6: function
const testIsNumber = function () {
assert.eq(Type.isNumber('a'), false);
assert.eq(Type.isNumber(null), false);
assert.eq(Type.isNumber(undefined), false);
assert.eq(Type.isNumber(true), false);
assert.eq(Type.isNumber(0), true);
assert.eq(Type.isNumber([]), false);
assert.eq(Type.isNumber({}), false);
assert.eq(Type.isNumber(function () { }), false);
};