How to use the ava.after function in ava

To help you get started, we’ve selected a few ava examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github peterjoseph / Reeve / tests_integration / 01_authentication.js View on Github external
t.is(response.body.user.lastName, testData.lastName);
	t.is(response.body.user.emailAddress, testData.emailAddress);
	t.is(response.body.user.workspaceURL, testData.workspaceURL);
	t.not(response.body.user.clientFeatures, null);
	t.not(response.body.user.userRoles, null);
	t.is(response.body.user.language, testData.language);
});

// 200 - Logout of active user account (Client Owner)
test("Owner Account Logout - Valid Header - 200 Response", async t => {
	const response = await request.post("api/v1.0/authentication/logout").set("Authorization", testData.securityToken);
	t.is(response.status, 200);
});

// Cleanup test server on completion
test.after("Cleanup test environment", t => {
	server.close();
});
github zeit / react-keyframes / test / index.js View on Github external
// Packages
import test from 'ava'
import lolex from 'lolex'
import React from 'react'
import {render, findDOMNode} from 'react-dom'

// Utilities
import {Keyframes, Frame} from '../src'

let clock

test.before(() => {
  clock = lolex.install()
})

test.after(() => {
  clock.uninstall()
})

test('animate', t => {
  const container = document.createElement('div')
  const component = render(
    
      foo
      bar
      baz
    ,
    container
  )
  const node = findDOMNode(component)

  t.deepEqual(node.childNodes.length, 1)
github swiftcafex / ios-image-maker / test / test-image-util.js View on Github external
},
        {
            "cwd" : path.join(__dirname, "test-support/test-imageutil/generateConfigItem"),
            "dir" : "./output/icon/Assets.xcassets/"
        }

    ]);
}

test.before(async t => {

    await clean().then(function(){ });

});

test.after(async t => {

    await clean().then(function(){ });

});

test("place holder", t => {

    t.pass();
});

// test('ImageUtil.generateConfigItem', async t => {
//
//     var workingDirectoryPath = path.join(__dirname, "test-support/test-imageutil/generateConfigItem");
//     process.chdir(workingDirectoryPath);
//
//     var assetConfig = {
github mozillach / gh-projects-content-queue / test / scheduled-date.js View on Github external
import test from 'ava';
import ScheduledDate from '../lib/scheduled-date';
import sinon from 'sinon';
import defaultConfig from '../config.default.json';

const clock = sinon.useFakeTimers();
test.after(() => {
    clock.restore();
});

const globalDate = new Date();
const tzOffset = globalDate.getTimezoneOffset() / 60;

