当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ava.after函数代码示例

本文整理汇总了TypeScript中ava.after函数的典型用法代码示例。如果您正苦于以下问题:TypeScript after函数的具体用法?TypeScript after怎么用?TypeScript after使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了after函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createTestData

    mongoClient,
    db: mongoClient.db(),
    validate: [
      {
        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();
});
开发者ID:tyranid-org,项目名称:tyranid,代码行数:30,代码来源:index.ts

示例2: test

    let myArray: Array<any> = ["firstObject", "secondObject", ["nestedObj1", "nestedObj2"]];
    logger.info("Writing default level to default console.");
    logger.debug("writing debug level to default console.");
    logger.warn("Writing array object to default console", myArray);
});

test("Logger with default parameters can be instantiated multiple times", async t => {
    let logger = new Logger();
    logger.info("Writing default level to default console.");
    logger.debug("writing debug level to default console.");

    /* tslint:disable:no-unused-variable */
    let logger2 = new Logger();
    /* tslint:enable:no-unused-variable */

    logger.info("2nd Logger - Writing default level to default console");
});

test("Logger can be instantiated with custom file parameter", async t => {
    let logger = new Logger();
    logger.addLoggerTransport(winston.transports.File, { filename: testLogFileName });
    logger.info("Writing default level to default console + file.");
    logger.warn("writing warn level to default console + file.");
    t.is(logger.getConfiguredLoggerTransports().length, 2);
});

test.after("Deleting created log file", async t => {
    let fullPathName = path.join(__dirname, testLogFileName);
    return fs.unlinkSync(fullPathName);
});
开发者ID:arjun-msft,项目名称:opent2t,代码行数:30,代码来源:OpenT2TTests.ts

示例3: request

    const loginResult = await request(app)
        .post("/test/api/user/login")
        .send({password: userForRegistration.password, username: userForRegistration.username});
    t.is(loginResult.status, 200);
    t.truthy(loginResult.body.isSuccess);
});

test("login:Error", async(t) => {
    const res = await request(app)
        .post("/test/api/user/login")
        .send({password: "adsdsdsdsdsdsdsdsdsdsdsdsdsds", username: "adsssssssssssss"});

    t.is(res.status, 404);
    t.falsy(res.body.isSuccess);
});

test("isLogged:Error", async(t) => {
    const res = await request(app)
        .post("/test/api/user/isLogged")
        .set("authorization", "nope");

    t.is(res.status, 401);
    t.falsy(res.body.isSuccess);
});


test.after("close connection to database", () => {
    mongoose.connection.close();
});
开发者ID:dominikus1993,项目名称:twitterClone,代码行数:29,代码来源:controllerTest.ts

示例4: test

});

test('hostname+path in options are not breaking redirects', async (t) => {
    t.is((await got(`${http.url}/relative`, {hostname: http.host, path: '/relative'})).body, 'reached');
});

test('redirect only GET and HEAD requests', async (t) => {
    try {
        await got(`${http.url}/relative`, {body: 'wow'});
        t.fail('Exception was not thrown');
    } catch (err) {
        t.is(err.message, 'Response code 302 (Found)');
        t.is(err.path, '/relative');
        t.is(err.statusCode, 302);
    }
});

test('redirects from httpt o https works', async (t) => {
    t.truthy((await got(`${http.url}/httpToHttps`, {rejectUnauthorized: false})).body);
});

test('redirects works with lowercase method', async (t) => {
    const body = (await got(`${http.url}/relative`, {method: 'head'})).body;
    t.is(body, '');
});

test.after('cleanup', async () => {
    await http.close();
    await https.close();
});
开发者ID:cyounkins,项目名称:typed-got,代码行数:30,代码来源:redirects.ts

示例5: tempfile

import {createServer} from './helpers/server';

const socketPath = tempfile('.socket');

let s;

test.before('setup', async () => {
    s = await createServer();

    s.on('/', (req, res) => {
        res.end('ok');
    });

    await s.listen(socketPath);
});

test('works', async (t) => {
    const url = format('http://unix:%s:%s', socketPath, '/');
    t.is((await got(url)).body, 'ok');
});

// "protocol-less works failed with "Protocol "unix:" not supported. Expected "http:".""
//t est('protocol-less works', async (t) => {
//  const url = format('unix:%s:%s', socketPath, '/');
//  t.is((await got(url)).body, 'ok');
// });

test.after('cleanup', async () => {
    await s.close();
});
开发者ID:cyounkins,项目名称:typed-got,代码行数:30,代码来源:unix-socket.ts

示例6: PNG

	const png = new PNG(buffer);
	const {pixels} = await pify(png.parse.bind(png))();
	return pixels;
};

let server;
let serverFileName;
test.before(async () => {
	server = await createServer();
	serverFileName = server.url
		.replace('http://', '')
		.replace(':', '!');
});

test.after(() => {
	server.close();
});

test('expose a constructor', t => {
	t.is(typeof Pageres, 'function');
});

test('add a source', t => {
	const pageres = new Pageres().src(server.url, ['1280x1024', '1920x1080']);
	t.is((pageres as any)._source[0].url, server.url);
});

test('set destination directory', t => {
	t.is((new Pageres().dest('tmp') as any)._destination, 'tmp');
});
开发者ID:sindresorhus,项目名称:pageres,代码行数:30,代码来源:test.ts


注:本文中的ava.after函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。