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

import { HTMLManager } from '../../lib/';
import { OutputModel, OutputView } from '../../lib/output';

import * as widgets from '@jupyter-widgets/controls'

describe('text output', () => {

    let model: widgets.WidgetModel;
    let view;
    let manager: HTMLManager;

    beforeEach(async function() {
        const widgetTag = document.createElement('div');
        widgetTag.className = 'widget-subarea';
        document.body.appendChild(widgetTag);
        manager = new HTMLManager()
        const modelId = 'u-u-i-d';
        const modelCreate: widgets.ModelOptions = {
            model_name: 'OutputModel',
            model_id: modelId,
            model_module: '@jupyter-widgets/controls',
            model_module_version: '*'
        }
        const modelState = {
            outputs: [
                {
                    "output_type": "stream",
                    "name": "stdout",
                    "text": "this-is-a-test\n"
                }
            ],
        }
        model = await manager.new_model(modelCreate, modelState);
        view = await manager.display_model(
            undefined, model, { el: widgetTag }
        );
    })

    it('create the view', () => {
        expect(view).to.not.be.undefined
    });

    it('display the view', () => {
        const outputView = (view as OutputView);
        const el = view.el;
        expect(el.textContent).to.equal('this-is-a-test\n')
    });
})<commit_msg>Factor out test fixture<commit_after>
import { expect } from 'chai';

import { HTMLManager } from '../../lib/';
import { OutputModel, OutputView } from '../../lib/output';

import * as widgets from '@jupyter-widgets/controls'

const newWidget = async (modelState) => {
    const widgetTag = document.createElement('div');
    widgetTag.className = 'widget-subarea';
    document.body.appendChild(widgetTag);
    const manager = new HTMLManager()
    const modelId = 'u-u-i-d';
    const modelCreate: widgets.ModelOptions = {
        model_name: 'OutputModel',
        model_id: modelId,
        model_module: '@jupyter-widgets/controls',
        model_module_version: '*'
    }
    const model = await manager.new_model(modelCreate, modelState);
    const view = await manager.display_model(
        undefined, model, { el: widgetTag }
    );
    return view;
}


describe('text output', () => {
    let view;
    const textValue = 'this-is-a-test\n'
    const modelState = {
        outputs: [
            {
                "output_type": "stream",
                "name": "stdout",
                "text": textValue
            }
        ],
    }

    beforeEach(async function() {
        view = await newWidget(modelState)
    })

    it('create the view', () => {
        expect(view).to.not.be.undefined
    });

    it('display the view', () => {
        const outputView = (view as OutputView);
        const el = view.el;
        expect(el.textContent).to.equal(textValue)
    });
})
{'fraction_non_alphanumeric': 0.13946488294314383, 'fraction_numerical': 0.0, 'mean_word_length': 2.0676923076923077, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 10, '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': '2489713', 'n_tokens_mistral': 878, 'n_tokens_neox': 857, 'n_words': 190}