Beispiel #1
0
	testFiles.forEach(filename => {
		const basename = path.basename(filename, '.js');
		const filepath = path.join(testsDir, filename);

		test.serial(basename, async t => {
			await t.notThrows(execa('karma', ['start', conf], {
				cwd,
				env: Object.assign({}, process.env, {ANY_OBSERVABLE_TEST_PATH: filepath})
			}));
		});
	});
Beispiel #2
0
const testFile = (file, group) => {
  let description = svgs[group][file],
    actual_path = path.resolve(`${actual_folder}/${group}_${file}.png`),
    actual_file;

  test.serial(`comparing results for ${file} (${description})`, async t => {
    return openPage(browser, file, t, port)
      .then(canvas_dataurl => {
        return getBuffersBrowser(file, canvas_dataurl);
      })
      .then(({ canvasBuffer, expectedImg }) => {
        actual_file = canvasBuffer;
        return runDiff(
          canvasBuffer,
          expectedImg,
          `${diff_folder}/${group}_${file}.png`,
          0.03
        );
      })
      .then(async ({ res, differences }) => {
        if (!res) {
          await fs.writeFileAsync(actual_path, actual_file);
          if (group === "broken") {
            t.log(`skip broken ${file}`);
            t.truthy.skip(`skip broken ${file}`);
          } else {
            t.fail(
              `${file}.png has ${differences} differences with compared file`
            );
          }
        } else {
          t.truthy(res);
        }
      })
      .catch(async err => {
        await fs.writeFileAsync(actual_path, actual_file);
        t.log(err);
        t.fail(err.message);
      });
  });
};
Beispiel #3
0
server.setup();
const {initDashboard} = browser.setup();

import * as C from '../helpers/test-constants';

let dashboard;
test.before(async () => {
	dashboard = await initDashboard();
});

test.serial('should return a reference to any already-declared replicant', async t => {
	const ret = await dashboard.evaluate(() => {
		const rep1 = window.dashboardApi.Replicant('clientDupRef');
		const rep2 = window.dashboardApi.Replicant('clientDupRef');
		return rep1 === rep2;
	});

	t.true(ret);
});

test.serial('should only apply defaultValue when first declared', async t => {
	t.context.apis.extension.Replicant('clientTest', {
		defaultValue: 'foo',
		persistent: false
	});

	const ret = await dashboard.evaluate(() => new Promise(resolve => {
		const rep = window.dashboardApi.Replicant('clientTest', {defaultValue: 'bar'});
		rep.on('declared', () => resolve(rep.value));
	}));
const snippetFilePath = path.join(os.tmpdir(), 'test', 'delete-snippet')
const snippetFile = path.join(snippetFilePath, 'snippets.json')
const newSnippet = {
  id: crypto.randomBytes(16).toString('hex'),
  name: 'Unnamed snippet',
  prefix: [],
  content: ''
}

test.beforeEach((t) => {
  sander.writeFileSync(snippetFile, JSON.stringify([newSnippet]))
})

test.serial('Delete a snippet', (t) => {
  return Promise.resolve()
    .then(function doTest () {
      return Promise.all([
        deleteSnippet(newSnippet, snippetFile)
      ])
    })
    .then(function assert (data) {
      data = data[0]
      const snippets = JSON.parse(sander.readFileSync(snippetFile))
      t.is(snippets.length, 0)
    })
})

test.after.always(() => {
  sander.rimrafSync(snippetFilePath)
})
Beispiel #5
0
  await db.model('people', {
    name: String,
    age: Number
  })

  return Promise.all(people.map(person => db.create('people', person)))
})

test.after.always(() => db.close())

test.serial('increments by 1 when no amount is provided', async t => {
  const values = await Promise.all(
    people.map(({ name, age }, i) => {
      people[i].age += 1
      return db.incr('people.age', { name })
        .then(() => db.get('people.age', { name }))
        .then(val => [age, val])
    })
  )

  values.forEach(([age, val]) => t.is(val, age + 1))
})

