Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmore committed Jun 3, 2022
1 parent 68cb6a2 commit 648b102
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/issue-diploma.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,12 @@ class IssueDiploma extends ScopedElementsMixin(AdapterLitElement) {
}, 1000);
}

async httpGetAsync(url, options) {
console.log('httpGetAsync', url, options);
let response = await fetch(url, options).then(result => {
if (!result.ok) throw Error(url+' status: '+result.status+' '+result.statusText);
return result.json();
});

return response;
async httpGetAsync(url, options) {
console.log('httpGetAsync', url);
const result = await fetch(url, options);
if (!result.ok)
throw Error(url+' '+result.status+' '+result.statusText);
return result.json();
}

async fetchDiplomas() {
Expand Down
12 changes: 5 additions & 7 deletions src/issue-grades.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,11 @@ class IssueGrades extends ScopedElementsMixin(AdapterLitElement) {
}

async httpGetAsync(url, options) {
console.log('httpGetAsync', url, options);
let response = await fetch(url, options).then(result => {
if (!result.ok) throw Error(url+' status: '+result.status+' '+result.statusText);
return result.json();
});

return response;
console.log('httpGetAsync', url);
const result = await fetch(url, options);
if (!result.ok)
throw Error(url+' '+result.status+' '+result.statusText);
return result.json();
}

async fetchCourseGrades() {
Expand Down
2 changes: 2 additions & 0 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ suite('issue-diploma', () => {
await new Promise(r => setTimeout(r, 2000));
assert.isFalse(node.exporting, 'cred offer already accepted by student');

await new Promise(r => setTimeout(r, 3000));

let student_get_offers = await node.httpGetAsync('https://kraken.iaik.tugraz.at/issuecredential/actions');
assert.isNotEmpty(student_get_offers);
Expand Down Expand Up @@ -217,6 +218,7 @@ suite('issue-grades', () => {
await new Promise(r => setTimeout(r, 2000));
assert.isFalse(node.exporting, 'cred offer already accepted by student');

await new Promise(r => setTimeout(r, 3000));

let student_get_offers = await node.httpGetAsync('https://kraken.iaik.tugraz.at/issuecredential/actions');
assert.isNotEmpty(student_get_offers);
Expand Down

0 comments on commit 648b102

Please sign in to comment.