Skip to content
Permalink
Browse files
Delete replace() in image module
  • Loading branch information
sarkarj committed Dec 2, 2019
1 parent 1ba7dc6 commit 1ce6bbe116ab6c7ac5efbde12435e86c489ce351
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
@@ -48,23 +48,6 @@ class Image {
}
}

async replace(filename, description, imageId) {
try{
if(filename.length === 0) throw new Error('filename is missing')
let sql
if(description === undefined) sql = `UPDATE images SET image_path = '${filename}'
WHERE image_id = ${imageId};`
else sql = `UPDATE images SET image_path = ${filename},
image_description = '${description}' WHERE image_id = ${imageId};`
await this.db.run(sql)
sql = 'SELECT last_insert_rowid() as id'
const result = await this.db.get(sql)
return result['id']
} catch(err) {
throw err
}
}

/**
* Retrieves details of an image
* @param {Integer} key - id of the image
@@ -39,15 +39,6 @@ describe('add()', () => {
})
})

describe('replace()', () => {
test('return error if filename is empty', async done => {
expect.assertions(1)
const image = await new Image()
await expect(image.replace(''))
.rejects.toEqual(Error('filename is missing'))
done()
})
})

describe('get()', () => {
test('return error if parameters are not stated', async done => {

0 comments on commit 1ce6bbe

Please sign in to comment.