test(dev-infra): remove chai from ts-api-guardian tests (#41503)
Refactor ts-api-guardian tests to use jasmine instead of chai PR Close #41503
This commit is contained in:
parent
aa755c8853
commit
8b9d025b13
|
@ -81,7 +81,6 @@
|
||||||
"@types/babel__traverse": "^7.0.9",
|
"@types/babel__traverse": "^7.0.9",
|
||||||
"@types/base64-js": "1.2.5",
|
"@types/base64-js": "1.2.5",
|
||||||
"@types/bluebird": "^3.5.27",
|
"@types/bluebird": "^3.5.27",
|
||||||
"@types/chai": "^4.1.2",
|
|
||||||
"@types/convert-source-map": "^1.5.1",
|
"@types/convert-source-map": "^1.5.1",
|
||||||
"@types/diff": "^3.5.1",
|
"@types/diff": "^3.5.1",
|
||||||
"@types/events": "3.0.0",
|
"@types/events": "3.0.0",
|
||||||
|
@ -113,7 +112,6 @@
|
||||||
"bluebird": "^3.7.2",
|
"bluebird": "^3.7.2",
|
||||||
"brotli": "^1.3.2",
|
"brotli": "^1.3.2",
|
||||||
"canonical-path": "1.0.0",
|
"canonical-path": "1.0.0",
|
||||||
"chai": "4.2.0",
|
|
||||||
"chalk": "^2.3.1",
|
"chalk": "^2.3.1",
|
||||||
"chokidar": "^3.5.1",
|
"chokidar": "^3.5.1",
|
||||||
"convert-source-map": "^1.5.1",
|
"convert-source-map": "^1.5.1",
|
||||||
|
|
|
@ -61,10 +61,8 @@ ts_library(
|
||||||
tsconfig = "//tools:tsconfig-test",
|
tsconfig = "//tools:tsconfig-test",
|
||||||
deps = [
|
deps = [
|
||||||
":lib",
|
":lib",
|
||||||
"@npm//@types/chai",
|
|
||||||
"@npm//@types/jasmine",
|
"@npm//@types/jasmine",
|
||||||
"@npm//@types/node",
|
"@npm//@types/node",
|
||||||
"@npm//chai",
|
|
||||||
"@npm//jasmine",
|
"@npm//jasmine",
|
||||||
"@npm//typescript",
|
"@npm//typescript",
|
||||||
],
|
],
|
||||||
|
|
|
@ -204,7 +204,7 @@ class ResolvedDeclarationEmitter {
|
||||||
}
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Symbol "${resolvedSymbol.name}" was aliased as "${s.name}". ` +
|
`Symbol "${resolvedSymbol.name}" was aliased as "${s.name}". ` +
|
||||||
`Aliases are not supported."`);
|
`Aliases are not supported.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolvedSymbol;
|
return resolvedSymbol;
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
"minimist": "^1.2.0"
|
"minimist": "^1.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "^4.1.2",
|
|
||||||
"@types/diff": "^3.5.1",
|
"@types/diff": "^3.5.1",
|
||||||
"@types/jasmine": "^2.8.8",
|
"@types/jasmine": "^2.8.8",
|
||||||
"@types/minimist": "^1.2.0",
|
"@types/minimist": "^1.2.0",
|
||||||
"@types/node": "^10.9.4",
|
"@types/node": "^10.9.4",
|
||||||
"chai": "^4.1.2",
|
|
||||||
"jasmine": "^3.1.0",
|
"jasmine": "^3.1.0",
|
||||||
"source-map-support": "^0.5.9",
|
"source-map-support": "^0.5.9",
|
||||||
"typescript": "4.2.3"
|
"typescript": "4.2.3"
|
||||||
|
|
|
@ -6,11 +6,10 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chai = require('chai');
|
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {assertFileEqual, unlinkRecursively} from './helpers';
|
import {assertFileEqual} from './helpers';
|
||||||
|
|
||||||
const BINARY_PATH = require.resolve('../ts-api-guardian/bin/ts-api-guardian');
|
const BINARY_PATH = require.resolve('../ts-api-guardian/bin/ts-api-guardian');
|
||||||
|
|
||||||
|
@ -24,38 +23,38 @@ describe('cli: e2e test', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
unlinkRecursively(outDir);
|
fs.rmdirSync(outDir, {recursive: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should print usage without any argument', () => {
|
it('should print usage without any argument', () => {
|
||||||
const {stderr} = execute([]);
|
const {stderr} = execute([]);
|
||||||
chai.assert.match(stderr, /Usage/);
|
expect(stderr).toMatch(/Usage/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show help message with --help', () => {
|
it('should show help message with --help', () => {
|
||||||
const {stdout} = execute(['--help']);
|
const {stdout} = execute(['--help']);
|
||||||
chai.assert.match(stdout, /Usage/);
|
expect(stdout).toMatch(/Usage/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate golden file with --out', () => {
|
it('should generate golden file with --out', () => {
|
||||||
const simpleFile = path.join(outDir, 'simple.d.ts');
|
const simpleFile = path.join(outDir, 'simple.d.ts');
|
||||||
const {status, stderr} = execute(['--out', simpleFile, 'test/fixtures/simple.d.ts']);
|
const {status, stderr} = execute(['--out', simpleFile, 'test/fixtures/simple.d.ts']);
|
||||||
chai.assert.equal(status, 0, stderr);
|
expect(status).toBe(0, stderr);
|
||||||
assertFileEqual(simpleFile, 'test/fixtures/simple_expected.d.ts');
|
assertFileEqual(simpleFile, 'test/fixtures/simple_expected.d.ts');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should verify golden file with --verify and exit cleanly on no difference', () => {
|
it('should verify golden file with --verify and exit cleanly on no difference', () => {
|
||||||
const {stdout, status} =
|
const {stdout, status} =
|
||||||
execute(['--verify', 'test/fixtures/simple_expected.d.ts', 'test/fixtures/simple.d.ts']);
|
execute(['--verify', 'test/fixtures/simple_expected.d.ts', 'test/fixtures/simple.d.ts']);
|
||||||
chai.assert.equal(stdout, '');
|
expect(stdout).toBe('');
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should verify golden file with --verify and exit with error on difference', () => {
|
it('should verify golden file with --verify and exit with error on difference', () => {
|
||||||
const {stdout, status} = execute(
|
const {stdout, status} = execute(
|
||||||
['--verify', 'test/fixtures/verify_expected.d.ts', 'test/fixtures/verify_entrypoint.d.ts']);
|
['--verify', 'test/fixtures/verify_expected.d.ts', 'test/fixtures/verify_entrypoint.d.ts']);
|
||||||
chai.assert.equal(stdout, fs.readFileSync('test/fixtures/verify.patch').toString());
|
expect(stdout).toBe(fs.readFileSync('test/fixtures/verify.patch').toString());
|
||||||
chai.assert.equal(status, 1);
|
expect(status).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate multiple golden files with --outDir and --rootDir', () => {
|
it('should generate multiple golden files with --outDir and --rootDir', () => {
|
||||||
|
@ -63,7 +62,7 @@ describe('cli: e2e test', () => {
|
||||||
'--outDir', outDir, '--rootDir', 'test/fixtures', 'test/fixtures/simple.d.ts',
|
'--outDir', outDir, '--rootDir', 'test/fixtures', 'test/fixtures/simple.d.ts',
|
||||||
'test/fixtures/sorting.d.ts'
|
'test/fixtures/sorting.d.ts'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
assertFileEqual(path.join(outDir, 'simple.d.ts'), 'test/fixtures/simple_expected.d.ts');
|
assertFileEqual(path.join(outDir, 'simple.d.ts'), 'test/fixtures/simple_expected.d.ts');
|
||||||
assertFileEqual(path.join(outDir, 'sorting.d.ts'), 'test/fixtures/sorting_expected.d.ts');
|
assertFileEqual(path.join(outDir, 'sorting.d.ts'), 'test/fixtures/sorting_expected.d.ts');
|
||||||
});
|
});
|
||||||
|
@ -75,8 +74,8 @@ describe('cli: e2e test', () => {
|
||||||
'--verifyDir', outDir, '--rootDir', 'test/fixtures', 'test/fixtures/simple.d.ts',
|
'--verifyDir', outDir, '--rootDir', 'test/fixtures', 'test/fixtures/simple.d.ts',
|
||||||
'test/fixtures/sorting.d.ts'
|
'test/fixtures/sorting.d.ts'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(stdout, '');
|
expect(stdout).toBe('');
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should generate respecting --stripExportPattern', () => {
|
it('should generate respecting --stripExportPattern', () => {
|
||||||
|
@ -84,7 +83,8 @@ describe('cli: e2e test', () => {
|
||||||
'--out', path.join(outDir, 'underscored.d.ts'), '--stripExportPattern', '^__.*',
|
'--out', path.join(outDir, 'underscored.d.ts'), '--stripExportPattern', '^__.*',
|
||||||
'test/fixtures/underscored.d.ts'
|
'test/fixtures/underscored.d.ts'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(status, 0);
|
|
||||||
|
expect(status).toBe(0);
|
||||||
assertFileEqual(
|
assertFileEqual(
|
||||||
path.join(outDir, 'underscored.d.ts'), 'test/fixtures/underscored_expected.d.ts');
|
path.join(outDir, 'underscored.d.ts'), 'test/fixtures/underscored_expected.d.ts');
|
||||||
});
|
});
|
||||||
|
@ -94,7 +94,7 @@ describe('cli: e2e test', () => {
|
||||||
'--out', path.join(outDir, 'stripped_alias.d.ts'), '--stripExportPattern', '^__.*',
|
'--out', path.join(outDir, 'stripped_alias.d.ts'), '--stripExportPattern', '^__.*',
|
||||||
'test/fixtures/stripped_alias.d.ts'
|
'test/fixtures/stripped_alias.d.ts'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
assertFileEqual(
|
assertFileEqual(
|
||||||
path.join(outDir, 'stripped_alias.d.ts'), 'test/fixtures/stripped_alias_expected.d.ts');
|
path.join(outDir, 'stripped_alias.d.ts'), 'test/fixtures/stripped_alias_expected.d.ts');
|
||||||
});
|
});
|
||||||
|
@ -104,8 +104,8 @@ describe('cli: e2e test', () => {
|
||||||
'--verify', 'test/fixtures/underscored_expected.d.ts', 'test/fixtures/underscored.d.ts',
|
'--verify', 'test/fixtures/underscored_expected.d.ts', 'test/fixtures/underscored.d.ts',
|
||||||
'--stripExportPattern', '^__.*'
|
'--stripExportPattern', '^__.*'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(stdout, '');
|
expect(stdout).toBe('');
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should respect --allowModuleIdentifiers', () => {
|
it('should respect --allowModuleIdentifiers', () => {
|
||||||
|
@ -113,8 +113,8 @@ describe('cli: e2e test', () => {
|
||||||
'--verify', 'test/fixtures/module_identifier_expected.d.ts', '--allowModuleIdentifiers',
|
'--verify', 'test/fixtures/module_identifier_expected.d.ts', '--allowModuleIdentifiers',
|
||||||
'foo', 'test/fixtures/module_identifier.d.ts'
|
'foo', 'test/fixtures/module_identifier.d.ts'
|
||||||
]);
|
]);
|
||||||
chai.assert.equal(stdout, '');
|
expect(stdout).toBe('');
|
||||||
chai.assert.equal(status, 0);
|
expect(status).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -136,8 +136,9 @@ function execute(args: string[]): {stdout: string, stderr: string, status: numbe
|
||||||
'NODE_PATH': nodePath,
|
'NODE_PATH': nodePath,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
chai.assert(!output.error, 'Child process failed or timed out: ' + output.error);
|
|
||||||
chai.assert(!output.signal, `Child process killed by signal ${output.signal}`);
|
expect(output.error).toBeFalsy(`Child process failed or timed out: ${output.error}`);
|
||||||
|
expect(output.signal).toBeFalsy(`Child process killed by signal ${output.signal}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stdout: output.stdout.toString(),
|
stdout: output.stdout.toString(),
|
||||||
|
|
|
@ -6,78 +6,76 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import chai = require('chai');
|
|
||||||
import {parseArguments} from '../lib/cli';
|
import {parseArguments} from '../lib/cli';
|
||||||
|
|
||||||
describe('cli: parseArguments', () => {
|
describe('cli: parseArguments', () => {
|
||||||
it('should show usage with error when supplied with no arguments', () => {
|
it('should show usage with error when supplied with no arguments', () => {
|
||||||
const {mode, errors} = parseArguments([]);
|
const {mode, errors} = parseArguments([]);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, ['No input file specified.']);
|
expect(errors).toEqual(['No input file specified.']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage without error when supplied with --help', () => {
|
it('should show usage without error when supplied with --help', () => {
|
||||||
const {mode, errors} = parseArguments(['--help']);
|
const {mode, errors} = parseArguments(['--help']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, []);
|
expect(errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied with none of --out/verify[Dir]', () => {
|
it('should show usage with error when supplied with none of --out/verify[Dir]', () => {
|
||||||
const {mode, errors} = parseArguments(['input.d.ts']);
|
const {mode, errors} = parseArguments(['input.d.ts']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, ['Specify either --out[Dir] or --verify[Dir]']);
|
expect(errors).toEqual(['Specify either --out[Dir] or --verify[Dir]']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied with both of --out/verify[Dir]', () => {
|
it('should show usage with error when supplied with both of --out/verify[Dir]', () => {
|
||||||
const {mode, errors} =
|
const {mode, errors} =
|
||||||
parseArguments(['--out', 'out.d.ts', '--verifyDir', 'golden.d.ts', 'input.d.ts']);
|
parseArguments(['--out', 'out.d.ts', '--verifyDir', 'golden.d.ts', 'input.d.ts']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, ['Specify either --out[Dir] or --verify[Dir]']);
|
expect(errors).toEqual(['Specify either --out[Dir] or --verify[Dir]']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied without input file', () => {
|
it('should show usage with error when supplied without input file', () => {
|
||||||
const {mode, errors} = parseArguments(['--out', 'output.d.ts']);
|
const {mode, errors} = parseArguments(['--out', 'output.d.ts']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, ['No input file specified.']);
|
expect(errors).toEqual(['No input file specified.']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied without input file', () => {
|
it('should show usage with error when supplied without input file', () => {
|
||||||
const {mode, errors} = parseArguments(['--out', 'output.d.ts', 'first.d.ts', 'second.d.ts']);
|
const {mode, errors} = parseArguments(['--out', 'output.d.ts', 'first.d.ts', 'second.d.ts']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(errors, ['More than one input specified. Use --outDir instead.']);
|
expect(errors).toEqual(['More than one input specified. Use --outDir instead.']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use out mode when supplied with --out', () => {
|
it('should use out mode when supplied with --out', () => {
|
||||||
const {argv, mode, errors} = parseArguments(['--out', 'out.d.ts', 'input.d.ts']);
|
const {argv, mode, errors} = parseArguments(['--out', 'out.d.ts', 'input.d.ts']);
|
||||||
chai.assert.equal(argv['out'], 'out.d.ts');
|
expect(argv['out']).toBe('out.d.ts');
|
||||||
chai.assert.deepEqual(argv._, ['input.d.ts']);
|
expect(argv._).toEqual(['input.d.ts']);
|
||||||
chai.assert.equal(mode, 'out');
|
expect(mode).toBe('out');
|
||||||
chai.assert.deepEqual(errors, []);
|
expect(errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use verify mode when supplied with --verify', () => {
|
it('should use verify mode when supplied with --verify', () => {
|
||||||
const {argv, mode, errors} = parseArguments(['--verify', 'out.d.ts', 'input.d.ts']);
|
const {argv, mode, errors} = parseArguments(['--verify', 'out.d.ts', 'input.d.ts']);
|
||||||
chai.assert.equal(argv['verify'], 'out.d.ts');
|
expect(argv['verify']).toBe('out.d.ts');
|
||||||
chai.assert.deepEqual(argv._, ['input.d.ts']);
|
expect(argv._).toEqual(['input.d.ts']);
|
||||||
chai.assert.equal(mode, 'verify');
|
expect(mode).toBe('verify');
|
||||||
chai.assert.deepEqual(errors, []);
|
expect(errors).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied with --autoDiscoverEntrypoints without --baseDir',
|
it('should show usage with error when supplied with --autoDiscoverEntrypoints without --baseDir',
|
||||||
() => {
|
() => {
|
||||||
const {mode, errors} =
|
const {mode, errors} =
|
||||||
parseArguments(['--autoDiscoverEntrypoints', '--outDir', 'something']);
|
parseArguments(['--autoDiscoverEntrypoints', '--outDir', 'something']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(
|
expect(errors).toEqual(['--rootDir must be provided with --autoDiscoverEntrypoints.']);
|
||||||
errors, ['--rootDir must be provided with --autoDiscoverEntrypoints.']);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show usage with error when supplied with --autoDiscoverEntrypoints without --outDir/verifyDir',
|
it('should show usage with error when supplied with --autoDiscoverEntrypoints without --outDir/verifyDir',
|
||||||
() => {
|
() => {
|
||||||
const {mode, errors} =
|
const {mode, errors} =
|
||||||
parseArguments(['--autoDiscoverEntrypoints', '--rootDir', 'something']);
|
parseArguments(['--autoDiscoverEntrypoints', '--rootDir', 'something']);
|
||||||
chai.assert.equal(mode, 'help');
|
expect(mode).toBe('help');
|
||||||
chai.assert.deepEqual(
|
expect(errors).toEqual(
|
||||||
errors, ['--outDir or --verifyDir must be used with --autoDiscoverEntrypoints.']);
|
['--outDir or --verifyDir must be used with --autoDiscoverEntrypoints.']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,22 +6,8 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as chai from 'chai';
|
import {readFileSync} from 'fs';
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export function unlinkRecursively(file: string) {
|
|
||||||
if (fs.statSync(file).isDirectory()) {
|
|
||||||
for (const f of fs.readdirSync(file)) {
|
|
||||||
unlinkRecursively(path.join(file, f));
|
|
||||||
}
|
|
||||||
fs.rmdirSync(file);
|
|
||||||
} else {
|
|
||||||
fs.unlinkSync(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function assertFileEqual(actualFile: string, expectedFile: string) {
|
export function assertFileEqual(actualFile: string, expectedFile: string) {
|
||||||
chai.assert.equal(
|
expect(readFileSync(actualFile).toString()).toBe(readFileSync(expectedFile).toString());
|
||||||
fs.readFileSync(actualFile).toString(), fs.readFileSync(expectedFile).toString());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as main from '../lib/main';
|
import * as main from '../lib/main';
|
||||||
import {assertFileEqual, unlinkRecursively} from './helpers';
|
|
||||||
|
import {assertFileEqual} from './helpers';
|
||||||
|
|
||||||
describe('integration test: public api', () => {
|
describe('integration test: public api', () => {
|
||||||
let _warn: any = null;
|
let _warn: any = null;
|
||||||
|
@ -61,7 +62,7 @@ describe('integration test: public api', () => {
|
||||||
|
|
||||||
it('should remove reexported external symbols', () => {
|
it('should remove reexported external symbols', () => {
|
||||||
check('test/fixtures/reexported_extern.d.ts', 'test/fixtures/reexported_extern_expected.d.ts');
|
check('test/fixtures/reexported_extern.d.ts', 'test/fixtures/reexported_extern_expected.d.ts');
|
||||||
chai.assert.deepEqual(warnings, [
|
expect(warnings).toEqual([
|
||||||
'test/fixtures/reexported_extern.d.ts(5,1): error: No export declaration found for symbol "CompilerHost"'
|
'test/fixtures/reexported_extern.d.ts(5,1): error: No export declaration found for symbol "CompilerHost"'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -75,9 +76,8 @@ describe('integration test: public api', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw on passing a .ts file as an input', () => {
|
it('should throw on passing a .ts file as an input', () => {
|
||||||
chai.assert.throws(() => {
|
expect(() => main.publicApi('test/fixtures/empty.ts'))
|
||||||
main.publicApi('test/fixtures/empty.ts');
|
.toThrowError('Source file "test/fixtures/empty.ts" is not a declaration file');
|
||||||
}, 'Source file "test/fixtures/empty.ts" is not a declaration file');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should respect serialization options', () => {
|
it('should respect serialization options', () => {
|
||||||
|
@ -99,7 +99,7 @@ describe('integration test: generateGoldenFile', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
unlinkRecursively(outDir);
|
fs.rmdirSync(outDir, {recursive: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,23 +129,23 @@ describe('integration test: verifyAgainstGoldenFile', () => {
|
||||||
it('should check an entrypoint against a golden file on equal', () => {
|
it('should check an entrypoint against a golden file on equal', () => {
|
||||||
const diff = main.verifyAgainstGoldenFile(
|
const diff = main.verifyAgainstGoldenFile(
|
||||||
'test/fixtures/reexported_classes.d.ts', 'test/fixtures/reexported_classes_expected.d.ts');
|
'test/fixtures/reexported_classes.d.ts', 'test/fixtures/reexported_classes_expected.d.ts');
|
||||||
chai.assert.equal(diff, '');
|
expect(diff).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check an entrypoint against a golden file with proper diff message', () => {
|
it('should check an entrypoint against a golden file with proper diff message', () => {
|
||||||
const diff = main.verifyAgainstGoldenFile(
|
const diff = main.verifyAgainstGoldenFile(
|
||||||
'test/fixtures/verify_entrypoint.d.ts', 'test/fixtures/verify_expected.d.ts');
|
'test/fixtures/verify_entrypoint.d.ts', 'test/fixtures/verify_expected.d.ts');
|
||||||
chai.assert.equal(diff, fs.readFileSync('test/fixtures/verify.patch').toString());
|
expect(diff).toBe(fs.readFileSync('test/fixtures/verify.patch').toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should respect serialization options', () => {
|
it('should respect serialization options', () => {
|
||||||
const diff = main.verifyAgainstGoldenFile(
|
const diff = main.verifyAgainstGoldenFile(
|
||||||
'test/fixtures/underscored.d.ts', 'test/fixtures/underscored_expected.d.ts',
|
'test/fixtures/underscored.d.ts', 'test/fixtures/underscored_expected.d.ts',
|
||||||
{stripExportPattern: /^__.*/});
|
{stripExportPattern: /^__.*/});
|
||||||
chai.assert.equal(diff, '');
|
expect(diff).toBe('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function check(sourceFile: string, expectedFile: string, options: main.SerializationOptions = {}) {
|
function check(sourceFile: string, expectedFile: string, options: main.SerializationOptions = {}) {
|
||||||
chai.assert.equal(main.publicApi(sourceFile, options), fs.readFileSync(expectedFile).toString());
|
expect(main.publicApi(sourceFile, options)).toBe(fs.readFileSync(expectedFile).toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* found in the LICENSE file at https://angular.io/license
|
* found in the LICENSE file at https://angular.io/license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as chai from 'chai';
|
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
|
||||||
import {publicApiInternal, SerializationOptions} from '../lib/serializer';
|
import {publicApiInternal, SerializationOptions} from '../lib/serializer';
|
||||||
|
@ -125,8 +124,8 @@ describe('unit test', () => {
|
||||||
const expected = `
|
const expected = `
|
||||||
`;
|
`;
|
||||||
check({'classes_and_interfaces.d.ts': classesAndInterfaces, 'file.d.ts': input}, expected);
|
check({'classes_and_interfaces.d.ts': classesAndInterfaces, 'file.d.ts': input}, expected);
|
||||||
chai.assert.deepEqual(
|
expect(warnings).toEqual(
|
||||||
warnings, ['file.d.ts(1,1): error: No export declaration found for symbol "Foo"']);
|
['file.d.ts(1,1): error: No export declaration found for symbol "Foo"']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should sort exports', () => {
|
it('should sort exports', () => {
|
||||||
|
@ -634,14 +633,12 @@ function getMockHost(files: {[name: string]: string}): ts.CompilerHost {
|
||||||
function check(
|
function check(
|
||||||
files: {[name: string]: string}, expected: string, options: SerializationOptions = {}) {
|
files: {[name: string]: string}, expected: string, options: SerializationOptions = {}) {
|
||||||
const actual = publicApiInternal(getMockHost(files), 'file.d.ts', {}, options);
|
const actual = publicApiInternal(getMockHost(files), 'file.d.ts', {}, options);
|
||||||
chai.assert.equal(actual.trim(), stripExtraIndentation(expected).trim());
|
expect(actual.trim()).toBe(stripExtraIndentation(expected).trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkThrows(
|
function checkThrows(
|
||||||
files: {[name: string]: string}, error: string, options: SerializationOptions = {}) {
|
files: {[name: string]: string}, error: string, options: SerializationOptions = {}) {
|
||||||
chai.assert.throws(() => {
|
expect(() => publicApiInternal(getMockHost(files), 'file.d.ts', {}, options)).toThrowError(error);
|
||||||
publicApiInternal(getMockHost(files), 'file.d.ts', {}, options);
|
|
||||||
}, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function stripExtraIndentation(text: string) {
|
function stripExtraIndentation(text: string) {
|
||||||
|
|
66
yarn.lock
66
yarn.lock
|
@ -2550,11 +2550,6 @@
|
||||||
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.33.tgz#d79c020f283bd50bd76101d7d300313c107325fc"
|
resolved "https://registry.yarnpkg.com/@types/bluebird/-/bluebird-3.5.33.tgz#d79c020f283bd50bd76101d7d300313c107325fc"
|
||||||
integrity sha512-ndEo1xvnYeHxm7I/5sF6tBvnsA4Tdi3zj1keRKRs12SP+2ye2A27NDJ1B6PqkfMbGAcT+mqQVqbZRIrhfOp5PQ==
|
integrity sha512-ndEo1xvnYeHxm7I/5sF6tBvnsA4Tdi3zj1keRKRs12SP+2ye2A27NDJ1B6PqkfMbGAcT+mqQVqbZRIrhfOp5PQ==
|
||||||
|
|
||||||
"@types/chai@^4.1.2":
|
|
||||||
version "4.2.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.11.tgz#d3614d6c5f500142358e6ed24e1bf16657536c50"
|
|
||||||
integrity sha512-t7uW6eFafjO+qJ3BIV2gGUyZs27egcNRkUdalkud+Qa3+kg//f129iuOFivHDXQ+vnU3fDXuwgv0cqMCbcE8sw==
|
|
||||||
|
|
||||||
"@types/cli-progress@^3.4.2":
|
"@types/cli-progress@^3.4.2":
|
||||||
version "3.4.2"
|
version "3.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/@types/cli-progress/-/cli-progress-3.4.2.tgz#03dfa3d507e9dda85ba4a14006c37e8b7094c605"
|
resolved "https://registry.yarnpkg.com/@types/cli-progress/-/cli-progress-3.4.2.tgz#03dfa3d507e9dda85ba4a14006c37e8b7094c605"
|
||||||
|
@ -3610,11 +3605,6 @@ assert@^1.1.1:
|
||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
util "0.10.3"
|
util "0.10.3"
|
||||||
|
|
||||||
assertion-error@^1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
|
|
||||||
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
|
|
||||||
|
|
||||||
assign-symbols@^1.0.0:
|
assign-symbols@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
||||||
|
@ -4469,30 +4459,6 @@ caseless@~0.12.0:
|
||||||
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
|
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
|
||||||
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
|
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
|
||||||
|
|
||||||
chai@4.2.0:
|
|
||||||
version "4.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5"
|
|
||||||
integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==
|
|
||||||
dependencies:
|
|
||||||
assertion-error "^1.1.0"
|
|
||||||
check-error "^1.0.2"
|
|
||||||
deep-eql "^3.0.1"
|
|
||||||
get-func-name "^2.0.0"
|
|
||||||
pathval "^1.1.0"
|
|
||||||
type-detect "^4.0.5"
|
|
||||||
|
|
||||||
chai@^4.1.2:
|
|
||||||
version "4.3.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49"
|
|
||||||
integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==
|
|
||||||
dependencies:
|
|
||||||
assertion-error "^1.1.0"
|
|
||||||
check-error "^1.0.2"
|
|
||||||
deep-eql "^3.0.1"
|
|
||||||
get-func-name "^2.0.0"
|
|
||||||
pathval "^1.1.1"
|
|
||||||
type-detect "^4.0.5"
|
|
||||||
|
|
||||||
"chainsaw@>=0.0.7 <0.1":
|
"chainsaw@>=0.0.7 <0.1":
|
||||||
version "0.0.9"
|
version "0.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.0.9.tgz#11a05102d1c4c785b6d0415d336d5a3a1612913e"
|
resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.0.9.tgz#11a05102d1c4c785b6d0415d336d5a3a1612913e"
|
||||||
|
@ -4553,11 +4519,6 @@ chardet@^0.7.0:
|
||||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
|
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
|
||||||
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
|
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
|
||||||
|
|
||||||
check-error@^1.0.2:
|
|
||||||
version "1.0.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
|
||||||
integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=
|
|
||||||
|
|
||||||
check-side-effects@0.0.23:
|
check-side-effects@0.0.23:
|
||||||
version "0.0.23"
|
version "0.0.23"
|
||||||
resolved "https://registry.yarnpkg.com/check-side-effects/-/check-side-effects-0.0.23.tgz#0daa99d6c26be01467483f3ae0bdb3c4b22d59b2"
|
resolved "https://registry.yarnpkg.com/check-side-effects/-/check-side-effects-0.0.23.tgz#0daa99d6c26be01467483f3ae0bdb3c4b22d59b2"
|
||||||
|
@ -6036,13 +5997,6 @@ decomment@^0.9.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
esprima "4.0.1"
|
esprima "4.0.1"
|
||||||
|
|
||||||
deep-eql@^3.0.1:
|
|
||||||
version "3.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
|
|
||||||
integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==
|
|
||||||
dependencies:
|
|
||||||
type-detect "^4.0.0"
|
|
||||||
|
|
||||||
deep-equal@^1.0.1:
|
deep-equal@^1.0.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
|
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
|
||||||
|
@ -7708,11 +7662,6 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5:
|
||||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||||
|
|
||||||
get-func-name@^2.0.0:
|
|
||||||
version "2.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
|
|
||||||
integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=
|
|
||||||
|
|
||||||
get-intrinsic@^1.0.2:
|
get-intrinsic@^1.0.2:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6"
|
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6"
|
||||||
|
@ -12151,16 +12100,6 @@ path-type@^4.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||||
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||||
|
|
||||||
pathval@^1.1.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"
|
|
||||||
integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA=
|
|
||||||
|
|
||||||
pathval@^1.1.1:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d"
|
|
||||||
integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==
|
|
||||||
|
|
||||||
pause-stream@0.0.11:
|
pause-stream@0.0.11:
|
||||||
version "0.0.11"
|
version "0.0.11"
|
||||||
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
|
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
|
||||||
|
@ -15549,11 +15488,6 @@ type-check@~0.3.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
prelude-ls "~1.1.2"
|
prelude-ls "~1.1.2"
|
||||||
|
|
||||||
type-detect@^4.0.0, type-detect@^4.0.5:
|
|
||||||
version "4.0.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
|
|
||||||
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
|
|
||||||
|
|
||||||
type-fest@^0.11.0:
|
type-fest@^0.11.0:
|
||||||
version "0.11.0"
|
version "0.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1"
|
||||||
|
|
Loading…
Reference in New Issue