diff --git a/src/routes/postNoSegments.js b/src/routes/postNoSegments.js index 6494095..6b2b7aa 100644 --- a/src/routes/postNoSegments.js +++ b/src/routes/postNoSegments.js @@ -7,14 +7,14 @@ module.exports = (req, res) => { // Collect user input data let videoID = req.body.videoID; let userID = req.body.userID; - let categorys = req.body.categorys; + let categories = req.body.categories; // Check input data is valid if (!videoID || !userID - || !categorys - || !Array.isArray(categorys) - || categorys.length === 0 + || !categories + || !Array.isArray(categories) + || categories.length === 0 ) { res.status(400).json({ status: 400, @@ -45,20 +45,20 @@ module.exports = (req, res) => { }); } - // get user categorys not already submitted that match accepted format - let categorysToMark = categorys.filter((category) => { + // get user categories not already submitted that match accepted format + let categoriesToMark = categories.filter((category) => { return !!category.match(/^[a-zA-Z]+$/); }).filter((category) => { return noSegmentList.indexOf(category) === -1; }); // remove any duplicates - categorysToMark = categorysToMark.filter((category, index) => { - return categorysToMark.indexOf(category) === index; + categoriesToMark = categoriesToMark.filter((category, index) => { + return categoriesToMark.indexOf(category) === index; }); // create database entry - categorysToMark.forEach((category) => { + categoriesToMark.forEach((category) => { try { db.prepare('run', "INSERT INTO noSegments (videoID, userID, category) VALUES(?, ?, ?)", [videoID, userID, category]); } catch (err) { @@ -73,6 +73,6 @@ module.exports = (req, res) => { res.status(200).json({ status: 200, - submitted: categorysToMark + submitted: categoriesToMark }); }; \ No newline at end of file diff --git a/test/cases/noSegmentRecords.js b/test/cases/noSegmentRecords.js index d902478..a09264f 100644 --- a/test/cases/noSegmentRecords.js +++ b/test/cases/noSegmentRecords.js @@ -25,11 +25,11 @@ describe('noSegmentRecords', () => { else done('Version isn\'t greater that 1. Version is ' + version); }); - it('Should be able to submit categorys not in video (http response)', (done) => { + it('Should be able to submit categories not in video (http response)', (done) => { let json = { videoID: 'no-segments-video-id', userID: 'VIPUser-noSegments', - categorys: [ + categories: [ 'outro', 'shilling', 'shilling', @@ -64,11 +64,11 @@ describe('noSegmentRecords', () => { }); }); - it('Should be able to submit categorys not in video (sql check)', (done) => { + it('Should be able to submit categories not in video (sql check)', (done) => { let json = { videoID: 'no-segments-video-id-1', userID: 'VIPUser-noSegments', - categorys: [ + categories: [ 'outro', 'shilling', 'shilling', @@ -110,11 +110,11 @@ describe('noSegmentRecords', () => { }); }); - it('Should return 400 for no categorys', (done) => { + it('Should return 400 for no categories', (done) => { let json = { videoID: 'test', userID: 'test', - categorys: [] + categories: [] }; request.post(utils.getbaseURL() @@ -133,7 +133,7 @@ describe('noSegmentRecords', () => { let json = { videoID: 'test', userID: null, - categorys: ['sponsor'] + categories: ['sponsor'] }; request.post(utils.getbaseURL() @@ -152,7 +152,7 @@ describe('noSegmentRecords', () => { let json = { videoID: null, userID: 'test', - categorys: ['sponsor'] + categories: ['sponsor'] }; request.post(utils.getbaseURL() @@ -167,11 +167,11 @@ describe('noSegmentRecords', () => { }); }); - it('Should return 400 object categorys)', (done) => { + it('Should return 400 object categories)', (done) => { let json = { videoID: 'test', userID: 'test', - categorys: {} + categories: {} }; request.post(utils.getbaseURL() @@ -186,11 +186,11 @@ describe('noSegmentRecords', () => { }); }); - it('Should return 400 bad format categorys', (done) => { + it('Should return 400 bad format categories', (done) => { let json = { videoID: 'test', userID: 'test', - categorys: 'sponsor' + categories: 'sponsor' }; request.post(utils.getbaseURL() @@ -209,7 +209,7 @@ describe('noSegmentRecords', () => { let json = { videoID: 'test', userID: 'test', - categorys: [ + categories: [ 'sponsor' ] };