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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM CUT coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

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

75.0
/projects/igniteui-angular/src/lib/services/csv/csv-exporter-options.ts
1
import { IgxExporterOptionsBase } from '../exporter-common/exporter-options-base';
2

3
/**
4
 * Objects of this class are used to configure the CSV exporting process.
5
 */
6
export class IgxCsvExporterOptions extends IgxExporterOptionsBase {
7

8
    private _valueDelimiter;
9
    private _fileType;
10

11
    constructor(fileName: string, fileType: CsvFileTypes) {
12
        super(fileName, IgxCsvExporterOptions.getExtensionFromFileType(fileType));
6✔
13
        this.setFileType(fileType);
6✔
14
        this.setDelimiter();
6✔
15
    }
16

17
    private static getExtensionFromFileType(fType: CsvFileTypes) {
18
        let extension = '';
12✔
19
        switch (fType) {
12!
20
            case CsvFileTypes.CSV:
21
                extension = '.csv';
4✔
22
                break;
4✔
23
            case CsvFileTypes.TSV:
24
                extension = '.tsv';
4✔
25
                break;
4✔
26
            case CsvFileTypes.TAB:
27
                extension = '.tab';
4✔
28
                break;
4✔
29
            default:
30
                throw Error('Unsupported CSV file type!');
×
31
        }
32
        return extension;
12✔
33
    }
34

35
    /**
36
     * Gets the value delimiter which will be used for the exporting operation.
37
     * ```typescript
38
     * let delimiter = this.exportOptions.valueDelimiter;
39
     * ```
40
     *
41
     * @memberof IgxCsvExporterOptions
42
     */
43
    public get valueDelimiter() {
UNCOV
44
        return this._valueDelimiter;
×
45
    }
46

47
    /**
48
     * Sets a value delimiter which will overwrite the default delimiter of the selected export format.
49
     * ```typescript
50
     * this.exportOptions.valueDelimiter = '|';
51
     * ```
52
     *
53
     * @memberof IgxCsvExporterOptions
54
     */
55
    public set valueDelimiter(value) {
UNCOV
56
        this.setDelimiter(value);
×
57
    }
58

59
    /**
60
     * Gets the CSV export format.
61
     * ```typescript
62
     * let filetype = this.exportOptions.fileType;
63
     * ```
64
     *
65
     * @memberof IgxCsvExporterOptions
66
     */
67
    public get fileType() {
68
        return this._fileType;
6✔
69
    }
70

71
    /**
72
     * Sets the CSV export format.
73
     * ```typescript
74
     * this.exportOptions.fileType = CsvFileTypes.TAB;
75
     * ```
76
     *
77
     * @memberof IgxCsvExporterOptions
78
     */
79
    public set fileType(value) {
UNCOV
80
        this.setFileType(value);
×
81
    }
82

83
    private setFileType(value) {
84
        if (value !== undefined && value !== null && value !== this._fileType) {
6✔
85
            this._fileType = value;
6✔
86
            const extension = IgxCsvExporterOptions.getExtensionFromFileType(value);
6✔
87
            if (!this.fileName.endsWith(extension)) {
6!
UNCOV
88
                const oldExt = '.' + this.fileName.split('.').pop();
×
UNCOV
89
                const newName = this.fileName.replace(oldExt, extension);
×
UNCOV
90
                this._fileExtension = extension;
×
UNCOV
91
                this.fileName = newName;
×
92
            }
93
        }
94
    }
95

96
    private setDelimiter(value?) {
97
        if (value !== undefined && value !== '' && value !== null) {
6!
UNCOV
98
            this._valueDelimiter = value;
×
99
        } else {
100
            switch (this.fileType) {
6✔
101
                case CsvFileTypes.CSV:
102
                    this._valueDelimiter = ',';
2✔
103
                    break;
2✔
104
                case CsvFileTypes.TSV:
105
                case CsvFileTypes.TAB:
106
                    this._valueDelimiter = '\t';
4✔
107
                    break;
4✔
108
            }
109
        }
110
    }
111
}
112

113
/**
114
 * This enumeration is used to configure the default value separator
115
 * as well as the default file extension used when performing CSV exporting.
116
 */
117
export enum CsvFileTypes {
2✔
118
    /**
119
     * Character Separated Values, default separator is "comma", default file extension is .csv
120
     */
121
    CSV,
2✔
122
    /**
123
     * Tab Separated Values, default separator is tab, default file extension is .tsv
124
     */
125
    TSV,
2✔
126
    /**
127
     * Tab Separated Values, default separator is tab, default file extension is .tab
128
     */
129
    TAB
2✔
130
}
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

© 2025 Coveralls, Inc