|
@@ -32,7 +32,7 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- filesData = new SourceCodeReader({}).readSourceCode(inputPath);
|
|
|
+ filesData = new SourceCodeReader(inputPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return valid files data', () => {
|
|
@@ -51,7 +51,7 @@ describe('SourceCodeReader', () => {
|
|
|
let testFunc: () => void;
|
|
|
|
|
|
before(() => {
|
|
|
- testFunc = () => new SourceCodeReader({}).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(inputPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` is not a valid path', () => {
|
|
@@ -67,7 +67,7 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- testFunc = () => new SourceCodeReader({}).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(inputPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` has invalid extension', () => {
|
|
@@ -92,9 +92,12 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- filesData = new SourceCodeReader({
|
|
|
- exclude: ['**/foo.js']
|
|
|
- }).readSourceCode(inputPath);
|
|
|
+ filesData = new SourceCodeReader(
|
|
|
+ inputPath,
|
|
|
+ {
|
|
|
+ exclude: ['**/foo.js']
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return valid files data', () => {
|
|
@@ -115,9 +118,12 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- testFunc = () => new SourceCodeReader({
|
|
|
- exclude: [`**/${tmpFileName}`]
|
|
|
- }).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(
|
|
|
+ inputPath,
|
|
|
+ {
|
|
|
+ exclude: [`**/${tmpFileName}`]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` is the excluded file path', () => {
|
|
@@ -137,9 +143,12 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- testFunc = () => new SourceCodeReader({
|
|
|
- exclude: [tmpFileName]
|
|
|
- }).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(
|
|
|
+ inputPath,
|
|
|
+ {
|
|
|
+ exclude: [tmpFileName]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` is the excluded file path', () => {
|
|
@@ -159,9 +168,12 @@ describe('SourceCodeReader', () => {
|
|
|
|
|
|
before(() => {
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- testFunc = () => new SourceCodeReader({
|
|
|
- exclude: [inputPath]
|
|
|
- }).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(
|
|
|
+ inputPath,
|
|
|
+ {
|
|
|
+ exclude: [inputPath]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` is the excluded file path', () => {
|
|
@@ -205,7 +217,7 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({}).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(tmpDirectoryPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -226,7 +238,7 @@ describe('SourceCodeReader', () => {
|
|
|
let testFunc: () => void;
|
|
|
|
|
|
before(() => {
|
|
|
- testFunc = () => new SourceCodeReader({}).readSourceCode(inputPath);
|
|
|
+ testFunc = () => new SourceCodeReader(inputPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should throw an error if `inputPath` is not a valid path', () => {
|
|
@@ -276,7 +288,7 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({}).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(tmpDirectoryPath, {}).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -322,9 +334,12 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({
|
|
|
- exclude: ['**/hawk.js']
|
|
|
- }).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(
|
|
|
+ tmpDirectoryPath,
|
|
|
+ {
|
|
|
+ exclude: ['**/hawk.js']
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -368,12 +383,15 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({
|
|
|
- exclude: [
|
|
|
- `**/${tmpFileName2}`,
|
|
|
- `**/${tmpFileName4}`
|
|
|
- ]
|
|
|
- }).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(
|
|
|
+ tmpDirectoryPath,
|
|
|
+ {
|
|
|
+ exclude: [
|
|
|
+ `**/${tmpFileName2}`,
|
|
|
+ `**/${tmpFileName4}`
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -416,12 +434,15 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({
|
|
|
- exclude: [
|
|
|
- tmpFileName2,
|
|
|
- tmpFileName4
|
|
|
- ]
|
|
|
- }).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(
|
|
|
+ tmpDirectoryPath,
|
|
|
+ {
|
|
|
+ exclude: [
|
|
|
+ tmpFileName2,
|
|
|
+ tmpFileName4
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -464,12 +485,15 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- result = new SourceCodeReader({
|
|
|
- exclude: [
|
|
|
- filePath2,
|
|
|
- filePath4
|
|
|
- ]
|
|
|
- }).readSourceCode(tmpDirectoryPath);
|
|
|
+ result = new SourceCodeReader(
|
|
|
+ tmpDirectoryPath,
|
|
|
+ {
|
|
|
+ exclude: [
|
|
|
+ filePath2,
|
|
|
+ filePath4
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -501,9 +525,12 @@ describe('SourceCodeReader', () => {
|
|
|
fs.writeFileSync(filePath2, fileContent);
|
|
|
fs.writeFileSync(filePath3, fileContent);
|
|
|
fs.writeFileSync(filePath4, fileContent);
|
|
|
- testFunc = () => new SourceCodeReader({
|
|
|
- exclude: [tmpDirectoryPath]
|
|
|
- }).readSourceCode(tmpDirectoryPath);
|
|
|
+ testFunc = () => new SourceCodeReader(
|
|
|
+ tmpDirectoryPath,
|
|
|
+ {
|
|
|
+ exclude: [tmpDirectoryPath]
|
|
|
+ }
|
|
|
+ ).readSourceCode();
|
|
|
});
|
|
|
|
|
|
it('should return files data', () => {
|
|
@@ -535,7 +562,7 @@ describe('SourceCodeReader', () => {
|
|
|
consoleLogSpy = sinon.spy(console, 'log');
|
|
|
|
|
|
fs.writeFileSync(inputPath, fileContent);
|
|
|
- new SourceCodeReader({}).readSourceCode(inputPath);
|
|
|
+ new SourceCodeReader(inputPath, {}).readSourceCode();
|
|
|
|
|
|
consoleLogCallResult = consoleLogSpy.called;
|
|
|
loggingMessageResult = consoleLogSpy.getCall(0).args[0];
|