test.serial('increments by a specified amount', async t => {
  const values = await Promise.all(
    people.map(({ name, age }, i) => {
      people[i].age += 4
      return db.incr('people.age', { name }, 4)
        .then(() => db.get('people.age', { name }))
        .then(val => [age, val])
    })
  )
Beispiel #6
0
const port = 4006
const url = route => 'http://localhost:' + port + route

let nuxt = null
let builder = null
let buildSpies = null

// Init nuxt.js and create server listening on localhost:4000
test.serial('Init Nuxt.js', async t => {
  const rootDir = resolve(__dirname, 'fixtures/module')
  const config = require(resolve(rootDir, 'nuxt.config.js'))
  config.rootDir = rootDir
  config.dev = false
  nuxt = new Nuxt(config)
  builder = new Builder(nuxt)

  buildSpies = await intercept({ log: true, error: true }, async () => {
    await builder.build()
    await nuxt.listen(port, 'localhost')
  })

  t.true(buildSpies.log.calledWithMatch('DONE'))
  t.true(buildSpies.log.calledWithMatch('OPEN'))
})

test.serial('Vendor', async t => {
  t.true(
    nuxt.options.build.vendor.indexOf('lodash') !== -1,
    'lodash added to config'
  )
})
Beispiel #7
0
  };

  setState = sinon.stub(reactElement, 'setState').callsFake((value, callback) => {
    reactElement.state = value;
    callback(value);
  });
});

test.afterEach(() => {
  if (setState) {
    setState.restore();
  }
});

test.serial('should return a function', (t) => {
  t.is(typeof onValueChange(), 'function');
});

test.serial('should call setState when triggered', t => onValueChange(reactElement, 'test')('value').then(() => t.true(setState.calledOnce)));

test.serial('should call callback with matching object', t => onValueChange(reactElement, 'test')('value').then(data => t.deepEqual(data, { test: 'value' })));

test.serial('should call setState with matching object when innerKey', t => onValueChange(
  {
    ...reactElement,
    state: {
      myAwesomeObj: {
        existing: 'key',
      },
    },
  },
Beispiel #8
0
var logger = new OpenT2TLogger("info");
var OpenT2T = require('opent2t').OpenT2T;
var opent2t = new OpenT2T(logger);

console.log("Test Config:");
console.log(JSON.stringify(testConfig, null, 2));

///
/// Run a series of tests to validate the translator
///

// onboard
test.serial('onboard', t => {

    return opent2t.createTranslatorAsync(onboardingPath, 'thingOnboarding', testConfig)
        .then(onboarding => {
            // TEST: translator is valid
            t.is(typeof onboarding, 'object') && t.truthy(onboarding);

            return opent2t.invokeMethodAsync(onboarding, "org.opent2t.onboarding.wink", "onboard", [testConfig])
                .then((accessToken) => {
                    console.log("accessToken:");
                    console.log(JSON.stringify(accessToken, null, 2));

                    // TEST: something was returned
                    t.truthy(accessToken);
                    t.truthy(accessToken.accessToken);
                });
        });
});
Beispiel #9
0
const inspect = require('util').inspect,
  test = require('ava');

var Fn;
test.before.serial(t => {
  Fn = Services.getAccount;
});


test.serial('getAccount (No Arguments)', t => {

  var Input = {};

  return Fn(Input)
  .then(Result => {

    t.ok(Result.error);
    t.ok(Result.error.length === 1);

    // Print
    // console.log(inspect(Result, { depth: null }));
  });
});

test.serial('getAccount (Invalid id)', t => {

  var Input = {
    id: '56be1d2a54d12187e6ee764x',
  };

  return Fn(Input)
  .then(Result => {
        );
        fs.unlinkSync(errorFile);
    } catch (e) {
        // No error.txt present. That's good!
    }

    if (t.context.app && t.context.app.isRunning()) {
        await t.context.app.stop();
    }
});

test('the test app', async t => getApp(t));

test.serial('if testEvent returns true for 1', async (t) => {
    const app = await getApp(t);
    await constructModule(app);
    await fireEventsBusEventAndWaitForAnother(app, 'desktopLoaded', 'example.loaded');
    const response = await fetch(app, 'example', 'testEvent', 1);
    // Fetch returns an array with the response event arguments.
    t.true(response[0]);
});

test.serial('if testEvent returns false for 5', async (t) => {
    const app = await getApp(t);
    await constructModule(app);
    await fireEventsBusEventAndWaitForAnother(app, 'desktopLoaded', 'example.loaded');
    const response = await fetch(app, 'example', 'testEvent', 5);
    // Fetch returns an array with the response event arguments.
    t.false(response[0]);
});
      if (err) t.fail('Unable to create posts');
    });
  });
});

test.afterEach.always(t => {
  dropDB(t);
});

