本文整理汇总了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']
);
}
示例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']
);
}
示例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);
}
示例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();
});
});
示例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
);
}
示例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'
);
}
示例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);
});
});
示例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
);
}
示例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
);
}
示例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
);
}