Skip to content
Permalink
Browse files
Merge pull request #3 from 5001CEM-1920SEPJAN/one-last-hope3
Delete replace() in image module
  • Loading branch information
sarkarj committed Dec 2, 2019
2 parents f5ba19e + 1ce6bbe commit e504f7a13e8cc1cf3a23a55958889d35acc69fc4
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 e504f7a

Please sign in to comment.