本文整理汇总了TypeScript中ava.serial函数的典型用法代码示例。如果您正苦于以下问题:TypeScript serial函数的具体用法?TypeScript serial怎么用?TypeScript serial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serial函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createTestData
dir: __dirname,
fileMatch: 'models.js'
}
]
});
await createTestData();
});
// drop test db
test.after(async () => {
await Tyr.mongoClient.db(sanitizedDB).dropDatabase();
});
test.serial('should successfully sanitize', () =>
sanitize(Tyr, { outDbName: sanitizedDB })
);
test.serial('should error if sanitizing into same db', async t => {
try {
await sanitize(Tyr, { outDbName: sanitizedDB });
} catch (err) {
return t.pass();
}
t.fail();
});
test.serial('documents should be sanitized', async t => {
const sanitizedUsers = await Tyr.mongoClient
.db(sanitizedDB)
.collection('users')
示例2: Knex
test.beforeEach(t => {
t.context.db = Knex({
client: 'sqlite3',
connection: {
filename: ':memory:'
}
});
});
test.afterEach(async function(t) {
await t.context.db.destroy();
});
test.serial(`should add table`, async function(t) {
const r = new Migration(add.one, add.two);
await Migration.run(t.context.db, await r.up());
t.true(await t.context.db.schema.hasTable('test_table'));
});
test.serial(`should drop table`, async function(t) {
const m = new Migration(add.one, add.two);
await Migration.run(t.context.db, await m.up(), await m.down());
t.false(await t.context.db.schema.hasTable('test_table'));
});
test.serial(`should rename table`, async function(t) {
const m1 = new Migration(add.one, rename.one);
const m2 = new Migration(rename.one, rename.two);
await Migration.run(t.context.db, await m1.up(), await m2.up());
t.true(await t.context.db.schema.hasTable('test_table2'));
});
示例3: testPasswordValid
export function testPasswordValid()
{
test.serial('パスワード検証 - パスワードがnullで確認用パスワードがない時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = null;
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('パスワード検証 - null不可の時はパスワードと確認用パスワードがnullで一致していても失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = null;
const confirm = null;
const result = Validator.password({password, confirm}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('パスワード検証 - null可の時はパスワードと確認用パスワードがnullで一致していれば成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = null;
const confirm = null;
const canNull = true;
const result = Validator.password({password, confirm, canNull}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('パスワード検証 - 短すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = '1234567';
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('パスワード検証 - 有効な最小文字数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = '12345678';
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('パスワード検証 - 有効な最大文字数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = '1234567890123456';
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('パスワード検証 - 長すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = '12345678901234567';
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('パスワード検証 - 英数以外の時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const password = 'あいうえおかきくけこ';
const result = Validator.password({password}, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
//.........这里部分代码省略.........
示例4: ActionsOnGoogleAva
test.serial('sends correct request parameters - en-US', t => {
const action = new ActionsOnGoogleAva(require(testCredentialsFile))
const mockResponse = sinon.stub(action._client, 'assist')
mockResponse.callsFake(() => {
let onData: Function, onEnd: Function
return {
on: (event: string, call: Function) => {
if (event === 'data') {
onData = call
} else if (event === 'end') {
onEnd = call
}
},
// tslint:disable-next-line
write: (data: any) => {
t.is(data.config.text_query, 'Talk to my test app')
t.is(data.config.dialog_state_in.language_code, 'en-US')
t.is(data.config.debug_config.return_debug_info, true)
},
end() {
onData({})
onEnd()
},
}
})
return action.startConversation('')
.then(res => {
t.pass()
mockResponse.restore()
})
})
示例5: createMstPlugin
test.serial("sends action complete event", t => {
const { reactotron, track } = createMstPlugin()
const user = TestUserModel.create()
track(user)
user.setAge(123)
// details about the reactotron functions used
const send = td.explain(reactotron.send)
// called only once
t.is(1, send.callCount)
const payload = {
name: "setAge()",
ms: 1,
action: { name: "setAge", path: "", args: [123] },
mst: {
id: 1,
rootId: 1,
parentId: 0,
type: "action",
modelType: TestUserModel,
alive: true,
root: true,
protected: true,
},
}
// send() params
t.deepEqual(["state.action.complete", payload], send.calls[0].args)
})
示例6: testIsChangePasswordValid
export function testIsChangePasswordValid()
{
test.serial('パスワード変更の入力値検証 - メールアドレスが未設定の時は設定できないこと', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: null,
password: null
};
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: null,
newPassword: '1234567890123456',
confirm: null
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.FAILED);
await AccountAgent.remove(account.id);
log.stepOut();
});
test.serial('パスワード変更の入力値検証 - メールアドレス以外に認証手段がない時はパスワードなしに変更できないこと', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: 'admin@example.com',
password: '12345678'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: null,
newPassword: null,
confirm: null
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.FAILED);
await AccountAgent.remove(account.id);
log.stepOut();
});
test.serial('パスワード変更の入力値検証 - メールアドレス以外に認証手段がある時はパスワードなしに変更できること', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: 'admin@example.com',
password: '12345678',
twitter: 'twitter'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: '12345678',
newPassword: null,
confirm: null,
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.OK);
await AccountAgent.remove(account.id);
log.stepOut();
});
test.serial('パスワード変更の入力値検証 - 現在のパスワードと現在のパスワードとして入力されたパスワードが一致しない時は変更できないこと', async (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
let account : Account =
{
email: 'admin@example.com',
password: '12345678'
};
account.password = Utils.getHashPassword(account.email, account.password, Config.PASSWORD_SALT);
account = await AccountAgent.add(account);
const param : Request.ChangePassword =
{
oldPassword: null,
newPassword: '1234567890123456',
confirm: '1234567890123456'
};
const result = await isChangePasswordValid(param, account.id, locale);
const {status} = result.response;
t.is(status, Response.Status.FAILED);
await AccountAgent.remove(account.id);
log.stepOut();
//.........这里部分代码省略.........
示例7: testAccountNameValid
export function testAccountNameValid()
{
test.serial('アカウント名検証 - 前や後にスペースがある時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = ' accountName';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('アカウント名検証 - 短すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = '';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('アカウント名検証 - 有効な最小文字数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = '1';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('アカウント名検証 - 有効な最大文字数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = '12345678901234567890';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('アカウント名検証 - 長すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const accountName = '123456789012345678901';
const result = Validator.accountName(accountName, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
}
示例8: Error
import { serial as test } from 'ava'
import {
ADAPTER_OPTIONS,
ADAPTER_OPTIONS2,
AdapterMockFactory,
} from '../test/adapter.mock'
import { ha4us } from './adapter'
test('Create adapter', async t => {
const cb = () => {
throw new Error('intendend test problem')
}
await ha4us(ADAPTER_OPTIONS, AdapterMockFactory(cb))
t.pass()
})
test('Create 2nd adapter', async t => {
return ha4us(ADAPTER_OPTIONS2, AdapterMockFactory()).then(() => {
t.pass()
})
})
示例9: RegExp
t.regex(screenshots[0].filename, new RegExp(`${dateFns.format(Date.now(), 'YYYY-MM-DD')} - \\d{2}-\\d{2}-\\d{2} - ${server.host}!${server.port}.png`));
});
test('`selector` option', async t => {
const screenshots = await new Pageres({selector: '#team'}).src(server.url, ['1024x768']).run();
t.is(screenshots[0].filename, `${server.host}!${server.port}-1024x768.png`);
const size = imageSize(screenshots[0]);
t.is(size.width, 1024);
t.is(size.height, 80);
});
test.serial('support local relative files', async t => {
const _cwd = process.cwd();
process.chdir(__dirname);
const screenshots = await new Pageres().src('fixture.html', ['1024x768']).run();
t.is(screenshots[0].filename, 'fixture.html-1024x768.png');
t.true(screenshots[0].length > 1000);
process.chdir(_cwd);
});
test('support local absolute files', async t => {
const screenshots = await new Pageres().src(path.join(__dirname, 'fixture.html'), ['1024x768']).run();
t.is(screenshots[0].filename, 'fixture.html-1024x768.png');
t.true(screenshots[0].length > 1000);
});
test('fetch resolutions from w3counter', async t => {
const screenshots = await new Pageres().src(server.url, ['w3counter']).run();
t.is(screenshots.length, 10);
t.true(screenshots[0].length > 1000);
});
示例10: testUserNameValid
export function testUserNameValid()
{
test.serial('ユーザー名検証 - nullは成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = null;
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('ユーザー名検証 - 前や後にスペースがある時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = ' username';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('ユーザー名検証 - 有効な最大文字数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = 'ABCDEF78901234567890';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
test.serial('ユーザー名検証 - 長すぎる時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = '123456789012345678901';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('ユーザー名検証 - 数字のみは失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = '12345678901234567890';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('ユーザー名検証 - 英数以外の時は失敗すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = 'あいうえおかきくけこ';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.FAILED);
log.stepOut();
});
test.serial('ユーザー名検証 - 英数の時は成功すること', (t) =>
{
const log = slog.stepIn('test', t['_test'].title);
const userName = 'ABC456789_abc4567890';
const accountId = 0;
const account = null;
const result = Validator.userName(userName, accountId, account, locale);
const {status} = result;
log.d(JSON.stringify(result, null, 2));
t.is(status, Response.Status.OK);
log.stepOut();
});
//.........这里部分代码省略.........