保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var path_1 = require("path");
var util_1 = require("util");
var tsconfig = require("./tsconfig");
var TEST_DIR = path_1.join(__dirname, '../tests');
describe('tsconfig', function () {
    var tests = [
        {
            args: [TEST_DIR, 'invalidfile'],
            error: parseInt(process.versions.node, 10) > 5 ? 'Unexpected token s in JSON at position 0' : 'Unexpected token s'
        },
        {
            args: [TEST_DIR, 'missing'],
            error: 'Cannot find a tsconfig.json file at the specified directory: missing'
        },
        {
            args: [TEST_DIR, 'missing/foobar'],
            error: 'The specified path does not exist: missing/foobar'
        },
        {
            args: ['/'],
            config: {
                files: [],
                compilerOptions: {}
            }
        },
        {
            args: [TEST_DIR, 'empty'],
            config: {},
            path: path_1.join(TEST_DIR, 'empty/tsconfig.json')
        },
        {
            args: [TEST_DIR, 'empty/tsconfig.json'],
            config: {},
            path: path_1.join(TEST_DIR, 'empty/tsconfig.json')
        },
        {
            args: [path_1.join(TEST_DIR, 'find/up/config')],
            config: {},
            path: path_1.join(TEST_DIR, 'find/tsconfig.json')
        },
        {
            args: [TEST_DIR, 'valid'],
            config: {
                compilerOptions: {
                    module: 'commonjs',
                    noImplicitAny: true,
                    outDir: 'dist',
                    removeComments: true,
                    sourceMap: true,
                    preserveConstEnums: true
                },
                files: [
                    './src/foo.ts'
                ]
            },
            path: path_1.join(TEST_DIR, 'valid/tsconfig.json')
        },
        {
            args: [TEST_DIR, 'bom'],
            config: {
                compilerOptions: {
                    module: 'commonjs',
                    noImplicitAny: true,
                    outDir: 'dist',
                    removeComments: true,
                    sourceMap: true,
                    preserveConstEnums: true
                },
                files: [
                    './src/bom.ts'
                ]
            },
            path: path_1.join(TEST_DIR, 'bom/tsconfig.json')
        },
        {
            args: [path_1.join(TEST_DIR, 'cwd')],
            config: {
                compilerOptions: {
                    module: 'commonjs',
                    noImplicitAny: true,
                    outDir: 'dist',
                    removeComments: true,
                    sourceMap: true,
                    preserveConstEnums: true
                }
            },
            path: path_1.join(TEST_DIR, 'cwd/tsconfig.json')
        }
    ];
    describe('sync', function () {
        tests.forEach(function (test) {
            describe(util_1.inspect(test.args), function () {
                it('should try to find config', function () {
                    var result;
                    try {
                        result = tsconfig.loadSync(test.args[0], test.args[1]);
                    }
                    catch (err) {
                        chai_1.expect(err.message).to.equal(test.error);
                        return;
                    }
                    chai_1.expect(result.path).to.equal(test.path);
                    chai_1.expect(result.config).to.deep.equal(test.config);
                });
                if (test.path) {
                    it('should resolve filename', function () {
                        chai_1.expect(tsconfig.resolveSync(test.args[0], test.args[1])).to.equal(test.path);
                    });
                }
            });
        });
    });
    describe('async', function () {
        tests.forEach(function (test) {
            describe(util_1.inspect(test.args), function () {
                it('should try to find config', function () {
                    return tsconfig.load(test.args[0], test.args[1])
                        .then(function (result) {
                        chai_1.expect(result.path).to.equal(test.path);
                        chai_1.expect(result.config).to.deep.equal(test.config);
                    }, function (error) {
                        chai_1.expect(error.message).to.equal(test.error);
                    });
                });
                if (test.path) {
                    it('should resolve filename', function () {
                        return tsconfig.resolve(test.args[0], test.args[1])
                            .then(function (filename) {
                            chai_1.expect(filename).to.equal(test.path);
                        });
                    });
                }
            });
        });
    });
});
//# sourceMappingURL=tsconfig.spec.js.map