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