test('constructor with invalid date', (t) => {
    const date = new ScheduledDate('', {
        schedulingTime: {
            format: '',
            timezone: 0
        }
    });

    t.true(date instanceof Date);
    // Can't test the date object's time since the subclassing of the date object
github Schniz / cuery / test / query.js View on Github external
CREATE TABLE "public"."${tableName}" (
      id serial PRIMARY KEY,
      name text,
      age integer
    )
  `, []);

  const insertions = seed.map(e => `('${e.name}', ${e.age})`);
  const query = `
    INSERT INTO "public"."${tableName}" (name, age)
    VALUES ${insertions.join(', ')}
  `;
  await doQuery(conn, query, []);
});

test.after(async () => {
  const conn = await connect();
  await doQuery(conn, `DROP TABLE "public"."${tableName}"`, []);
});

test('simple query', async t => {
  const simple = Query.of({
    query: `SELECT * FROM ${tableName}`,
    params: [],
  });

  const { rows } = await execute(simple, {});
  t.is(rows.length, 2);
});

test('query with params', async t => {
  const simple = Query.of({
github elementary / houston / test / telemetry / server.js View on Github external
import alias from 'root/.alias'
import mockConfig from 'test/fixtures/config'

mock(path.resolve(alias.resolve.alias['root'], 'config.js'), mockConfig)

const config = require(path.resolve(alias.resolve.alias['lib'], 'config')).default
const db = require(path.resolve(alias.resolve.alias['lib'], 'database', 'connection.js')).default
const Download = require(path.resolve(alias.resolve.alias['lib'], 'database', 'download')).default
const Project = require(path.resolve(alias.resolve.alias['lib'], 'database', 'project')).default
const telemetry = require(path.resolve(alias.resolve.alias['telemetry'], 'server'))

test.before((t) => {
  db.connect(config.database)
})

test.after((t) => {
  db.connection.close()
})

test('parseMessage can parse a nginx message string', (t) => {
  const parseMessage = telemetry.parseMessage

  const one = parseMessage('test nginx: 192.168.1.1|200|/apphub/dists/xenial/main/appstream/Components-amd64.yml.gz|163|chrome|128')

  t.is(one.client, '192.168.1.1')
  t.is(one.status, 200)
  t.is(one.path, '/apphub/dists/xenial/main/appstream/Components-amd64.yml.gz')
  t.is(one.file, 'Components-amd64.yml.gz')
  t.is(one.ext, '.gz')
  t.is(one.bytes, 163)
  t.is(one.time, 128)
})
github BoostIO / Boostnote / tests / dataApi / createNote.js View on Github external
t.is(input1.snippets[0].content, jsonData1.snippets[0].content)
      t.is(input1.snippets[0].name, data1.snippets[0].name)
      t.is(input1.snippets[0].name, jsonData1.snippets[0].name)

      t.is(storageKey, data2.storage)
      let jsonData2 = CSON.readFileSync(path.join(storagePath, 'notes', data2.key + '.cson'))
      t.is(input2.title, data2.title)
      t.is(input2.title, jsonData2.title)
      t.is(input2.content, data2.content)
      t.is(input2.content, jsonData2.content)
      t.is(input2.tags.length, data2.tags.length)
      t.is(input2.tags.length, jsonData2.tags.length)
    })
})

test.after(function after () {
  localStorage.clear()
  sander.rimrafSync(storagePath)
})
github superchargejs / framework / testing / drivers / ava.js View on Github external
assignAfterHook () {
    Ava.after(`${this.constructor.name}: after`, async t => {
      return this.test.after(t)
    })
  }
github jamesramsay / hercule / test / units / resolve / parseLink.js View on Github external
global.fs = require('fs');

test.before(() => {
  const localStream = new Readable();
  localStream.push('local!');
  localStream.push(null);

  sinon.stub(global.fs, 'createReadStream')
    .withArgs('/foo/animal.md', { encoding: 'utf8' })
    .returns(localStream);

  nock('http://github.com').get('/a.md').reply(200, 'remote!');
  nock('http://github.com').get('/i-dont-exist.md').reply(404);
});

test.after(() => {
  global.fs.createReadStream.restore();
});


test.cb('should resolve local file link', (t) => {
  const link = 'animal.md';
  const relativePath = '/foo';
  const source = '/foo/bar.md';

  resolveLink({ link, relativePath, source }, (err, input, resolvedLink, resolvedRelativePath) => {
    t.ifError(err);
    t.deepEqual(resolvedLink, '/foo/animal.md');
    t.deepEqual(resolvedRelativePath, relativePath);

    const concatStream = concat((result) => {
      t.deepEqual(result.toString('utf8'), 'local!');
github rodrigogs / nodejs-web-jade-scaffold / tests.js View on Github external
'use strict';

import test from 'ava';
import http from 'http';
import request from 'request';
import app from './main';

const baseUrl = 'http://127.0.0.1:3000';
let server;

test.before(() => {
    server = http.createServer(app).listen(3000, '127.0.0.1');
});

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

const getMethod = (t, url, params) => {
    t.plan(3);

    request.get({uri: url, qs: params}, (err, response, body) => {
        t.notOk(err, `Request error for url ${url}`);
        t.true(response && (response.statusCode >= 200 && response.statusCode < 399), `Url ${url} failed with status ${response ? response.statusCode : ''}`);
        t.ok(body, `Body is empty`);
        t.end();
    });
};

const postMethod = (t, url, params) => {
    t.plan(3);