import { from } from 'rxjs';
import { first, tap } from 'rxjs/operators';
import { ModelService } from './model-service';
import * as monaco from '@vscode/monaco-editor/esm/vs/editor/editor.api';
import { ITextModel, ITextBufferFactory, EndOfLineSequence } from '@vscode/monaco-editor/esm/vs/editor/common/model';
import 'jest';

describe('ModelService', () => {

    describe('addModel', () => {

        it('adds', async () => {
            const modelService = new ModelService();
            const modelUri = monaco.Uri.parse('a://b/foo.json'); // a made up unique URI for our model
            // const model: ITextModel = monaco.editor.createModel('', 'json', modelUri) as any;

            // modelService.onModelRemoved.pipe(tap(el => console.log('---trigger onModelAdd', el))).subscribe(e => console.log(e));

            const model = modelService.createModel('', 'json', modelUri);
            model.dispose();
            // expect(
            //     await from(modelService.models)
            //         .pipe(first())
            //         .toPromise(),
            // ).toMatchSnapshot();
            // model.dispose();

        });
        // it('refuses to add model with duplciate URI', async () => {
        //     const modelService = createModelService();
        //     const modelUri = monaco.Uri.parse('a://b/foo1.json'); // a made up unique URI for our model
        //     const model1: ITextModel = monaco.editor.createModel('', 'json', modelUri) as any;
        //     modelService.addModel(model1);
        //     expect(monaco.editor.createModel('', 'json', modelUri) as any).toThrowError('Cannot add model because it already exists!');
        // });

    });
});
