當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript bedrock.assert類代碼示例

本文整理匯總了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));
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:27,代碼來源:HistoryTest.ts

示例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
   );
 };
開發者ID:aha-app,項目名稱:tinymce-word-paste-filter,代碼行數:12,代碼來源:AsyncSmoothAnimationTest.ts

示例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');
   }
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:7,代碼來源:FindInlinePatternTest.ts

示例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' });
  };
開發者ID:abstask,項目名稱:tinymce,代碼行數:8,代碼來源:LayoutTest.ts

示例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()
   );
 };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:8,代碼來源:SizeInputConvertTest.ts

示例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);
 };
開發者ID:abstask,項目名稱:tinymce,代碼行數:10,代碼來源:TypeTest.ts


注:本文中的@ephox/bedrock.assert類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。