<commit_before>/**
 * Created by matheus on 5/14/16.
 */

import test from 'ava';
import translate from './index';

test('translate from \'\' (auto) to \'\' (english)', async t => {
    const res = await translate('Ik spreek Engels', {});
    t.falsy(res.text.corrected);
    t.falsy(res.text.correction);
    t.is(res.text.value, 'I speak English');
    t.falsy(res.from.corrected);
    t.is(res.from.iso, 'nl');
});

test('translate from auto to dutch', async t => {
    const res = await translate('I speak Dutch', {from: 'auto', to: 'nl'});

    t.falsy(res.text.corrected);
    t.falsy(res.text.correction);
    t.is(res.text.value, 'ik spreek Nederlands');
    t.falsy(res.from.corrected);
    t.is(res.from.iso, 'en');
});<commit_msg>Catch promise rejection in tests<commit_after>/**
 * Created by matheus on 5/14/16.
 */

import test from 'ava';
import translate from './index';

test('translate from \'\' (auto) to \'\' (english)', async t => {
    try {
        const res = await translate('Ik spreek Engels');

        t.falsy(res.text.corrected);
        t.falsy(res.text.correction);
        t.is(res.text.value, 'I speak English');
        t.falsy(res.from.corrected);
        t.is(res.from.iso, 'nl');
    } catch (err) {
        t.fail(err.code);
    }
});

test('translate from auto to dutch', async t => {
    try {
        const res = await translate('I speak Dutch', {from: 'auto', to: 'nl'});

        t.falsy(res.text.corrected);
        t.falsy(res.text.correction);
        t.is(res.text.value, 'ik spreek Nederlands');
        t.falsy(res.from.corrected);
        t.is(res.from.iso, 'en');
    } catch (err) {
        t.fail(err.code);
    }
});
{'fraction_non_alphanumeric': 0.18982035928143712, 'fraction_numerical': 0.005988023952095809, 'mean_word_length': 2.70509977827051, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3117794', 'n_tokens_mistral': 632, 'n_tokens_neox': 601, 'n_words': 136}