<commit_before>﻿describe('blockEditorService tests', function () {

    var blockEditorService, contentResource;

    beforeEach(module('umbraco.services'));
    beforeEach(module('umbraco.resources'));
    beforeEach(module('umbraco.mocks'));
    
    beforeEach(inject(function ($injector, mocksUtils) {

        mocksUtils.disableAuth();

        contentResource = $injector.get("contentResource");
        spyOn(contentResource, "getScaffold").and.callFake(
            function () {
                return Promise.resolve(mocksUtils.getMockVariantContent(1234))
            }
        );

        blockEditorService = $injector.get('blockEditorService');

    }));

    var simpleBlockConfigurationMock = {contentTypeAlias: "testAlias", label:"Test", settingsElementTypeAlias: null, view: "testview.html"};

    describe('init blockEditoModelObject', function () {
        
        it('fail if no model value', function () {
            function createWithNoModelValue() {
                blockEditorService.createModelObject(null, "test", []);
            }
            expect(createWithNoModelValue).toThrow();
        });

        it('return a object, with methods', function () {
            var modelObject = blockEditorService.createModelObject({}, "test", []);

            expect(modelObject).not.toBeUndefined();
            expect(modelObject.loadScaffolding).not.toBeUndefined();
        });

        it('getBlockConfiguration provide the requested block configurtion', function () {
            var modelObject = blockEditorService.createModelObject({}, "test", [simpleBlockConfigurationMock]);
            
            expect(modelObject.getBlockConfiguration(simpleBlockConfigurationMock.contentTypeAlias).label).toBe(simpleBlockConfigurationMock.label);
        });
        
        it('loadScaffolding provides data for itemPicker', function (done) {
            var modelObject = blockEditorService.createModelObject({}, "test", [simpleBlockConfigurationMock]);
            
            var pendingPromise = modelObject.loadScaffolding().then(() => {
                var itemPickerOptions = modelObject.getAvailableBlocksForItemPicker();
                expect(itemPickerOptions.length).toBe(1);
                expect(itemPickerOptions[0].alias).toBe(simpleBlockConfigurationMock.contentTypeAlias);
                done();
            });
            
        });


  });

});<commit_msg>another two tests<commit_after>﻿describe('blockEditorService tests', function () {

    var blockEditorService, contentResource;

    beforeEach(module('umbraco.services'));
    beforeEach(module('umbraco.resources'));
    beforeEach(module('umbraco.mocks'));
    
    beforeEach(inject(function ($injector, mocksUtils) {

        mocksUtils.disableAuth();

        contentResource = $injector.get("contentResource");
        spyOn(contentResource, "getScaffold").and.callFake(
            function () {
                return Promise.resolve(mocksUtils.getMockVariantContent(1234))
            }
        );

        blockEditorService = $injector.get('blockEditorService');

    }));


    var blockConfigurationMock = {contentTypeAlias: "testAlias", label:"Test label", settingsElementTypeAlias: null, view: "testview.html"};

    var propertyModelMock = {
        layout: {
            "Umbraco.TestBlockEditor": [
                {
                    udi: 1234
                }
            ]
        },
        data: [
            {
                udi: 1234,
                contentTypeAlias: "testAlias",
                testvalue: "myTestValue"
            }
        ]
    };

    describe('init blockEditoModelObject', function () {
        
        it('fail if no model value', function () {
            function createWithNoModelValue() {
                blockEditorService.createModelObject(null, "Umbraco.TestBlockEditor", []);
            }
            expect(createWithNoModelValue).toThrow();
        });

        it('return a object, with methods', function () {
            var modelObject = blockEditorService.createModelObject({}, "Umbraco.TestBlockEditor", []);

            expect(modelObject).not.toBeUndefined();
            expect(modelObject.loadScaffolding).not.toBeUndefined();
        });

        it('getBlockConfiguration provide the requested block configurtion', function () {
            var modelObject = blockEditorService.createModelObject({}, "Umbraco.TestBlockEditor", [blockConfigurationMock]);
            
            expect(modelObject.getBlockConfiguration(blockConfigurationMock.contentTypeAlias).label).toBe(blockConfigurationMock.label);
        });
        
        it('loadScaffolding provides data for itemPicker', function (done) {
            var modelObject = blockEditorService.createModelObject({}, "Umbraco.TestBlockEditor", [blockConfigurationMock]);
            
            modelObject.loadScaffolding().then(() => {
                var itemPickerOptions = modelObject.getAvailableBlocksForItemPicker();
                expect(itemPickerOptions.length).toBe(1);
                expect(itemPickerOptions[0].alias).toBe(blockConfigurationMock.contentTypeAlias);
                done();
            });
            
        });
        
        it('getLayoutEntry has right values', function (done) {

            
            var modelObject = blockEditorService.createModelObject(propertyModelMock, "Umbraco.TestBlockEditor", [blockConfigurationMock]);
            
            modelObject.loadScaffolding().then(() => {
                
                var layout = modelObject.getLayout();

                expect(layout).not.toBeUndefined();
                expect(layout.length).toBe(1);
                expect(layout[0]).toBe(propertyModelMock.layout["Umbraco.TestBlockEditor"][0]);
                expect(layout[0].udi).toBe(propertyModelMock.layout["Umbraco.TestBlockEditor"][0].udi);

                done();
            });
            
        });
        
        it('getBlockModel provide value', function (done) {

            
            var modelObject = blockEditorService.createModelObject(propertyModelMock, "Umbraco.TestBlockEditor", [blockConfigurationMock]);
            
            modelObject.loadScaffolding().then(() => {
                
                var layout = modelObject.getLayout();
                expect(layout).not.toBeUndefined();

                var blockModel = modelObject.getBlockModel(layout[0]);

                expect(blockModel).not.toBeUndefined();
                expect(blockModel[0].udi).toBe(propertyModelMock.data[0].udi);
                expect(blockModel[0].testvalue).toBe(propertyModelMock.data[0].testvalue);

                done();
            });
            
        });


  });

});
{'fraction_non_alphanumeric': 0.11685025305150343, 'fraction_numerical': 0.004465614766299494, 'mean_word_length': 2.3278850916295197, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 7, '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': '7490906', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1609, 'n_words': 238}