• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 16193550997

10 Jul 2025 11:12AM UTC coverage: 4.657% (-87.0%) from 91.64%
16193550997

Pull #16028

github

web-flow
Merge f7a9963b8 into 87246e3ce
Pull Request #16028: fix(radio-group): dynamically added radio buttons do not initialize

178 of 15764 branches covered (1.13%)

18 of 19 new or added lines in 2 files covered. (94.74%)

25721 existing lines in 324 files now uncovered.

1377 of 29570 relevant lines covered (4.66%)

0.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/projects/igniteui-angular/src/lib/services/csv/char-separated-value-data.ts
1
import { ExportUtilities } from '../exporter-common/export-utilities';
2
import { yieldingLoop } from '../../core/utils';
3
import { IColumnInfo } from '../exporter-common/base-export-service';
4

5
/**
6
 * @hidden
7
 */
8
export class CharSeparatedValueData {
UNCOV
9
    private _headerRecord = '';
×
UNCOV
10
    private _dataRecords = '';
×
UNCOV
11
    private _eor = '\r\n';
×
12
    private _delimiter;
UNCOV
13
    private _escapeCharacters = ['\r', '\n', '\r\n'];
×
UNCOV
14
    private _delimiterLength = 1;
×
UNCOV
15
    private _isSpecialData = false;
×
16

UNCOV
17
    constructor(private _data: any[], valueDelimiter: string, private columns: IColumnInfo[] = [])  {
×
UNCOV
18
        this.setDelimiter(valueDelimiter);
×
19
    }
20

21
    public prepareData(key?: any[]) {
UNCOV
22
        if (!this._data || this._data.length === 0) {
×
UNCOV
23
            return '';
×
24
        }
UNCOV
25
        let keys = [];
×
UNCOV
26
        if (key){
×
27
            keys = key;
×
28
        }else {
UNCOV
29
            keys = ExportUtilities.getKeysFromData(this._data);
×
30
        }
31

UNCOV
32
        if (keys.length === 0) {
×
33
            return '';
×
34
        }
35

UNCOV
36
        this._isSpecialData = ExportUtilities.isSpecialData(this._data[0]);
×
UNCOV
37
        this._escapeCharacters.push(this._delimiter);
×
38

UNCOV
39
        this._headerRecord = this.processHeaderRecord(keys, this._data.length);
×
UNCOV
40
        this._dataRecords = this.processDataRecords(this._data, keys);
×
41

UNCOV
42
        return this._headerRecord + this._dataRecords;
×
43
    }
44

45
    public prepareDataAsync(done: (result: string) => void) {
UNCOV
46
        const columns = this.columns?.filter(c => !c.skip)
×
UNCOV
47
                        .sort((a, b) => a.startIndex - b.startIndex)
×
UNCOV
48
                        .sort((a, b) => a.pinnedIndex - b.pinnedIndex);
×
UNCOV
49
        const keys = columns && columns.length ? columns.map(c => c.field) : ExportUtilities.getKeysFromData(this._data);
×
50

UNCOV
51
        this._isSpecialData = ExportUtilities.isSpecialData(this._data[0]);
×
UNCOV
52
        this._escapeCharacters.push(this._delimiter);
×
53

UNCOV
54
        const headers = columns && columns.length ?
×
55
                        /* When column groups are present, always use the field as it indicates the group the column belongs to.
56
                        * Otherwise, in PivotGrid scenarios we can end up with many duplicated column names without a hint what they represent.
57
                        */
UNCOV
58
                        columns.map(c => c.columnGroupParent ? c.field : c.header ?? c.field) :
×
59
                        keys;
60

UNCOV
61
        this._headerRecord = this.processHeaderRecord(headers, this._data.length);
×
UNCOV
62
        if (keys.length === 0 || ((!this._data || this._data.length === 0) && keys.length === 0)) {
×
UNCOV
63
            done('');
×
64
        } else {
UNCOV
65
            this.processDataRecordsAsync(this._data, keys, (dr) => {
×
UNCOV
66
                done(this._headerRecord + dr);
×
67
            });
68
        }
69
    }
70

71
    private processField(value, escapeChars): string {
UNCOV
72
        let safeValue = ExportUtilities.hasValue(value) ? String(value) : '';
×
UNCOV
73
        if (escapeChars.some((v) => safeValue.includes(v))) {
×
UNCOV
74
            safeValue = `"${safeValue}"`;
×
75
        }
UNCOV
76
        return safeValue + this._delimiter;
×
77
    }
78

79
    private processHeaderRecord(keys, dataLength): string {
UNCOV
80
        let recordData = '';
×
UNCOV
81
        for (const keyName of keys) {
×
UNCOV
82
            recordData += this.processField(keyName, this._escapeCharacters);
×
83
        }
84

UNCOV
85
        const result = recordData.slice(0, -this._delimiterLength);
×
86

UNCOV
87
        return dataLength > 0 ? result + this._eor : result;
×
88
    }
89

90
    private processRecord(record, keys): string {
UNCOV
91
        const recordData = new Array(keys.length);
×
UNCOV
92
        for (let index = 0; index < keys.length; index++) {
×
UNCOV
93
            const value = (record[keys[index]] !== undefined) ? record[keys[index]] : this._isSpecialData ? record : '';
×
UNCOV
94
            recordData[index] = this.processField(value, this._escapeCharacters);
×
95
        }
96

UNCOV
97
        return recordData.join('').slice(0, -this._delimiterLength) + this._eor;
×
98
    }
99

100
    private processDataRecords(currentData, keys) {
UNCOV
101
        const dataRecords = new Array(currentData.length);
×
102

UNCOV
103
        for (let i = 0; i < currentData.length; i++) {
×
UNCOV
104
            const row = currentData[i];
×
UNCOV
105
            dataRecords[i] = this.processRecord(row, keys);
×
106
        }
107

UNCOV
108
        return dataRecords.join('');
×
109
    }
110

111
    private processDataRecordsAsync(currentData, keys, done: (result: string) => void) {
UNCOV
112
        const dataRecords = new Array(currentData.length);
×
113

UNCOV
114
        yieldingLoop(currentData.length, 1000,
×
115
            (i) => {
UNCOV
116
                const row = currentData[i];
×
UNCOV
117
                dataRecords[i] = this.processRecord(row, keys);
×
118
            },
119
            () => {
UNCOV
120
                done(dataRecords.join(''));
×
121
            });
122
    }
123

124
    private setDelimiter(value) {
UNCOV
125
        this._delimiter = value;
×
UNCOV
126
        this._delimiterLength = value.length;
×
127
    }
128
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc