<commit_before>import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { configureTestSuite } from '../../test-utils/configure-suite';
import {
    IgxTreeGridSelectionKeyComponent,
    IgxTreeGridSelectionComponent,
    IgxTreeGridSelectionWithTransactionComponent,
    IgxTreeGridFKeySelectionWithTransactionComponent
} from '../../test-utils/tree-grid-components.spec';
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
import { IgxTreeGridModule } from './tree-grid.module';
import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
import { GridSelectionFunctions, GridSummaryFunctions, GridFunctions } from '../../test-utils/grid-functions.spec';
import { GridSelectionMode } from '../common/enums';

describe('IgxTreeGrid - Multi Cell selection #tGrid', () => {
    configureTestSuite();

    beforeAll(waitForAsync(() => {
        TestBed.configureTestingModule({
            declarations: [
                IgxTreeGridSelectionKeyComponent,
                IgxTreeGridSelectionComponent,
                IgxTreeGridSelectionWithTransactionComponent,
                IgxTreeGridFKeySelectionWithTransactionComponent
            ],
            imports: [NoopAnimationsModule, IgxTreeGridModule]
        }).compileComponents();
    }));

    describe('Flat Data', () => {
        let fix;
        let treeGrid;
        let detect;

        beforeEach(fakeAsync(/** height/width setter rAF */() => {
            fix = TestBed.createComponent(IgxTreeGridSelectionKeyComponent);
            fix.detectChanges();
            treeGrid = fix.componentInstance.treeGrid;
            setupGridScrollDetection(fix, treeGrid);
            detect = () => treeGrid.cdr.detectChanges();
        }));

        it('Should select a region', () => {
            verifySelectingRegion(fix, treeGrid);
        });

        it('Should return correct data when expand and collapse rows', () => {
            verifySelectingExpandCollapse(fix, treeGrid);
        });

        it('Should be able to select a range with mouse dragging', () => {
            verifySelectingRangeWithMouseDrag(fix, treeGrid, detect);
        });

        it('Should not be possible to select a range when change cellSelection to none', () => {
            const rangeChangeSpy = spyOn<any>(treeGrid.onRangeSelection, 'emit').and.callThrough();
            const startCell = treeGrid.getCellByColumn(0, 'ID');
            const endCell = treeGrid.getCellByColumn(2, 'ID');

            expect(treeGrid.cellSelection).toEqual(GridSelectionMode.multiple);
            GridSelectionFunctions.selectCellsRangeNoWait(fix, startCell, endCell);
            detect();

            expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0);
            GridSelectionFunctions.verifySelectedRange(treeGrid, 0, 2, 0, 0);

            treeGrid.cellSelection = GridSelectionMode.none;
            fix.detectChanges();

            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0, false);
            expect(treeGrid.getSelectedData()).toEqual([]);
            expect(treeGrid.getSelectedRanges()).toEqual([]);

            // Try to select a range
            GridSelectionFunctions.selectCellsRangeNoWait(fix, endCell, startCell);
            detect();
            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0, false);
            expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
            expect(treeGrid.selectedCells.length).toBe(0);
            expect(treeGrid.getSelectedData()).toEqual([]);
            expect(treeGrid.getSelectedRanges()).toEqual([]);
        });

        it('Should not be possible to select a range when change cellSelection to single', () => {<commit_msg>chore(*): change tgrid test expect<commit_after>import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { configureTestSuite } from '../../test-utils/configure-suite';
import {
    IgxTreeGridSelectionKeyComponent,
    IgxTreeGridSelectionComponent,
    IgxTreeGridSelectionWithTransactionComponent,
    IgxTreeGridFKeySelectionWithTransactionComponent
} from '../../test-utils/tree-grid-components.spec';
import { IgxStringFilteringOperand } from '../../data-operations/filtering-condition';
import { IgxTreeGridModule } from './tree-grid.module';
import { setupGridScrollDetection } from '../../test-utils/helper-utils.spec';
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
import { GridSelectionFunctions, GridSummaryFunctions, GridFunctions } from '../../test-utils/grid-functions.spec';
import { GridSelectionMode } from '../common/enums';

describe('IgxTreeGrid - Multi Cell selection #tGrid', () => {
    configureTestSuite();

    beforeAll(waitForAsync(() => {
        TestBed.configureTestingModule({
            declarations: [
                IgxTreeGridSelectionKeyComponent,
                IgxTreeGridSelectionComponent,
                IgxTreeGridSelectionWithTransactionComponent,
                IgxTreeGridFKeySelectionWithTransactionComponent
            ],
            imports: [NoopAnimationsModule, IgxTreeGridModule]
        }).compileComponents();
    }));

    describe('Flat Data', () => {
        let fix;
        let treeGrid;
        let detect;

        beforeEach(fakeAsync(/** height/width setter rAF */() => {
            fix = TestBed.createComponent(IgxTreeGridSelectionKeyComponent);
            fix.detectChanges();
            treeGrid = fix.componentInstance.treeGrid;
            setupGridScrollDetection(fix, treeGrid);
            detect = () => treeGrid.cdr.detectChanges();
        }));

        it('Should select a region', () => {
            verifySelectingRegion(fix, treeGrid);
        });

        it('Should return correct data when expand and collapse rows', () => {
            verifySelectingExpandCollapse(fix, treeGrid);
        });

        it('Should be able to select a range with mouse dragging', () => {
            verifySelectingRangeWithMouseDrag(fix, treeGrid, detect);
        });

        it('Should not be possible to select a range when change cellSelection to none', () => {
            const rangeChangeSpy = spyOn<any>(treeGrid.onRangeSelection, 'emit').and.callThrough();
            const startCell = treeGrid.getCellByColumn(0, 'ID');
            const endCell = treeGrid.getCellByColumn(2, 'ID');

            expect(treeGrid.cellSelection).toEqual(GridSelectionMode.multiple);
            GridSelectionFunctions.selectCellsRangeNoWait(fix, startCell, endCell);
            detect();

            expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0);
            GridSelectionFunctions.verifySelectedRange(treeGrid, 0, 2, 0, 0);

            treeGrid.cellSelection = GridSelectionMode.none;
            fix.detectChanges();

            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0, false);
            expect(treeGrid.getSelectedData()).toEqual([]);
            expect(treeGrid.getSelectedRanges()).toEqual([]);

            // Try to select a range
            GridSelectionFunctions.selectCellsRangeNoWait(fix, endCell, startCell);
            detect();
            GridSelectionFunctions.verifyCellsRegionSelected(treeGrid, 0, 2, 0, 0, false);
            expect(rangeChangeSpy).toHaveBeenCalledTimes(1);
            expect(treeGrid.selectedCells.length).toBe(0);
            expect(treeGrid.getSelectedData().length).toBe(1);
            expect(treeGrid.getSelectedRanges()).toEqual([]);
        });

        it('Should not be possible to select a range when change cellSelection to single', () => {
{'fraction_non_alphanumeric': 0.11780104712041885, 'fraction_numerical': 0.005360259286960858, 'mean_word_length': 2.9405697445972496, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '3232947', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2032, 'n_words': 406}