@@ -6,22 +6,73 @@ import nock from 'nock';
66import { STORE_KEYS } from '../lib/constants/store' ;
77import { API } from '../lib/constants/api' ;
88
9- const mockProjectPath = path . resolve ( __dirname , 'mocked_data' ) ;
9+ const root = __dirname ;
10+ const mockProjectPath = path . resolve ( root , 'mocked_data' ) ;
11+ const analysedFile = `${ mockProjectPath } /sample_repository/main.js` ;
12+ const bundleID = 'gh/deepcode/DEEPCODE_PRIVATE_BUNDLE/ee0745667800961b0f35d6a4cb4fb12f72373d641e75e464f6632813102afcf1' ;
13+
14+ export const mockBundle = {
15+ files : {
16+ [ analysedFile ] : '3e2979852cc2e97f48f7e7973a8b0837eb73ed0485c868176bc3aa58c499f534' ,
17+ [ `${ mockProjectPath } /sample_repository/sub_folder/test2.js` ] : 'c8bc645260a7d1a0d1349a72150cb65fa005188142dca30d09c3cc67c7974923' ,
18+ [ `${ mockProjectPath } /sample_repository/utf8.js` ] : 'cc2b67993e547813db67f57c6b20bff83bf4ade64ea2c3fb468d927425502804' ,
19+ [ `${ mockProjectPath } /test.java` ] : '09f4ca64118f029e5a894305dfc329c930ebd2a258052de9e81f895b055ec929' ,
20+ }
21+ }
22+
23+ export const mockAnalysisResults = {
24+ files : {
25+ [ analysedFile ] : { '0' : [ { rows : [ 1 , 2 ] , cols : [ 3 , 4 ] , markers : [ ] } ] } ,
26+ } ,
27+ suggestions : {
28+ '0' : {
29+ id : 'TestSuggestion' ,
30+ message : 'some message' ,
31+ severity : 1 ,
32+ }
33+ } ,
34+ } ;
35+
36+ export const mockAnalysisTable = [
37+ {
38+ fileName : '/home/incode/WIP/DeepCode/atom-plugin/spec/mocked_data/sample_repository/main.js' ,
39+ localPath : '/home/incode/WIP/DeepCode/atom-plugin/spec/mocked_data/sample_repository/main.js' ,
40+ localName : 'main.js' ,
41+ message : 'some message' ,
42+ position : '[1, 3]' ,
43+ severity : 1 ,
44+ startRow : 1 ,
45+ startCol : 3 ,
46+ endRow : 2 ,
47+ endCol : 4 ,
48+ markers : [ ] ,
49+ suggestionID : 'TestSuggestion' ,
50+ suggestionIndex : '0' ,
51+ suggestionData : {
52+ rows : [ 1 , 2 ] ,
53+ cols :[ 3 , 4 ] ,
54+ markers : [ ] ,
55+ } ,
56+ } ,
57+ ] ;
1058
1159export const mockState = {
1260 // shared
1361 [ STORE_KEYS . accountType ] : 'free' ,
1462 [ STORE_KEYS . sessionToken ] : '444641e35f09d515e366e88ffc0e5929ef42263505d3424184e94040ca7401bc' ,
15- [ STORE_KEYS . serviceURL ] : 'http://localhost:3000/ ' ,
63+ [ STORE_KEYS . serviceURL ] : 'http://localhost:3000' ,
1664
1765 // project
1866 [ STORE_KEYS . confirmedFolders ] : [ mockProjectPath ] ,
1967 [ STORE_KEYS . allowedFiles ] : {
20- extensions : [ " .java" , " .html" , " .js" , " .jsx" , " .ts" , " .tsx" , " .vue" , " .py" ] ,
21- configFiles : [ " .pmdrc.xml" , " .ruleset.xml" , " ruleset.xml" , " .eslintrc.js" , " .eslintrc.json" , " .eslintrc.yml" , " tslint.json" , " .pylintrc" , " pylintrc" ] ,
68+ extensions : [ ' .java' , ' .html' , ' .js' , ' .jsx' , ' .ts' , ' .tsx' , ' .vue' , ' .py' ] ,
69+ configFiles : [ ' .pmdrc.xml' , ' .ruleset.xml' , ' ruleset.xml' , ' .eslintrc.js' , ' .eslintrc.json' , ' .eslintrc.yml' , ' tslint.json' , ' .pylintrc' , ' pylintrc' ] ,
2270 } ,
23- [ STORE_KEYS . bundleID ] : 'gh/deepcode/DEEPCODE_PRIVATE_BUNDLE/ee0745667800961b0f35d6a4cb4fb12f72373d641e75e464f6632813102afcf1' ,
71+ [ STORE_KEYS . bundleID ] : bundleID ,
2472 [ STORE_KEYS . firstStart ] : false ,
73+
74+ // runtime
75+ [ STORE_KEYS . testEnvironment ] : true ,
2576} ;
2677
2778export const startMockServer = ( ) => {
@@ -36,4 +87,19 @@ export const startMockServer = () => {
3687 } ) ;
3788
3889 mockedServer . get ( API . filters ) . reply ( 200 , mockState [ STORE_KEYS . allowedFiles ] ) ;
90+ mockedServer . post ( API . createBundle ) . reply ( 200 , {
91+ statusCode : 200 ,
92+ bundleId : bundleID ,
93+ } ) ;
94+ mockedServer . post ( `${ API . createBundle } /${ bundleID } ` ) . reply ( 200 , {
95+ statusCode : 200 ,
96+ bundleId : bundleID ,
97+ } ) ;
98+ mockedServer . get ( `${ API . analysis ( bundleID ) } ` ) . reply ( 200 , {
99+ statusCode : 200 ,
100+ status : 'DONE' ,
101+ progress : 1.0 ,
102+ analysisResults : mockAnalysisResults ,
103+ analysisURL : 'test_analysis_url'
104+ } ) ;
39105} ;
0 commit comments