<commit_before>import { expect } from 'chai';

import Cascade, { VirtualNode, Component } from '../scripts/modules/Cascade';

describe('Fragment.toNode', function () {
    it('should render Fragment Nodes', () => {
        var root = (
            <>
                <div id="testId"></div>
            </>
        );
        let rootElement = document.createElement('div');
        Cascade.render(rootElement, root, function (element: HTMLElement) {
            let div: HTMLElement = rootElement.childNodes[0] as any;
            expect(div.id).to.equal('testId');
        });
    });
});<commit_msg>Added Fragment diff test.<commit_after>import { expect } from 'chai';

import Cascade, { VirtualNode, Component, observable } from '../scripts/modules/Cascade';

describe('Fragment.toNode', function () {
    it('should render Fragment Nodes', () => {
        var root = (
            <>
                <div id="testId"></div>
            </>
        );
        let rootElement = document.createElement('div');
        Cascade.render(rootElement, root, function (element: HTMLElement) {
            let div: HTMLElement = rootElement.childNodes[0] as any;
            expect(div.id).to.equal('testId');
        });
    });

    it('should be able to Diff', (done) => {
        class ViewModel {
            @observable value = false;
        }
        interface IViewProps {
            viewModel: ViewModel;
        }
        class WithFragments extends Component<any> {
            render() {
                return (
                    <>
                        <div>a</div>
                        <div>b</div>
                    </>
                );
            }
        }
        class WithoutFragments extends Component<any> {
            render() {
                return (
                    <div>c</div>
                );
            }
        }
        class View extends Component<IViewProps> {
            render() {
                return (
                    <span>
                        {this.props.viewModel.value ?
                            <WithoutFragments /> :
                            <WithFragments />
                        }
                    </span>
                );
            }
        }
        var viewModel = new ViewModel();
        var container = document.createElement('div')
        Cascade.render(container, <View viewModel={viewModel} />);
        viewModel.value = true;
        window.setTimeout(() => {
            let span = container.childNodes[0];
            let div = span.childNodes[0];
            let text = div.textContent;
            expect(span.childNodes.length).to.equal(1);
            expect(div.childNodes.length).to.equal(1);
            expect(text).to.equal('c');
            done();
        }, 20);
    });
});
{'fraction_non_alphanumeric': 0.12875536480686695, 'fraction_numerical': 0.002861230329041488, 'mean_word_length': 1.3824531516183987, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, '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': '4863903', 'n_tokens_mistral': 738, 'n_tokens_neox': 712, 'n_words': 142}