-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add interface for model collection with tests #141
base: collections
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start. Some comments are related with style. Your code is valid but we prefer the other style.
I will add more comments later.
src/repositorios/colllection.test.js
Outdated
"Test CollectionModel", | ||
() => { | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail because Sequelize is configured to return a query object instead of JSON. You need to use data.dataValues
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are expecting .toThrow(error?)
instead of .toBeNull()
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are expecting .toThrow(error?)
instead of .toBeNull()
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default should be public and the missing field should go to the default one.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are expecting .toThrow(error?)
instead of .toBeNull()
.
src/repositorios/colllection.test.js
Outdated
} | ||
); | ||
|
||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start a new describe
block.
@costascaio I rebased the
Your pull request is now against the rebased version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You changed src/repositorios/injury.test.js
but not src/repositorios/image.test.js
.
src/repositorios/injury.test.js
Outdated
@@ -14,7 +14,8 @@ describe( | |||
{ | |||
nome: "Short", | |||
detalhes: "Long", | |||
grade: 100 | |||
grade: 100, | |||
id_collection: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test might fail if collection doesn't exist. Fix it using #136.
src/repositorios/injury.test.js
Outdated
@@ -25,7 +26,8 @@ describe( | |||
id: expect.any(Number), | |||
nome: "Short", | |||
detalhes: "Long", | |||
grade: 100 | |||
grade: 100, | |||
id_collection: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test might fail if collection doesn't exist. Fix it using #136.
src/repositorios/injury.test.js
Outdated
@@ -47,7 +49,8 @@ describe( | |||
id: 1, | |||
nome: expect.any(String), | |||
detalhes: expect.any(String), | |||
grade: expect.any(Number) | |||
grade: expect.any(Number), | |||
id_collection: expect.any(Number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test might fail if collection doesn't exist. Fix it using #136.
src/repositorios/injury.test.js
Outdated
@@ -87,7 +90,8 @@ describe( | |||
id: expect.any(Number), | |||
nome: expect.any(String), | |||
detalhes: expect.any(String), | |||
grade: expect.any(Number) | |||
grade: expect.any(Number), | |||
id_collection: expect.any(Number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test might fail if collection doesn't exist. Fix it using #136.
@@ -93,23 +94,25 @@ module.exports = { | |||
}); | |||
}, | |||
|
|||
async cadastrarCelulaSegmentada(id_imagem, id_descricao) { | |||
async cadastrarCelulaSegmentada(id_imagem, id_descricao, id_collection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cadastrarCelulaSegmentada
doesn't need id_collection
. Check the model!
}); | ||
}, | ||
|
||
async cadastrarCelulaClassificada(id_imagem, id_lesao) { | ||
async cadastrarCelulaClassificada(id_imagem, id_lesao, id_collection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was removed during the simplification of the database schema.
src/repositorios/colllection.test.js
Outdated
@@ -0,0 +1,162 @@ | |||
"use strict"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File name has a typo. Rename it from src/repositorios/colllection.test.js
to src/repositorios/collection.test.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use sed -i 's/expecte/expect/' src/repositorios/colllection.test.js
to fix the typos.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
src/repositorios/colllection.test.js
Outdated
}) | ||
.then( | ||
data => { | ||
expecte(data).toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here. Replace expecte
with expect
.
@costascaio I rebased the
And resolve the conflicts. |
return CollectionModel.findByPk(id_collection); | ||
}, | ||
|
||
async update_collection(request){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add toggle_public_collection(id_collection)
.
src/repositorios/collection.test.js
Outdated
return CollectionDOA.create_collection({ | ||
name: "Jest", | ||
slang: "jest", | ||
public: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default for public
should be false
.
) | ||
} | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_collection without public
is missing.
} | ||
); | ||
|
||
test( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move get_collection
to their own suite (inside describe
).
expect(data.dataValues) | ||
.toMatchObject( | ||
{ | ||
id: expect.any(Number), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace
id: expect.any(Number),
with
id: 1,
return CollectionModel.create(collection); | ||
}, | ||
|
||
async delete_collection(id_collection){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to mark for deletion instead of delete. Need to add a new field delete
.
); | ||
} | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed test delete_collection
.
@@ -246,72 +263,3 @@ describe( | |||
|
|||
} | |||
); | |||
|
|||
|
|||
describe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should not be delete.
@costascaio Any update? |
ce16e4f
to
28a703d
Compare
@costascaio you merge instead of rebase. Please fix it. |
@costascaio please follow the steps
|
3cb42f9
to
a0027d1
Compare
No description provided.