test.serial('Should send correct data when queried against a cuid', async t => {
  t.plan(2);

  const post = new Post({ name: 'Foo', title: 'bar', slug: 'bar', cuid: 'f34gb2bh24b24b2', content: 'Hello Mern says Foo' });
  post.save();

  const res = await request(app)
    .get('/api/posts/f34gb2bh24b24b2')
    .set('Accept', 'application/json');

  t.is(res.status, 200);
  t.is(res.body.post.name, post.name);
});

test.serial('Should correctly add a post', async t => {
  t.plan(2);

  const res = await request(app)
    .post('/api/posts')
    .send({ post: { name: 'Foo', title: 'bar', content: 'Hello Mern says Foo' } })
    .set('Accept', 'application/json');
Beispiel #12
0
// Save the current working diretory
const cwd = process.cwd();

test.beforeEach(() => {
  // Change current working directory to a temp directory
  process.chdir(tempy.directory());
});

test.afterEach.always(() => {
  // Restore the current working directory
  process.chdir(cwd);
});

test.serial('Get default registry', async t => {
  const registry = await getRegistry({}, 'package-name');

  t.is(registry, 'https://registry.npmjs.org/');
});

test.serial('Get the registry configured in ".npmrc" and normalize trailing slash', async t => {
  await appendFile('./.npmrc', 'registry = https://custom1.registry.com');
  const registry = await getRegistry({}, 'package-name');

  t.is(registry, 'https://custom1.registry.com/');
});

test.serial('Get the registry configured from "publishConfig"', async t => {
  const registry = await getRegistry({registry: 'https://custom2.registry.com/'}, 'package-name');

  t.is(registry, 'https://custom2.registry.com/');
});
test.serial('subscribe does not add an event listener within the TTL until redeemInitSession returns', t => {
  /*
   * Desperately want a mock framework for this
   */

  // Modify the NativeEventEmitter used by branch to track whether a listener has been added
  this.listenerAdded = false
  mock(branch.nativeEventEmitter, 'addListener', (event, listener) => {
    this.listenerAdded = true
  })

  // Modify RNBranch.redeemInitSessionResult to check whether a listener has been added
  mock(RNBranch, 'redeemInitSessionResult', () => {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        t.false(this.listenerAdded)
        resolve({error: null, params: null, uri: null})
      }, 100)
    })
  })

  return new Promise((resolve, reject) => {
    branch.subscribe(({error, params, uri}) => {})

    setTimeout(() => {
      this.listenerAdded ? resolve() : reject('listener was not added')
    }, 200)
  })
})
Beispiel #14
0
const projectDir = resolvePath(__dirname, '..')

function bytes (base64) {
  if (typeof base64 === 'undefined') return null

  return Buffer.from(base64, 'base64')
}

const async = (...args) => packageHash(...args).then()

let ownHash = null
test.serial('hashes itself', async t => {
  const [result] = await Promise.all([
    // Run in parallel to provide code coverage to ownHashPromise usage
    async(join(projectDir, 'package.json')),
    async(join(projectDir, 'package.json'))
  ])
  t.true(typeof result === 'string')
  t.true(result.length > 0)
  ownHash = Buffer.from(result, 'hex')
})

test('throws when called with a directory that is not an installed package', async t => {
  const err = await t.throwsAsync(async(resolveFixture('unpacked', 'not-a-package', 'package.json')))
  t.is(err.code, 'ENOENT')
})

test('throws when called with a non-existent path', async t => {
  const err = await t.throwsAsync(async(resolveFixture('does-not-exist', 'package.json')))
  t.is(err.code, 'ENOENT')
})
Beispiel #15
0
	{
		const glob = path.join(__dirname, 'fixtures/nodir/nested/*');
		const results = await fn.lintFiles(glob);
		const {results: [fileResult]} = results;

		// Ensure `nodir/nested` **would** report if globbed
		const expected = 'fixtures/nodir/nested/index.js'.split('/').join(path.sep);
		const actual = path.relative(__dirname, fileResult.filePath);
		t.is(actual, expected);
		t.is(results.errorCount, 1);
	}
});

test.serial('cwd option', async t => {
	const {results} = await fn.lintFiles('**/*', {cwd: 'fixtures/cwd'});
	const paths = results.map(r => path.relative(__dirname, r.filePath));
	paths.sort();
	t.deepEqual(paths, [path.join('fixtures', 'cwd', 'unicorn.js')]);
});

