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


TypeScript mocha-typescript.test函數代碼示例

本文整理匯總了TypeScript中mocha-typescript.test函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript test函數的具體用法?TypeScript test怎麽用?TypeScript test使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了test函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: productLeaderboardTest

 @test('Product leaderboard query')
 public async productLeaderboardTest() {
   let result = await getProductSalesLeaderboard();
   assert.isArray(result, 'Expected result to be an array');
   assert.equal(result.length, 5, 'Expected exactly 5 products');
   validateRecordColumns(
     {
       recordType: 'product-leaderboard',
       functionName: 'getProductSalesLeaderboard'
     },
     result[3],
     ['name', 'amount']
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:14,代碼來源:ex00.initial-dashboard.test.ts

示例2: employeeLeaderboardTest

 @test('Employee leaderboard query')
 public async employeeLeaderboardTest() {
   let result = await getEmployeeSalesLeaderboard();
   assert.isArray(result, 'Expected result to be an array');
   assert.equal(result.length, 5, 'Expected exactly 5 employees');
   validateRecordColumns(
     {
       recordType: 'employee-leaderboard',
       functionName: 'getEmployeeSalesLeaderboard'
     },
     result[3],
     ['name', 'amount']
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:14,代碼來源:ex00.initial-dashboard.test.ts

示例3: reorderableProductsColumnTest

 @test(
   'getAllProducts({ filter: { inventory: "needs-reorder" } }) results must now include categoryname and suppliername columns'
 )
 public async reorderableProductsColumnTest() {
   let firstPageResult = await getAllProducts({
     filter: { inventory: 'needs-reorder' }
   });
   assert.containsAllKeys(firstPageResult[0], [
     'suppliername',
     'categoryname'
   ]);
   assert.ok((firstPageResult[0] as any).suppliername);
   assert.ok((firstPageResult[0] as any).categoryname);
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:14,代碼來源:ex04.products-join.test.ts

示例4: suite

suite('util/ReadyGate', () => {
  test('ReadyGate is ready by default', () => {
    const gate = new ReadyGate();
    gate.isChannelReady().must.be.true();
  });
  test('Once it\'s marked as not ready it comes back as not ready', () => {
    const gate = new ReadyGate();
    gate.channelNotReady();
    gate.isChannelReady().must.be.false();
  });
  test('Once it\'s marked as ready it comes back as ready', () => {
    const gate = new ReadyGate();
    gate.channelNotReady();
    gate.channelReady();
    gate.isChannelReady().must.be.true();
  });
  test('Await returns immediately if the gate is ready', async () => {
    const gate = new ReadyGate();
    const ready = {ready: false};
    const promise = gate.awaitChannelReady().then(() => { ready.ready = true; });
    await new Promise<void>((resolve) => { setTimeout(resolve, 0);});
    ready.ready.must.be.true();
  });

  test('Await does not return immediately if the gate is not ready', async () => {
    const gate = new ReadyGate();
    gate.channelNotReady();
    const ready = {ready: false};
    gate.awaitChannelReady().then(() => { ready.ready = true; });
    await new Promise<void>((resolve) => { setTimeout(resolve, 50);});
    ready.ready.must.be.false();
    gate.channelReady();
    gate.awaitChannelReady().then(() => { ready.ready = true; });
    await new Promise<void>((resolve) => { setTimeout(resolve, 0);});
    ready.ready.must.be.true();
  });
});
開發者ID:yruan,項目名稱:inceptum,代碼行數:37,代碼來源:ReadyGateTest.ts

示例5: allCustomers

 @test('Get all customers')
 public async allCustomers() {
   let result = await getAllCustomers();
   assert.isArray(result, 'Expected result to be an array');
   assert.isAbove(
     result.length,
     40,
     'Expected more than 40 customers in array'
   );
   validateRecordColumns(
     { recordType: 'customer', functionName: 'getAllCustomers' },
     result[2],
     REQUIRED_CUSTOMER_LIST_COLS
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:15,代碼來源:ex00.initial-queries.test.ts

示例6: offset

  @test('When perPage = 20, page 2 starts at item 20')
  public async offset() {
    let first40Result = await getAllOrders({ perPage: 40, page: 1 });
    let first20Result = await getAllOrders({ perPage: 20, page: 1 });
    let second20Result = await getAllOrders({ perPage: 20, page: 2 });

    assert.isArray(second20Result, 'Expected result to be an array');
    assert.equal(second20Result.length, 20, 'Expected 20 orders in array');

    assert.deepEqual(
      second20Result[0],
      first40Result[20],
      'First item on the second page of 20 is the 20th item on the first page of 40'
    );
  }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:15,代碼來源:ex03.pagination-all-orders.test.ts

示例7: suite

suite('mysql/MysqlHealthCheck', () => {
  test('Readonly flag is passed (true)', async () => {
    const check = new MySQLHealthCheck('testCheck', true);
    const mockedMysqlClient = mock(MySQLClient);
    when(mockedMysqlClient.ping(anything())).thenReturn(Promise.resolve(undefined));
    check.mysqlClient = instance(mockedMysqlClient);
    await check.doCheck();
    verify(mockedMysqlClient.ping(true)).once();
  });
  test('Readonly flag is passed (false)', async () => {
    const check = new MySQLHealthCheck('testCheck', false);
    const mockedMysqlClient = mock(MySQLClient);
    when(mockedMysqlClient.ping(anything())).thenReturn(Promise.resolve(undefined));
    check.mysqlClient = instance(mockedMysqlClient);
    await check.doCheck();
    verify(mockedMysqlClient.ping(false)).once();
  });
  test('OKs on success', async () => {
    const check = new MySQLHealthCheck('testCheck', false);
    const mockedMysqlClient = mock(MySQLClient);
    when(mockedMysqlClient.ping(anything())).thenReturn(Promise.resolve(undefined));
    check.mysqlClient = instance(mockedMysqlClient);
    await check.runCheck();
    const result = check.getLastResult();
    result.status.must.equal(HealthCheckStatus.OK);
  });
  test('CRITICAL on exception', async () => {
    const check = new MySQLHealthCheck('testCheck', false);
    const mockedMysqlClient = mock(MySQLClient);
    when(mockedMysqlClient.ping(anything())).thenThrow(new Error('Error'));
    check.mysqlClient = instance(mockedMysqlClient);
    await check.runCheck();
    const result = check.getLastResult();
    result.status.must.equal(HealthCheckStatus.CRITICAL);
  });
});
開發者ID:yruan,項目名稱:inceptum,代碼行數:36,代碼來源:MySQLHealthCheck.ts

示例8: allProducts

 @test('Get all products')
 public async allProducts() {
   let result = await getAllProducts();
   assert.isArray(result, 'Expected result to be an array');
   assert.isAbove(
     result.length,
     20,
     'Expected more than 20 products in array'
   );
   validateRecordColumns(
     { recordType: 'product', functionName: 'getAllProducts' },
     result[3],
     REQUIRED_PRODUCT_LIST_COLS
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:15,代碼來源:ex00.initial-queries.test.ts

示例9: allSuppliers

 @test('Get all suppliers')
 public async allSuppliers() {
   let result = await getAllSuppliers();
   assert.isArray(result, 'Expected result to be an array');
   assert.isAbove(
     result.length,
     20,
     'Expected more than 20 suppliers in array'
   );
   validateRecordColumns(
     { recordType: 'supplier', functionName: 'getAllSuppliers' },
     result[3],
     REQUIRED_SUPPLIER_LIST_COLS
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:15,代碼來源:ex00.initial-queries.test.ts

示例10: allOrders

 @test('Get all orders')
 public async allOrders() {
   let result = await getAllOrders({ perPage: 50000 });
   assert.isArray(result, 'Expected result to be an array');
   assert.isAbove(
     result.length,
     800,
     'Expected more than 800 orders in array'
   );
   validateRecordColumns(
     { recordType: 'order', functionName: 'getAllOrders' },
     result[2],
     REQUIRED_ORDER_LIST_COLS
   );
 }
開發者ID:qjac,項目名稱:sql-fundamentals,代碼行數:15,代碼來源:ex00.initial-queries.test.ts


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