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


TypeScript ava.serial函數代碼示例

本文整理匯總了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')
開發者ID:tyranid-org,項目名稱:tyranid,代碼行數:31,代碼來源:index.ts

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

示例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();
    });
//.........這裏部分代碼省略.........
開發者ID:nandai,項目名稱:web-service-template,代碼行數:101,代碼來源:_testPasswordValid.ts

示例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()
    })
})
開發者ID:manoj253,項目名稱:actions-on-google-testing-nodejs,代碼行數:33,代碼來源:test.ts

示例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)
})
開發者ID:TheIdhem,項目名稱:reactotron,代碼行數:31,代碼來源:actions.test.ts

示例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();
//.........這裏部分代碼省略.........
開發者ID:nandai,項目名稱:web-service-template,代碼行數:101,代碼來源:_testIsChangePasswordValid.ts

示例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();
    });
}
開發者ID:nandai,項目名稱:web-service-template,代碼行數:62,代碼來源:_testAccountNameValid.ts

示例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()
    })
})
開發者ID:ha4us,項目名稱:ha4us.old,代碼行數:24,代碼來源:adapter.spec.ts

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

示例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();
    });

//.........這裏部分代碼省略.........
開發者ID:nandai,項目名稱:web-service-template,代碼行數:101,代碼來源:_testUserNameValid.ts


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