diff --git a/tests/__snapshots__/api.spec.ts.snap b/tests/__snapshots__/api.spec.ts.snap index 823d71f8..5e2efab9 100644 --- a/tests/__snapshots__/api.spec.ts.snap +++ b/tests/__snapshots__/api.spec.ts.snap @@ -5,81 +5,248 @@ Object { "2": Array [ Object { "cols": Array [ - 8, - 27, + 39, + 53, ], "fingerprints": Array [ Object { - "fingerprint": "f8e3391465a47f6586489cffd1f44ae47a1c4885c722de596d6eb931fe43bb16", + "fingerprint": "369aebd49780d3608e1ed3c48a88b50d531409e64105fa20b0e9b751f066f87b", "version": 0, }, + Object { + "fingerprint": "19689298.883ce888.fa1beb9c.44ab356c.f81b5a8d.f7edcf51.0d475b83.41ec51de.19689298.601f8825.fa1beb9c.de031890.f81b5a8d.ce109560.0d475b83.41ec51de", + "version": 1, + }, + ], + "markers": Array [ + Object { + "msg": Array [ + 16, + 21, + ], + "pos": Array [ + Object { + "cols": Array [ + 40, + 57, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 10, + 10, + ], + }, + ], + }, + Object { + "msg": Array [ + 36, + 62, + ], + "pos": Array [ + Object { + "cols": Array [ + 39, + 53, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 15, + 15, + ], + }, + ], + }, ], - "markers": Array [], "rows": Array [ - 5, - 5, + 15, + 15, ], }, ], "3": Array [ Object { "cols": Array [ - 6, - 25, + 42, + 54, ], "fingerprints": Array [ Object { - "fingerprint": "3e40a81739245db8fff4903a7e28e08bffa03486a677e7c91594cfdf15fb5a1d", + "fingerprint": "e7c159b1f0c8449a86abb7a07127d4f593e958f6a3912221ba564e18d8f7e43b", "version": 0, }, Object { - "fingerprint": "57664a44.2c254dac.98501263.9e345555.da547a36.9509b717.a713c1c8.45d76bdf.57664a44.2c254dac.98501263.9e345555.da547a36.9509b717.a713c1c8.45d76bdf", + "fingerprint": "a75b04d3.0b7f48d1.7a59bef1.44ab356c.a698423b.f7edcf51.c23c997b.41ec51de.a75b04d3.0b7f48d1.3c7d90aa.de031890.8b2d3351.ce109560.c23c997b.41ec51de", "version": 1, }, ], "markers": Array [ Object { "msg": Array [ - 25, - 36, + 16, + 21, ], "pos": Array [ Object { "cols": Array [ - 7, - 14, + 34, + 51, ], - "file": "/AnnotatorTest.cpp", + "file": "/GitHubAccessTokenScrambler12.java", "rows": Array [ - 8, - 8, + 11, + 11, ], }, ], }, Object { "msg": Array [ + 36, 45, - 57, ], "pos": Array [ Object { "cols": Array [ - 6, - 25, + 42, + 54, ], - "file": "/AnnotatorTest.cpp", + "file": "/GitHubAccessTokenScrambler12.java", "rows": Array [ - 10, - 10, + 16, + 16, + ], + }, + ], + }, + ], + "rows": Array [ + 16, + 16, + ], + }, + ], + "4": Array [ + Object { + "cols": Array [ + 37, + 47, + ], + "fingerprints": Array [ + Object { + "fingerprint": "b964e2b3c7ac4c5b425b9419abe756f566b7efcc16786e8036d44e33f109d545", + "version": 0, + }, + Object { + "fingerprint": "19689298.883ce888.fdf08d99.d7919eeb.74c2d841.f7edcf51.5721ebe2.54d46e25.19689298.883ce888.fdf08d99.d7919eeb.74c2d841.f7edcf51.5721ebe2.54d46e25", + "version": 1, + }, + ], + "markers": Array [ + Object { + "msg": Array [ + 4, + 6, + ], + "pos": Array [ + Object { + "cols": Array [ + 49, + 70, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 18, + 18, + ], + }, + ], + }, + Object { + "msg": Array [ + 21, + 51, + ], + "pos": Array [ + Object { + "cols": Array [ + 37, + 47, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 18, + 18, + ], + }, + ], + }, + ], + "rows": Array [ + 18, + 18, + ], + }, + ], + "5": Array [ + Object { + "cols": Array [ + 14, + 15, + ], + "fingerprints": Array [ + Object { + "fingerprint": "5af7ed14642e35fa42e5dcbec421163e53f6f8a9b540f1950c0cc520000d85e4", + "version": 0, + }, + Object { + "fingerprint": "c2e08f55.e9fd9d38.d1699128.f482feb1.a485742e.730a5695.62adb608.e9000d02.c2e08f55.ef94efde.cd271e66.e22980a8.d31a8364.730a5695.bae646e8.54d46e25", + "version": 1, + }, + ], + "markers": Array [ + Object { + "msg": Array [ + 28, + 46, + ], + "pos": Array [ + Object { + "cols": Array [ + 19, + 27, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 23, + 23, + ], + }, + ], + }, + Object { + "msg": Array [ + 80, + 94, + ], + "pos": Array [ + Object { + "cols": Array [ + 17, + 31, + ], + "file": "/GitHubAccessTokenScrambler12.java", + "rows": Array [ + 24, + 24, ], }, ], }, ], "rows": Array [ - 10, - 10, + 24, + 24, ], }, ], diff --git a/tests/analysis.spec.ts b/tests/analysis.spec.ts index 3601ac31..29a3be0b 100644 --- a/tests/analysis.spec.ts +++ b/tests/analysis.spec.ts @@ -32,7 +32,7 @@ describe('Functional test of analysis', () => { const onCreateBundleProgress = jest.fn((processed: number, total: number) => { expect(typeof processed).toBe('number'); - expect(total).toEqual(3); + expect(total).toEqual(2); expect(processed).toBeLessThanOrEqual(total); }); @@ -51,7 +51,6 @@ describe('Functional test of analysis', () => { }); emitter.on(emitter.events.apiRequestLog, onAPIRequestLog); - const bundle = await analyzeFolders({ baseURL, sessionToken, @@ -65,24 +64,16 @@ describe('Functional test of analysis', () => { expect(bundle).toHaveProperty('sessionToken'); expect(bundle).toHaveProperty('supportedFiles'); expect(bundle).toHaveProperty('analysisURL'); - expect(Object.keys(bundle.analysisResults.files).length).toEqual(4); - expect(bundle.analysisResults.files.hasOwnProperty(`${sampleProjectPath}/AnnotatorTest.cpp`)).toBeTruthy(); - expect(Object.keys(bundle.analysisResults.suggestions).length).toEqual(8); + expect(Object.keys(bundle.analysisResults.files).length).toEqual(3); + expect( + bundle.analysisResults.files.hasOwnProperty(`${sampleProjectPath}/GitHubAccessTokenScrambler12.java`), + ).toBeTruthy(); + expect(Object.keys(bundle.analysisResults.suggestions).length).toEqual(6); expect(bundle.analysisResults.timing.analysis).toBeGreaterThanOrEqual(bundle.analysisResults.timing.fetchingCode); expect(bundle.analysisResults.timing.queue).toBeGreaterThanOrEqual(0); expect(new Set(bundle.analysisResults.coverage)).toEqual( new Set([ - { - files: 1, - isSupported: true, - lang: 'C++ (beta)', - }, - { - files: 1, - isSupported: false, - lang: 'JSON', - }, { files: 1, isSupported: true, @@ -98,8 +89,8 @@ describe('Functional test of analysis', () => { // Check if emitter event happened expect(onSupportedFilesLoaded).toHaveBeenCalledTimes(2); - expect(onScanFilesProgress).toHaveBeenCalledTimes(8); - expect(onCreateBundleProgress).toHaveBeenCalledTimes(4); + expect(onScanFilesProgress).toHaveBeenCalledTimes(6); + expect(onCreateBundleProgress).toHaveBeenCalledTimes(3); expect(onAnalyseProgress).toHaveBeenCalled(); expect(onAPIRequestLog).toHaveBeenCalled(); diff --git a/tests/api.spec.ts b/tests/api.spec.ts index 0754bf95..00515d63 100644 --- a/tests/api.spec.ts +++ b/tests/api.spec.ts @@ -16,9 +16,9 @@ import { reportEvent, } from '../src/http'; -const fakeBundleId = '646c61854ef8ef5634d9caf2580352bc416b3d066f800832b47088d4169cf231'; +const fakeBundleId = '79925ce5d4dbfcb9f7f90f671bfcbdaebf394b3c91b49eb4d2b57f109d2abcc6'; let fakeBundleIdFull = ''; -const realBundleId = 'e03ac612f79b73ef6f55bdd3e32d324fb43dc138f9883bbb41085a6db59d67f5'; +const realBundleId = '39bc8dbc1e4fd197323fe352231ff3afad2cd2ea191b4abeb3613340c8752ea0'; let realBundleIdFull = ''; const reportTelemetryRequest = { @@ -40,46 +40,9 @@ describe('Requests to public API', () => { const response = await getFilters(baseURL, ''); expect(response.type).toEqual('success'); if (response.type === 'error') return; - expect(new Set(response.value.configFiles)).toEqual( - new Set([ - '.dcignore', - '.gitignore', - '.pylintrc', - 'pylintrc', - '.pmdrc.xml', - '.ruleset.xml', - 'ruleset.xml', - 'tslint.json', - '.eslintrc.js', - '.eslintrc.json', - '.eslintrc.yml', - ]), - ); + expect(new Set(response.value.configFiles)).toEqual(new Set(['.dcignore', '.gitignore'])); expect(new Set(response.value.extensions)).toEqual( - new Set([ - '.es', - '.es6', - '.htm', - '.html', - '.js', - '.jsx', - '.ts', - '.tsx', - '.vue', - '.c', - '.cc', - '.cpp', - '.cxx', - '.h', - '.hpp', - '.hxx', - '.py', - '.java', - '.CS', - '.Cs', - '.cs', - '.php', - ]), + new Set(['.es', '.es6', '.htm', '.html', '.js', '.jsx', '.ts', '.tsx', '.vue', '.java']), ); }); @@ -145,8 +108,6 @@ describe('Requests to public API', () => { expect(response.value.bundleId).toContain(fakeBundleId); fakeBundleIdFull = response.value.bundleId; expect(response.value.missingFiles).toEqual([ - '/.eslintrc.json', - `/AnnotatorTest.cpp`, `/GitHubAccessTokenScrambler12.java`, `/app.js`, `/db.js`, @@ -170,8 +131,6 @@ describe('Requests to public API', () => { if (response.type === 'error') return; expect(response.value.bundleId).toEqual(fakeBundleIdFull); expect(response.value.missingFiles).toEqual([ - '/.eslintrc.json', - `/AnnotatorTest.cpp`, `/GitHubAccessTokenScrambler12.java`, `/app.js`, `/db.js`, @@ -236,9 +195,7 @@ describe('Requests to public API', () => { [`/new.js`]: 'new123', }, removedFiles: [ - '/.eslintrc.json', `/app.js`, - `/AnnotatorTest.cpp`, `/GitHubAccessTokenScrambler12.java`, `/db.js`, `/main.js`, @@ -367,7 +324,7 @@ describe('Requests to public API', () => { if (response.value.status === AnalysisStatus.done) { expect(response.value.analysisURL.includes(realBundleIdFull)).toBeTruthy(); - expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(8); + expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(6); const suggestion = response.value.analysisResults.suggestions[0]; expect(Object.keys(suggestion)).toEqual([ 'id', @@ -403,26 +360,15 @@ describe('Requests to public API', () => { expect(suggestion.severity).toEqual(2); expect(suggestion.tags).toEqual(['maintenance', 'express', 'server', 'helmet']); - expect(Object.keys(response.value.analysisResults.files).length).toEqual(4); - const filePath = `/AnnotatorTest.cpp`; - expect(response.value.analysisResults.files[filePath]).toMatchSnapshot(); - + expect(Object.keys(response.value.analysisResults.files).length).toEqual(3); expect(response.value.analysisResults.timing.analysis).toBeGreaterThanOrEqual( response.value.analysisResults.timing.fetchingCode, ); + const filePath = `/GitHubAccessTokenScrambler12.java`; + expect(response.value.analysisResults.files[filePath]).toMatchSnapshot(); expect(response.value.analysisResults.timing.queue).toBeGreaterThanOrEqual(0); expect(new Set(response.value.analysisResults.coverage)).toEqual( new Set([ - { - files: 1, - isSupported: true, - lang: 'C++ (beta)', - }, - { - files: 1, - isSupported: false, - lang: 'JSON', - }, { files: 1, isSupported: true, @@ -445,7 +391,7 @@ describe('Requests to public API', () => { bundleId: realBundleIdFull, includeLint: false, severity: 1, - limitToFiles: [`/AnnotatorTest.cpp`], + limitToFiles: [`/GitHubAccessTokenScrambler12.java`], source: 'atom', }); @@ -454,8 +400,8 @@ describe('Requests to public API', () => { expect(response.value.status !== AnalysisStatus.failed).toBeTruthy(); } while (response.value.status !== AnalysisStatus.done); - expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(2); - expect(Object.keys(response.value.analysisResults.files)).toEqual(['/AnnotatorTest.cpp']); + expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(4); + expect(Object.keys(response.value.analysisResults.files)).toEqual(['/GitHubAccessTokenScrambler12.java']); // Get analysis results without linters but with severity 3 do {