Skip to content

Commit

Permalink
Fixed issue with basic GET
Browse files Browse the repository at this point in the history
  • Loading branch information
thebpmgroup committed Dec 14, 2019
1 parent 6a06ba7 commit c2a04f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/mockr.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class MockR {
if(options==undefined){
//This is a GET
let r = this.getRouteByUri(uri,"GET");
return Promise.resolve({ json: () => Promise.resolve(promisedData)});
console.log(r.Data);
return Promise.resolve({ json: () => Promise.resolve(r.Data)});
}
}
get Routes (){
Expand All @@ -25,7 +26,7 @@ export class MockR {
let r = new MockRRoute();
r.Verb = verb;
r.Uri = uri;
r.data = data;
r.Data = data;
this.Routes.push(r);
}
getRouteByUri(uri,verb)
Expand Down Expand Up @@ -67,7 +68,7 @@ export class MockRRoute {
return this._data;
}
set Data (data){
JSON.parse(data);
this._data = value;
//JSON.parse(data);
this._data = data;
}
}
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("MockR REST Mocking framework", () => {
expect(m.Routes.length).toEqual(1);
expect(m.Routes[0].Verb).toEqual("GET");
expect(m.Routes[0].Uri).toEqual("test.com/users");
expect(m.Routes[0].data).toEqual(data);
expect(m.Routes[0].Data).toEqual(data);
m.Routes.length = 0;
});
it("returns the data as a promise from the specified GET route", async() =>{
Expand All @@ -38,7 +38,8 @@ describe("MockR REST Mocking framework", () => {
}
];
m.addRoute("GET","test.com/users",data);
let d = await fetch(uri);
//expect(d.json()).toEqual(data);
let response = await fetch(uri);
let d = await response.json();
expect(d).toEqual(data);
});
});

0 comments on commit c2a04f5

Please sign in to comment.