-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix track tests #120
Fix track tests #120
Changes from 7 commits
bfac0f6
4356f7f
44c5bbc
f99eb32
1f1c1b0
5b7be04
f7a7998
072109a
999c42f
c202c29
be221b6
1d33461
b1c03b3
8970fbd
1466f34
de60743
eaae7dd
c208f40
16aeaac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ const jwt = require('jsonwebtoken'); | |
const request = require('supertest'); | ||
const chai = require('chai'); | ||
const chaiHttp = require('chai-http'); | ||
const logger = require('../../utils/logger'); | ||
|
||
chai.should(); | ||
chai.use(chaiHttp); | ||
|
@@ -25,7 +26,23 @@ describe('Track', () => { | |
.then(() => { | ||
db.migrate.latest() | ||
.then(() => { | ||
dbHandler.track.createNewTrackEntry(constants.initialTrack) | ||
const createArtists = () => { | ||
dbHandler.general.createNewEntry(tables.artists, | ||
[ | ||
artistsConstants.initialArtist, | ||
artistsConstants.testArtist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Si va a ser un initial siempre metele initialArtist2 |
||
] | ||
) | ||
.then((artists) => logger.debug(`Tests Artists created: ${JSON.stringify(artists, null, 4)}`)) | ||
.catch((error) => logger.warn(`Test Artists creation Error: ${error}`));; | ||
}; | ||
const createTracks = () => { | ||
dbHandler.track.createNewTrackEntry(constants.initialTrack) | ||
.then((tracks) => logger.debug(`Tests Tracks created: ${JSON.stringify(tracks, null, 4)}`)) | ||
.catch((error) => logger.warn(`Test Tracks creation Error: ${error}`)); | ||
}; | ||
const entryCreators = [createArtists(), createTracks()]; | ||
Promise.all(entryCreators) | ||
.then(() => done()) | ||
.catch(error => done(error)); | ||
}) | ||
|
@@ -60,6 +77,7 @@ describe('Track', () => { | |
res.body.metadata.should.have.property('count'); | ||
res.body.should.have.property('tracks'); | ||
res.body.tracks.should.be.a('array'); | ||
res.body.tracks.should.have.lengthOf(1); | ||
done(); | ||
}); | ||
}); | ||
|
@@ -166,8 +184,12 @@ describe('Track', () => { | |
res.body.track.should.have.property('name').eql(constants.initialTrack.name); | ||
res.body.track.should.have.property('duration'); | ||
res.body.track.should.have.property('href'); | ||
res.body.track.should.have.property('album'); // TODO | ||
res.body.track.should.have.property('artists'); | ||
res.body.track.should.have.property('album'); | ||
res.body.track.should.have.property('artists') | ||
.eql([ | ||
artistsConstants.initialShortArtist, | ||
artistsConstants.testShortArtist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aca! mejor comparar contra lo que devovio knex y no contra la constante que suponemos que va a devolver, no? |
||
]); | ||
res.body.track.should.have.property('popularity'); | ||
// TODO add check for 'rate: int' inside popularity object | ||
done(); | ||
|
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.
Estos ids los tenemos en varios pero creo que no esta bueno. No estoy segura de si se insertan asi o si no y despues los usamos asumiendo que quedaron con ese id. Nos complica mucho si guardamos las entries que devuelve knex una ve que creó y usamos ese id?
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.
Si le agregas el id y el mismo no esta repetido o es invalido la entry va a tener ese id seguro. Si queremos usar el id que devuelve knex independientemente de su valor habria que borrar esos campos de los json y no determinar un id valido de antemano en los json.