Skip to content

Commit

Permalink
debugging, one more test working
Browse files Browse the repository at this point in the history
  • Loading branch information
Abby Wheelis committed Feb 14, 2024
1 parent 19a46ed commit f0a55f5
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions www/__tests__/enketoHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ it('gets the saved result or throws an error', async () => {
},
} as unknown as AppConfig;

// //resolving instead of rejecting?
//resolving instead of rejecting?
// await expect(saveResponse(surveyName, badForm, config, opts)).rejects.toThrow(
// 'The times you entered are invalid. Please ensure that the start time is before the end time.',
// );
Expand Down Expand Up @@ -382,29 +382,28 @@ it('filters the survey responses by their name and version', async () => {
);
});

//returning undefined? fetch is not working?
// it('fetches the survey', async () => {
// global.fetch = (url: string) =>
// new Promise((rs, rj) => {
// setTimeout(() =>
// rs({
// text: () =>
// new Promise((rs, rj) => {
// console.log('reading the text');
// let urlList = url.split('.');
// let urlEnd = urlList[urlList.length - 1];
// if (urlEnd === 'json') {
// setTimeout(() => rs('{ "data": "is_json" }'), 100);
// } else {
// setTimeout(() => rs('not json'), 100);
// }
// }),
// }),
// );
// }) as any;
// await expect(
// fetchSurvey(
// 'https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/label_options/example-study-label-options.json',
// ),
// ).resolves.toMatchObject({ data: 'is_json' });
// });
it('fetches the survey', async () => {
global.fetch = (url: string) =>
new Promise((rs, rj) => {
setTimeout(() =>
rs({
text: () =>
new Promise((rs, rj) => {
console.log('reading the text');
let urlList = url.split('.');
let urlEnd = urlList[urlList.length - 1];
if (urlEnd === 'json') {
setTimeout(() => rs('{ "data": "is_json" }'), 100);
} else {
setTimeout(() => rs('not json'), 100);
}
}),
}),
);
}) as any;
await expect(
fetchSurvey(
'https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/label_options/example-study-label-options.json',
),
).resolves.toMatchObject({ data: 'is_json' });
});

0 comments on commit f0a55f5

Please sign in to comment.