Skip to content

Commit f6785e3

Browse files
committed
use API endpoint for testing GET notes endpoint
1 parent 2c781f7 commit f6785e3

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/content/4/en/part4b.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,15 @@ test('notes are returned as json', async () => {
614614
})
615615

616616
test('all notes are returned', async () => {
617-
const notes = await helper.notesInDb() // highlight-line
617+
const response = await api.get('/api/notes')
618618

619-
assert.strictEqual(notes.length, helper.initialNotes.length) // highlight-line
619+
assert.strictEqual(response.body.length, helper.initialNotes.length) // highlight-line
620620
})
621621

622622
test('a specific note is within the returned notes', async () => {
623-
const notes = await helper.notesInDb() // highlight-line
623+
const response = await api.get('/api/notes')
624624

625-
const contents = notes.map(n => n.content)
625+
const contents = response.body.map(e => e.content)
626626
assert(contents.includes('HTML is easy'))
627627
})
628628

@@ -1078,15 +1078,15 @@ describe('when there is initially some notes saved', () => {
10781078
})
10791079

10801080
test('all notes are returned', async () => {
1081-
const notes = await helper.notesInDb()
1081+
const response = await api.get('/api/notes')
10821082

1083-
assert.strictEqual(notes.length, helper.initialNotes.length)
1083+
assert.strictEqual(response.body.length, helper.initialNotes.length)
10841084
})
10851085

10861086
test('a specific note is within the returned notes', async () => {
1087-
const notes = await helper.notesInDb()
1087+
const response = await api.get('/api/notes')
10881088

1089-
const contents = notes.map(n => n.content)
1089+
const contents = response.body.map(e => e.content)
10901090
assert(contents.includes('HTML is easy'))
10911091
})
10921092

src/content/4/fi/osa4b.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,15 +609,15 @@ test('notes are returned as json', async () => {
609609
})
610610

611611
test('all notes are returned', async () => {
612-
const notes = await helper.notesInDb() // highlight-line
612+
const response = await api.get('/api/notes')
613613

614-
assert.strictEqual(notes.length, helper.initialNotes.length) // highlight-line
614+
assert.strictEqual(response.body.length, helper.initialNotes.length) // highlight-line
615615
})
616616

617617
test('a specific note is within the returned notes', async () => {
618-
const notes = await helper.notesInDb() // highlight-line
618+
const response = await api.get('/api/notes')
619619

620-
const contents = notes.map(n => n.content)
620+
const contents = response.body.map(e => e.content)
621621
assert(contents.includes('HTML is easy'))
622622
})
623623

@@ -1068,15 +1068,15 @@ describe('when there is initially some notes saved', () => {
10681068
})
10691069

10701070
test('all notes are returned', async () => {
1071-
const notes = await helper.notesInDb()
1071+
const response = await api.get('/api/notes')
10721072

1073-
assert.strictEqual(notes.length, helper.initialNotes.length)
1073+
assert.strictEqual(response.body.length, helper.initialNotes.length)
10741074
})
10751075

10761076
test('a specific note is within the returned notes', async () => {
1077-
const notes = await helper.notesInDb()
1077+
const response = await api.get('/api/notes')
10781078

1079-
const contents = notes.map(n => n.content)
1079+
const contents = response.body.map(e => e.content)
10801080
assert(contents.includes('HTML is easy'))
10811081
})
10821082

0 commit comments

Comments
 (0)