test('do not lint gitignored files', async t => {
	const cwd = path.join(__dirname, 'fixtures/gitignore');
	const glob = path.posix.join(cwd, '**/*');
	const ignored = path.resolve('fixtures/gitignore/test/foo.js');
	const {results} = await fn.lintFiles(glob, {cwd});

	t.is(results.some(r => r.filePath === ignored), false);
});

test('do not lint gitignored files in file with negative gitignores', async t => {
	const cwd = path.join(__dirname, 'fixtures/negative-gitignore');
	const glob = path.posix.join(cwd, '*');
test.afterEach(t => {
	t.context.mock.unset();
});

test.serial('missing fields', t => {
	t.throws(
		deploy({ clientSecret: 'q', refreshToken: 'q', id: 'q', zip: 'q' }),
		'Missing required field: clientId'
	);
	t.throws(
		deploy({ clientId: 'q', refreshToken: 'q', id: 'q', zip: 'q' }),
		'Missing required field: clientSecret'
	);
	t.throws(
		deploy({ clientId: 'q', clientSecret: 'q', id: 'q', zip: 'q' }),
		'Missing required field: refreshToken'
	);
	t.throws(
		deploy({ clientId: 'q', clientSecret: 'q', refreshToken: 'q', zip: 'q' }),
		'Missing required field: id'
	);
	t.throws(
		deploy({ clientId: 'q', clientSecret: 'q', refreshToken: 'q', id: 'q' }),
		'Missing required field: zip'
	);
});

test.serial('invalid publish target', t => {
	t.throws(
		deploy({ to: 'foobar', clientId: 'q', clientSecret: 'q', refreshToken: 'q', id: 'q', zip: 'q' }),
		'Invalid publish target: foobar'
Beispiel #17
0
test.before(async () => {
  await nm
    .goto(`${process.env.startPoint}/register`)
    .wait(1000)
    .insert('form input[name=email]', 'category@category.ru')
    .insert('form input[name=password]', '12345678')
    .insert('form input[name=repeatPassword]', '12345678')
    .click('form button[type=submit]')
    .wait(2000);
});

test.serial('default categories', async (t) => {
  nm
    .goto(`${process.env.startPoint}/dashboard/categories`)
    .evaluate(() => document.querySelectorAll('.btn.btn-block + div > div').length)
    .then((defaultCategoriesCount) => {
      t.true(defaultCategoriesCount => 3);
    });
});

test.serial('remove default category', async (t) => {
  const selectCategoriesCount = (ctx) => ctx
    .evaluate(() => document.querySelectorAll('.btn.btn-block + div > div').length);

  const categoriesCount = await selectCategoriesCount(nm);

  await nm
    .click('.btn.btn-block + div > div:last-child button:last-child')
    .click('form .btn-danger')
    .wait(500)
    .click('.modal-footer .btn-danger')
Beispiel #18
0
/*
* @Author: sahildua2305
* @Date:   2016-06-21 20:07:34
* @Last Modified by:   Sahil Dua
* @Last Modified time: 2016-06-21 20:13:58
*/

'use strict';

import test from 'ava';

test.serial('checkroot() when user is root', async t => {
  process.env.USER = 'root';
  process.env.LOGNAME = 'root';
  t.is(require('../')(), true);
});
      responseBody
    )
    fauxJax.restore()

    defer(t.end)
  }

  fauxJax.install()
  fauxJax.on('request', respond)
  t.context.data = mount(Users)
})

test.afterEach(t => t.context.data.wrapper.unmount())

test.serial('it should render users after request', t => {
  const { wrapper } = t.context.data
  expect(wrapper).to.have.exactly(1).descendants('.user--row')
})

test.serial('it should remove an user', t => {
  const { wrapper } = t.context.data
  wrapper.find('.user--remove').first().simulate('click')
  expect(wrapper).to.not.have.descendants('.user--row')
})

test.serial('it should handle errors', t => {
  const { flux } = t.context.data
  const { error } = flux.getStore('users').getState()
  t.is(error.error, 'foobar')
})
Beispiel #20
0
const dest = '.tmp';
const src = './fixtures/grey-chrome.png';
const verifyImage = (image, size) => {
	var dimensions = sizeof(path.join(dest, image));
	size = Math.floor(size);
	return (dimensions.height === size) && (dimensions.width === size);
};

test.cb.before(t => {
	rm(dest, () => md(dest, t.end));
});

test.serial('square to a image', t => {
	return square(src, dest, 32).then(images => {
		Object.keys(images).forEach(size => t.ok(verifyImage(images[size].src, size)));
	});
});

test.serial('square to multiple images', t => {
	return square(src, dest, [64, 92]).then(images => {
		Object.keys(images).forEach(size => t.ok(verifyImage(images[size].src, size)));
	});
});

test.serial('square to multiple images in various options', t => {
	var resizedImages = [
		'icon-128x128.png',
		'ms-touch-icon-144x144-precomposed.png',
		'chrome-splashscreen-icon-152x152.png',
		'chrome-touch-icon-192x192.png'
import test from 'ava';

import * as defaults from '../source/lib/defaults';
import {renderCount, renderError} from '../source/lib/badge';

test.beforeEach(() => {
	browser.flush();
});

test.serial('#renderCount uses default badge color', t => {
	const count = 42;
	const color = defaults.getBadgeDefaultColor();

	renderCount(count);

	const text = String(count);
	const title = defaults.defaultTitle;

	t.true(browser.browserAction.setBadgeText.calledWith({text}));
	t.true(browser.browserAction.setBadgeBackgroundColor.calledWith({color}));
	t.true(browser.browserAction.setTitle.calledWith({title}));
});

test.serial('#renderCount renders empty string when notifications count is 0', t => {
	const count = 0;
	const color = defaults.getBadgeDefaultColor();

	renderCount(count);

	const text = '';
	const title = defaults.defaultTitle;
Beispiel #22
0
import fs from 'fs';
import {serial as test} from 'ava';
import pathExists from 'path-exists';
import Configstore from './';

const configstorePath = new Configstore('configstore-test').path;

test.beforeEach(t => {
	fs.unlinkSync(configstorePath);
	t.context.conf = new Configstore('configstore-test');
});

test('.set() and .get()', t => {
	t.context.conf.set('foo', 'bar');
	t.context.conf.set('baz.boo', true);
	t.is(t.context.conf.get('foo'), 'bar');
	t.is(t.context.conf.get('baz.boo'), true);
});

test('.set() with object and .get()', t => {
	t.context.conf.set({
		foo1: 'bar1',
		foo2: 'bar2',
		baz: {
			boo: 'foo',
			foo: {
				bar: 'baz'
			}
		}
	});
	t.is(t.context.conf.get('foo1'), 'bar1');
  mockery.warnOnUnregistered(false)
  mockery.registerAllowables([''])
})

test.afterEach(() => {
  mockery.deregisterAll()
  mockery.resetCache()
  mockery.disable()
})

test.serial('readConfig() should reject if config.xml cannot be found', (t) => {
  const fsMock = {
    access: (p, cb) => cb(new Error('blah'))
  }

  mockery.registerMock('fs', fsMock)

  const PV = require(pluginValidatorModule)
  const pv = new PV(process.cwd())
  return t.throws(pv.readConfig(), 'config.xml not found')
})

test.serial('readConfig() should reject if config.xml cannot be read', (t) => {
  const fsMock = {
    access: (p, cb) => cb(),
    readFile: (path, enc, cb) => cb(new Error('blah'))
  }

  mockery.registerMock('fs', fsMock)

  const PV = require(pluginValidatorModule)
Beispiel #24
0
const inspect = require('util').inspect,
  test = require('ava');

var Fn;
test.before.serial(t => {
  Fn = Services.validateToken;
});


test.serial('validateToken (Object Token)', t => {

  var Input = {};

  return Fn(Input)
  .then(Result => {

    t.ok(Result.result === false);

    // Print
    // console.log(inspect(Result, { depth: null }));
  });
});

test.serial('validateToken (Empty Token)', t => {

  var Input = '';

  return Fn(Input)
  .then(Result => {

    t.ok(Result.result === false);
    browser.storage.local.get.withArgs("errorStates").resolves({
        errorStates: []
    });
});

test.serial('unregister', async (t) => {
    browser.storage.local.set.resetHistory();

    browser.storage.local.get.withArgs("errorStates").resolves({
        errorStates: [ {
            id: 'foo',
            gravity: 0,
            message: 'bar',
            actions: []
        } ]
    });

    const rv = await errorStateManager.unregister('foo');

    t.true(browser.storage.local.set.calledOnce);
    t.is(browser.storage.local.set.lastCall.args[0].errorStates.length, 0);
    t.true(rv);

    browser.storage.local.get.withArgs("errorStates").resolves({
        errorStates: []
    });
});

test.serial('register', async (t) => {
    browser.storage.local.set.resetHistory();

    const es = {
Beispiel #26
0
const request = supertest(app);

test.before.cb(t => {
  agenda.on('ready', () => {
    t.end();
  });
});

test.beforeEach(async () => {
  await agenda._collection.deleteMany({}, null);
});

test.serial('GET /api with no jobs should return the correct overview', async t => {
  const res = await request.get('/api');

  t.is(res.body.overview[0].displayName, 'All Jobs');
  t.is(res.body.jobs.length, 0);
});

test.serial('POST /api/jobs/create should confirm the job exists', async t => {
  const res = await request.post('/api/jobs/create')
  .send({
    jobName: 'Test Job',
    jobSchedule: 'in 2 minutes',
    jobRepeatEvery: '',
    jobData: {}
  })
  .set('Accept', 'application/json');

  t.true('created' in res.body);
            t.is(await prefs.get(dump.PREFS_MAPPING[branch][name]), dumpData.prefs[branch][name], `Value for ${branch}.${name} exported correctly`);
        }
    }
});

test("Dump frozen", async (t) => {
    const checkObject = (obj, assertOk) => {
            for(const p in obj) {
                if(typeof obj[p] === "object" && !Array.isArray(obj[p])) {
                    checkObject(obj[p], assertOk);
                }
            }
            assertOk(Object.isFrozen(obj), "object is frozen");
        },
        dumpData = await dump.create(CHANNELS_FIXTURE, USERS_FIXTURE);

    checkObject(dumpData, (...args) => t.true(...args));
});

test.serial("Prefs import", async (t) => {
    const dumpData = await dump.create(CHANNELS_FIXTURE, USERS_FIXTURE);

    await dump.load(dumpData);

    for(const branch in dump.PREFS_MAPPING) {
        for(const name in dump.PREFS_MAPPING[branch]) {
            t.is(await prefs.get(dump.PREFS_MAPPING[branch][name]), dumpData.prefs[branch][name], `Value for ${branch}.${name} imported correctly`);
        }
    }
});
Beispiel #28
0
const Database = proxyquire('../lib/database.js', {
  mongodb: {MongoClient}
})

test.beforeEach(async t => {
  t.context.db = await mongodb.MongoClient.connect(MONGODB_URL)
  await t.context.db.dropDatabase()
})

test.after(async () => {
  const db = await mongodb.MongoClient.connect(MONGODB_URL)
  await db.dropDatabase()
})

test.serial('constructor', t => {
  const database = new Database({url: 'URL'})
  t.is(database.url, 'URL')
})

test.serial('connect', async t => {
  MongoClient.connect = sinon.spy(() => Promise.resolve('DB'))

  const database = new Database({url: 'URL'})
  await database.connect()

  t.true(MongoClient.connect.calledWith('URL'))
  t.is(database.db, 'DB')
})

test.serial('disconnect', async t => {
  const database = new Database({})
  database.db = {close: sinon.spy(() => Promise.resolve())}
Beispiel #29
0
const inspect = require('util').inspect,
  test = require('ava');

var Fn;
test.before.serial(t => {
  Fn = Services.login;
});


test.serial('login (No Arguments)', t => {

  var Input = {};

  return Fn(Input)
  .then(Result => {

    t.ok(Result.error);
    t.ok(Result.error.length === 1);

    // Print
    // console.log(inspect(Result, { depth: null }));
  });
});

test.serial('login (Only Password - Short Password)', t => {

  var Input = {
    password: 'kevin'
  };

  return Fn(Input)
  .then(Result => {
  }

  fauxJax.install()
  fauxJax.on('request', respond)

  // get only flux instance to initialize component with flux store
  // before rendering happens
  const flux = mount(undefined, {}, true)
  if (testCount === 2) flux.getActions('users').indexSuccess([ JSON.parse(exampleUser) ])
  t.context.data = mount(Profile, { params: { seed: '7729a1ef4ba6ef68' } }, flux)
})

test.afterEach(t => t.context.data.wrapper.unmount())

test.serial('it should render username after request', t => {
  const { wrapper } = t.context.data
  expect(wrapper.find('h2')).to.have.text('Clara Coleman')
})

test.serial('it should render picture after request', t => {
  const { wrapper } = t.context.data
  expect(wrapper.find('img')).to.have.attr(
    'src',
    'http://api.randomuser.me/portraits/med/women/72.jpg'
  )
})

test.serial('it should handle errors', t => {
  const { flux } = t.context.data
  const { error } = flux.getStore('users').getState()
  t.is(error.error, 'foobar')
})