<commit_before>import React from 'react'
import renderer from 'react-test-renderer'
import Waffle from '../src/Waffle'

it('should render a basic waffle chart in SVG', () => {
    const component = renderer.create(
        <Waffle
            width={400}
            height={400}
            rows={10}
            columns={10}
            total={100}
            data={[{ id: 'one', label: 'one', value: 10 }]}
        />
    )

    let tree = component.toJSON()
    expect(tree).toMatchSnapshot()
})

const fillModes = ['top', 'right', 'bottom', 'left']
for (const fillMode of fillModes) {
    it(`should support ${fillMode} fill mode`, () => {
        const component = renderer.create(
            <Waffle
                width={400}
                height={400}
                rows={10}
                columns={10}
                total={100}
                data={[{ id: 'one', label: 'one', value: 10 }]}
                fillDirection={fillMode}
            />
        )

        let tree = component.toJSON()
        expect(tree).toMatchSnapshot()
    })
}<commit_msg>tests(waffle): add test for Waffle legends<commit_after>import React from 'react'
import renderer from 'react-test-renderer'
import { mount } from 'enzyme'
import { LegendSvg, LegendSvgItem } from '@nivo/legends'
import Waffle from '../src/Waffle'

it('should render a basic waffle chart in SVG', () => {
    const component = renderer.create(
        <Waffle
            width={400}
            height={400}
            rows={10}
            columns={10}
            total={100}
            data={[{ id: 'one', label: 'one', value: 10 }]}
        />
    )

    let tree = component.toJSON()
    expect(tree).toMatchSnapshot()
})

const fillModes = ['top', 'right', 'bottom', 'left']
for (const fillMode of fillModes) {
    it(`should support ${fillMode} fill mode`, () => {
        const component = renderer.create(
            <Waffle
                width={400}
                height={400}
                rows={10}
                columns={10}
                total={100}
                data={[{ id: 'one', label: 'one', value: 10 }]}
                fillDirection={fillMode}
            />
        )

        let tree = component.toJSON()
        expect(tree).toMatchSnapshot()
    })
}

describe('legends', () => {
    it('should support legends', () => {
        const data = [
            { id: 'one', label: 'one', value: 10 },
            { id: 'two', label: 'two', value: 20 },
            { id: 'tree', label: 'tree', value: 30 },
        ]
        const legends = [
            {
                anchor: 'top-left',
                direction: 'column',
                itemWidth: 100,
                itemHeight: 20,
            },
        ]
        const wrapper = mount(
            <Waffle
                width={400}
                height={400}
                rows={10}
                columns={10}
                total={100}
                colors={['red', 'green', 'blue']}
                data={data}
                legends={legends}
            />
        )

        expect(wrapper.find(LegendSvg)).toHaveLength(1)

        const legendItems = wrapper.find(LegendSvgItem)
        expect(legendItems).toHaveLength(3)
        expect(legendItems.at(0).prop('data')).toEqual({
            id: 'one',
            label: 'one',
            color: 'red',
        })
        expect(legendItems.at(1).prop('data')).toEqual({
            id: 'two',
            label: 'two',
            color: 'green',
        })
        expect(legendItems.at(2).prop('data')).toEqual({
            id: 'tree',
            label: 'tree',
            color: 'blue',
        })
    })
})
{'fraction_non_alphanumeric': 0.14792576419213974, 'fraction_numerical': 0.024290393013100438, 'mean_word_length': 1.5398475398475397, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 14, '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': '1349455', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1035, 'n_words': 242}