@@ -15,6 +15,7 @@ import {
1515
1616import readFixture from "./helpers/readFixture" ;
1717const {
18+ getSource,
1819 getSymbols,
1920 getEmptyLines,
2021 getOutOfScopeLocations,
@@ -27,38 +28,31 @@ import I from "immutable";
2728import { prefs } from "../../utils/prefs" ;
2829
2930const threadClient = {
30- sourceContents : function ( sourceId ) {
31- return new Promise ( ( resolve , reject ) =>
32- resolve ( {
33- source : sourceTexts [ sourceId ] ,
34- contentType : "text/javascript"
35- } )
36- ) ;
37- } ,
31+ sourceContents : async sourceId => ( {
32+ source : sourceTexts [ sourceId ] ,
33+ contentType : "text/javascript"
34+ } ) ,
3835 setPausePoints : async ( ) => { } ,
3936 getFrameScopes : async ( ) => { } ,
40- evaluate : function ( expression ) {
41- return new Promise ( ( resolve , reject ) =>
42- resolve ( { result : evaluationResult [ expression ] } )
43- ) ;
44- } ,
45- evaluateExpressions : function ( expressions ) {
46- return new Promise ( ( resolve , reject ) =>
47- resolve (
48- expressions . map ( expression => ( {
49- result : evaluationResult [ expression ]
50- } ) )
51- )
52- ) ;
53- }
37+ evaluate : async expression => ( { result : evaluationResult [ expression ] } ) ,
38+ evaluateExpressions : async expressions =>
39+ expressions . map ( expression => ( { result : evaluationResult [ expression ] } ) )
40+ } ;
41+
42+ const sourceMaps = {
43+ getOriginalSourceText : async ( { id } ) => ( {
44+ id,
45+ text : sourceTexts [ id ] ,
46+ contentType : "text/javascript"
47+ } )
5448} ;
5549
5650const sourceTexts = {
5751 "base.js" : "function base(boo) {}" ,
5852 "foo.js" : "function base(boo) { return this.bazz; } outOfScope" ,
5953 "scopes.js" : readFixture ( "scopes.js" ) ,
60- "reactComponent.js-original " : readFixture ( "reactComponent.js" ) ,
61- "reactFuncComponent.js-original " : readFixture ( "reactFuncComponent.js" )
54+ "reactComponent.js/originalSource " : readFixture ( "reactComponent.js" ) ,
55+ "reactFuncComponent.js/originalSource " : readFixture ( "reactFuncComponent.js" )
6256} ;
6357
6458const evaluationResult = {
@@ -87,13 +81,15 @@ describe("ast", () => {
8781
8882 describe ( "setSourceMetaData" , ( ) => {
8983 it ( "should detect react components" , async ( ) => {
90- const store = createStore ( threadClient ) ;
84+ const store = createStore ( threadClient , { } , sourceMaps ) ;
9185 const { dispatch, getState } = store ;
9286 const source = makeOriginalSource ( "reactComponent.js" ) ;
9387
88+ await dispatch ( actions . newSource ( makeSource ( "reactComponent.js" ) ) ) ;
89+
9490 await dispatch ( actions . newSource ( source ) ) ;
9591
96- await dispatch ( actions . loadSourceText ( I . Map ( { id : source . id } ) ) ) ;
92+ await dispatch ( actions . loadSourceText ( getSource ( getState ( ) , source . id ) ) ) ;
9793 await dispatch ( actions . setSourceMetaData ( source . id ) ) ;
9894
9995 await waitForState ( store , state => {
@@ -116,25 +112,6 @@ describe("ast", () => {
116112 const sourceMetaData = getSourceMetaData ( getState ( ) , base . id ) ;
117113 expect ( sourceMetaData . framework ) . toBe ( undefined ) ;
118114 } ) ;
119-
120- it ( "should detect react func components" , async ( ) => {
121- const store = createStore ( threadClient ) ;
122- const { dispatch, getState } = store ;
123- const source = makeOriginalSource ( "reactFuncComponent.js" ) ;
124-
125- await dispatch ( actions . newSource ( source ) ) ;
126-
127- await dispatch ( actions . loadSourceText ( I . Map ( { id : source . id } ) ) ) ;
128- await dispatch ( actions . setSourceMetaData ( source . id ) ) ;
129-
130- await waitForState ( store , state => {
131- const metaData = getSourceMetaData ( state , source . id ) ;
132- return metaData && metaData . framework ;
133- } ) ;
134-
135- const sourceMetaData = getSourceMetaData ( getState ( ) , source . id ) ;
136- expect ( sourceMetaData . framework ) . toBe ( "React" ) ;
137- } ) ;
138115 } ) ;
139116
140117 describe ( "setSymbols" , ( ) => {
0 commit comments