diff --git a/src/test/routes/admin.constants.json b/src/test/routes/admin/admin.constants.json similarity index 100% rename from src/test/routes/admin.constants.json rename to src/test/routes/admin/admin.constants.json diff --git a/src/test/routes/admin.spec.js b/src/test/routes/admin/admin.spec.js similarity index 94% rename from src/test/routes/admin.spec.js rename to src/test/routes/admin/admin.spec.js index 59190a4..2655059 100644 --- a/src/test/routes/admin.spec.js +++ b/src/test/routes/admin/admin.spec.js @@ -1,9 +1,9 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db/generalHandler'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/generalHandler'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); @@ -12,7 +12,7 @@ const chaiHttp = require('chai-http'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./admin.constants.json'); const testToken = jwt.sign({ admin: true }, config.secret); diff --git a/src/test/routes/album.constants.json b/src/test/routes/album/album.constants.json similarity index 100% rename from src/test/routes/album.constants.json rename to src/test/routes/album/album.constants.json diff --git a/src/test/routes/album.extra.constants.json b/src/test/routes/album/album.extra.constants.json similarity index 100% rename from src/test/routes/album.extra.constants.json rename to src/test/routes/album/album.extra.constants.json diff --git a/src/test/routes/album.extra.spec.js b/src/test/routes/album/album.extra.spec.js similarity index 96% rename from src/test/routes/album.extra.spec.js rename to src/test/routes/album/album.extra.spec.js index b0c3dbe..110ec46 100644 --- a/src/test/routes/album.extra.spec.js +++ b/src/test/routes/album/album.extra.spec.js @@ -1,19 +1,19 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); -const logger = require('../../utils/logger'); +const logger = require('../../../utils/logger'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./album.extra.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); diff --git a/src/test/routes/album.spec.js b/src/test/routes/album/album.spec.js similarity index 97% rename from src/test/routes/album.spec.js rename to src/test/routes/album/album.spec.js index ee3b7db..1165d3f 100644 --- a/src/test/routes/album.spec.js +++ b/src/test/routes/album/album.spec.js @@ -1,19 +1,19 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); -const logger = require('../../utils/logger'); +const logger = require('../../../utils/logger'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./album.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); diff --git a/src/test/routes/artist.constants.json b/src/test/routes/artist/artist.constants.json similarity index 100% rename from src/test/routes/artist.constants.json rename to src/test/routes/artist/artist.constants.json diff --git a/src/test/routes/artist.me.constants.json b/src/test/routes/artist/artist.me.constants.json similarity index 100% rename from src/test/routes/artist.me.constants.json rename to src/test/routes/artist/artist.me.constants.json diff --git a/src/test/routes/artist.me.spec.js b/src/test/routes/artist/artist.me.spec.js similarity index 97% rename from src/test/routes/artist.me.spec.js rename to src/test/routes/artist/artist.me.spec.js index bea7e82..cecad39 100644 --- a/src/test/routes/artist.me.spec.js +++ b/src/test/routes/artist/artist.me.spec.js @@ -1,18 +1,18 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const dbHandler = require('../../handlers/db'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); -const logger = require('../../utils/logger'); +const logger = require('../../../utils/logger'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./artist.me.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); diff --git a/src/test/routes/artist.spec.js b/src/test/routes/artist/artist.spec.js similarity index 98% rename from src/test/routes/artist.spec.js rename to src/test/routes/artist/artist.spec.js index 0931f40..8f51acd 100644 --- a/src/test/routes/artist.spec.js +++ b/src/test/routes/artist/artist.spec.js @@ -1,18 +1,18 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const dbHandler = require('../../handlers/db'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); -const logger = require('../../utils/logger'); +const logger = require('../../../utils/logger'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./artist.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); diff --git a/src/test/routes/token.constants.json b/src/test/routes/token/token.constants.json similarity index 100% rename from src/test/routes/token.constants.json rename to src/test/routes/token/token.constants.json diff --git a/src/test/routes/token.spec.js b/src/test/routes/token/token.spec.js similarity index 96% rename from src/test/routes/token.spec.js rename to src/test/routes/token/token.spec.js index 825cf6e..3add200 100644 --- a/src/test/routes/token.spec.js +++ b/src/test/routes/token/token.spec.js @@ -1,9 +1,9 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db/generalHandler'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/generalHandler'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); diff --git a/src/test/routes/track.me.constants.json b/src/test/routes/track.me.constants.json deleted file mode 100644 index 6859275..0000000 --- a/src/test/routes/track.me.constants.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "jwtTestUser": { - "id": 24 - }, - "initialTrack": { - "name": "Despacito", - "albumId": 240, - "artists": [2, 1] - }, - "validTrackId": 1 -} \ No newline at end of file diff --git a/src/test/routes/track.constants.json b/src/test/routes/track/track.constants.json similarity index 100% rename from src/test/routes/track.constants.json rename to src/test/routes/track/track.constants.json diff --git a/src/test/routes/track/track.me.constants.json b/src/test/routes/track/track.me.constants.json new file mode 100644 index 0000000..0397078 --- /dev/null +++ b/src/test/routes/track/track.me.constants.json @@ -0,0 +1,25 @@ +{ + "jwtTestUser": { + "id": 24 + }, + "initialTrack": { + "name": "Despacito", + "albumId": 240, + "artists": [2, 1] + }, + "validTrackId": 1, + "initialArtist1": { + "id": 1, + "name": "Papa Baute", + "description": "Tiene un implante coclear?", + "genres": ["Bachata"], + "images": ["una con guido", "otra con sergio"] + }, + "initialArtist2": { + "id": 2, + "name": "Luis Fonsi", + "description": "El que canta despacito", + "genres": ["pero que no es justin"], + "images": ["ni daddy yankee"] + } +} \ No newline at end of file diff --git a/src/test/routes/track.me.spec.js b/src/test/routes/track/track.me.spec.js similarity index 92% rename from src/test/routes/track.me.spec.js rename to src/test/routes/track/track.me.spec.js index 4c241f2..20a4170 100644 --- a/src/test/routes/track.me.spec.js +++ b/src/test/routes/track/track.me.spec.js @@ -1,10 +1,10 @@ process.env.NODE_ENV = 'test'; -const logger = require('../../utils/logger'); -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db'); +const logger = require('../../../utils/logger'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); @@ -13,9 +13,8 @@ const chaiHttp = require('chai-http'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./track.me.constants.json'); -const artistsConstants = require('./artist.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); @@ -27,8 +26,8 @@ describe('Track me', () => { db.migrate.latest().then(() => { dbHandler.general.createNewEntry(tables.artists, [ - artistsConstants.initialArtist, - artistsConstants.testArtist, + constants.initialArtist1, + constants.initialArtist2, ]).then(artists => { logger.info(`Tests artists created: ${JSON.stringify(artists, null, 4)}`); dbHandler.track.createNewTrackEntry(constants.initialTrack) diff --git a/src/test/routes/track.spec.js b/src/test/routes/track/track.spec.js similarity index 98% rename from src/test/routes/track.spec.js rename to src/test/routes/track/track.spec.js index 96e7fd7..ba43436 100644 --- a/src/test/routes/track.spec.js +++ b/src/test/routes/track/track.spec.js @@ -1,19 +1,19 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/index'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); const chaiHttp = require('chai-http'); -const logger = require('../../utils/logger'); +const logger = require('../../../utils/logger'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./track.constants.json'); const testToken = jwt.sign(constants.jwtTestUser, config.secret); diff --git a/src/test/routes/user.constants.json b/src/test/routes/user/user.constants.json similarity index 100% rename from src/test/routes/user.constants.json rename to src/test/routes/user/user.constants.json diff --git a/src/test/routes/user.me.constants.json b/src/test/routes/user/user.me.constants.json similarity index 100% rename from src/test/routes/user.me.constants.json rename to src/test/routes/user/user.me.constants.json diff --git a/src/test/routes/user.me.spec.js b/src/test/routes/user/user.me.spec.js similarity index 97% rename from src/test/routes/user.me.spec.js rename to src/test/routes/user/user.me.spec.js index e454722..b964ba5 100644 --- a/src/test/routes/user.me.spec.js +++ b/src/test/routes/user/user.me.spec.js @@ -1,9 +1,9 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db/generalHandler'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/generalHandler'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); @@ -12,7 +12,7 @@ const chaiHttp = require('chai-http'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./user.me.constants.json'); const initialUserToken = jwt.sign(constants.initialUser, config.secret); diff --git a/src/test/routes/user.spec.js b/src/test/routes/user/user.spec.js similarity index 97% rename from src/test/routes/user.spec.js rename to src/test/routes/user/user.spec.js index 051a4b3..d625a52 100644 --- a/src/test/routes/user.spec.js +++ b/src/test/routes/user/user.spec.js @@ -1,9 +1,9 @@ process.env.NODE_ENV = 'test'; -const app = require('../../app'); -const db = require('../../database'); -const tables = require('../../database/tableNames'); -const dbHandler = require('../../handlers/db/generalHandler'); +const app = require('../../../app'); +const db = require('../../../database/index'); +const tables = require('../../../database/tableNames'); +const dbHandler = require('../../../handlers/db/generalHandler'); const jwt = require('jsonwebtoken'); const request = require('supertest'); const chai = require('chai'); @@ -12,7 +12,7 @@ const chaiHttp = require('chai-http'); chai.should(); chai.use(chaiHttp); -const config = require('./../../config'); +const config = require('./../../../config'); const constants = require('./user.constants.json'); const testToken = jwt.sign({ admin: true }, config.secret);