<commit_before>import React from 'react';
import test from 'ava';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import Dropzone from "react-dropzone";

import AttachmentAdder from "../../src/components/attachment/AttachmentAdder";

require('ignore-styles')

const defaultAttachmentAdder = <AttachmentAdder sendChange = {(file) => {}} />

test('has Dropzone element', t=> {
    const wrapper = shallow(defaultAttachmentAdder);
    t.is(wrapper.find(Dropzone).length, 1);
});

test('if no maximum size, header tells it', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const header = <h1>Upload attachments as much as you want</h1>;
    t.truthy(wrapper.contains(header));
})

test('header informs no fiels uploaded when started', t=> {
    const wrapper = shallow(defaultAttachmentAdder);
    const noElementsHeader = <h2>No attachments uploaded</h2>;
    t.truthy(wrapper.contains(noElementsHeader));
})

test('headers changes when attachment is added', t=> {

    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    const oneElementAddedHeader = <h2>One attachment uploaded:</h2>;
    t.truthy(wrapper.contains(oneElementAddedHeader));
})

test('added attachment has button so u can remove it', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    t.truthy(wrapper.find('button').length, 1);
})

test('when button is clicked, it tells u no attachments uploaded', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    wrapper.find('button').simulate('click');

    const noElementsHeader = <h2>No attachments uploaded</h2>;
    t.truthy(wrapper.contains(noElementsHeader));
})

test("when delete button is clicked, it is removed from the view", t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    wrapper.find('button').simulate('click');

    t.truthy(wrapper.find('button').length, 0);
})

const getFileList = () => {
    const file = {name: "MattiLuukkainenFullStack.sql"};
    const fileArray = [file];
    return fileArray;
}<commit_msg>fixed test fuk yea<commit_after>import React from 'react';
import test from 'ava';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import Dropzone from "react-dropzone";

import AttachmentAdder from "../../src/components/attachment/AttachmentAdder";

require('ignore-styles')

const defaultAttachmentAdder = <AttachmentAdder sendChange = {(file) => {}} />

test('has Dropzone element', t=> {
    const wrapper = shallow(defaultAttachmentAdder);
    t.is(wrapper.find(Dropzone).length, 1);
});

test('if no maximum size, header tells it', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const header = <h1>Upload attachments as much as you want</h1>;
    t.truthy(wrapper.contains(header));
})

test('header informs no files uploaded when started', t=> {
    const wrapper = shallow(defaultAttachmentAdder);
    const noElementsHeader = <h2>No attachments uploaded</h2>;
    t.truthy(wrapper.contains(noElementsHeader));
})

test('headers changes when attachment is added', t=> {

    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    const oneElementAddedHeader = <h2>One attachment uploaded:</h2>;
    t.truthy(wrapper.contains(oneElementAddedHeader));
})

test('added attachment has button so u can remove it', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    t.truthy(wrapper.find('button').length, 1);
})

test('when button is clicked, it tells u no attachments uploaded', t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    wrapper.find('button').simulate('click');

    const noElementsHeader = <h2>No attachments uploaded</h2>;
    t.truthy(wrapper.contains(noElementsHeader));
})

test("when delete button is clicked, it is removed from the view", t => {
    const wrapper = shallow(defaultAttachmentAdder);
    const files = getFileList();
    wrapper.setState({attachments: files});
    wrapper.find('button').simulate('click');
    t.is(wrapper.find('button').length, 0);
})

const getFileList = () => {
    const file = {name: "MattiLuukkainenFullStack.sql"};
    const fileArray = [file];
    return fileArray;
}
{'fraction_non_alphanumeric': 0.13822894168466524, 'fraction_numerical': 0.004751619870410367, 'mean_word_length': 4.7102342786683105, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 39, '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': '5923213', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1341, 'n_words': 359}