From 951088df64864b7002d8342e3bf2848161f6e319 Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Thu, 8 Sep 2016 17:08:09 -0500 Subject: [PATCH 01/12] Add npm to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8ce40bcc..731ce3d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ before_script: - until curl http://localhost:9200/; do sleep 1; done script: - py.test --cov bulbs --cov-report term-missing + - npm test - scripts/lint after_success: - coveralls From 776e146036bf26127a0b15770f4787ad7759cdea Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 09:48:52 -0500 Subject: [PATCH 02/12] It's somewhat important to install packages before running tests --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 731ce3d0..200ad69a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ before_script: - until curl http://localhost:9200/; do sleep 1; done script: - py.test --cov bulbs --cov-report term-missing + - npm install - npm test - scripts/lint after_success: From 1be20689ab3f12c5d7c8c58e7b9bfdf62a9f113b Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 10:18:39 -0500 Subject: [PATCH 03/12] Let's try this again --- .travis.yml | 20 ++++++++++---------- karma.travis.conf.js | 8 ++++++++ package.json | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 karma.travis.conf.js diff --git a/.travis.yml b/.travis.yml index 200ad69a..e2e642f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,15 +3,15 @@ language: python sudo: required matrix: - include: - # Current production - - python: '2.7' - env: ELASTICSEARCH_VERSION=1.4.4 - - python: "3.5" - env: ELASTICSEARCH_VERSION=1.4.4 - # Latest in 1.X line (as of 2016-02-10). For speed, just run future ES version with latest Python - - python: '3.5' - env: ELASTICSEARCH_VERSION=1.7.5 + include: + # Current production + - python: '2.7' + env: ELASTICSEARCH_VERSION=1.4.4 + - python: "3.5" + env: ELASTICSEARCH_VERSION=1.4.4 + # Latest in 1.X line (as of 2016-02-10). For speed, just run future ES version with latest Python + - python: '3.5' + env: ELASTICSEARCH_VERSION=1.7.5 cache: directories: - $HOME/.cache/pip @@ -35,7 +35,7 @@ before_script: script: - py.test --cov bulbs --cov-report term-missing - npm install - - npm test + - npm run ci-test - scripts/lint after_success: - coveralls diff --git a/karma.travis.conf.js b/karma.travis.conf.js new file mode 100644 index 00000000..95090a1a --- /dev/null +++ b/karma.travis.conf.js @@ -0,0 +1,8 @@ +var karmaConfig = require('./karma.conf'); + +module.exports = function (config) { + config.set(Object.assign({ + browsers: ['Chrome_travis_ci'], + captureTimeout: 0, + }, karmaConfig)); +}; diff --git a/package.json b/package.json index b21c72e5..946a39dd 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "private": true, "scripts": { "karma": "karma start", - "test": "karma start --single-run" + "test": "karma start --single-run", + "ci-test": "karma start --config karma.conf.travis.js --single-run" }, "dependencies": { "invariant": "^2.2.1", From 835b033e023d9714de2fa93bf42531075488ba8f Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 10:37:46 -0500 Subject: [PATCH 04/12] Add karma config for travis --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index e2e642f2..3c74b5b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,11 @@ before_script: - psql -c "create user bulbs WITH superuser PASSWORD 'testing';" -U postgres # Wait for ES startup - until curl http://localhost:9200/; do sleep 1; done + - bower install + - npm install + - 'export CHROME_BIN=chromium-browser' + - 'export DISPLAY=:99.0' + - 'sh -e /etc/init.d/xvfb start' script: - py.test --cov bulbs --cov-report term-missing - npm install From c9d235e6b76c4056f3ea715fc8f7b37964c06afe Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 11:07:58 -0500 Subject: [PATCH 05/12] Whoops, we don't need bower --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3c74b5b6..38f947d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,6 @@ before_script: - psql -c "create user bulbs WITH superuser PASSWORD 'testing';" -U postgres # Wait for ES startup - until curl http://localhost:9200/; do sleep 1; done - - bower install - npm install - 'export CHROME_BIN=chromium-browser' - 'export DISPLAY=:99.0' From 2583e9028ce27b6a5389bf1aa822baa0c4a40014 Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 11:34:04 -0500 Subject: [PATCH 06/12] Exclude node_modules from python linter, don't double install npm packages --- .travis.yml | 1 - scripts/lint | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38f947d9..934b2e97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,6 @@ before_script: - 'sh -e /etc/init.d/xvfb start' script: - py.test --cov bulbs --cov-report term-missing - - npm install - npm run ci-test - scripts/lint after_success: diff --git a/scripts/lint b/scripts/lint index 0e18bf20..ee4d2aa8 100755 --- a/scripts/lint +++ b/scripts/lint @@ -2,4 +2,4 @@ # # Run linter(s) over project -flake8 . +flake8 . --exclude node_modules From b17d8bbd38876c631d75095a71e9d7eeab7e7caf Mon Sep 17 00:00:00 2001 From: Dayton Nolan Date: Fri, 9 Sep 2016 13:42:26 -0500 Subject: [PATCH 07/12] Lint WIP --- .eslintrc | 1 + bulbs/ads/static/js/mobile-ad-placer.js | 9 +-- bulbs/ads/static/js/mobile-ad-placer.test.js | 15 ++-- .../videos/js/recirc/main.browserify.js | 2 +- .../video-recirc-list/video-recirc-list.js | 14 ++-- .../current-episode-data.js | 12 ++-- .../current-episode-data.test.js | 38 +++++----- .../series/popular-series/popular-series.js | 2 +- .../popular-series/popular-series.test.js | 6 +- .../js/series/series-meta/series-meta.js | 16 ++--- .../js/series/series-meta/series-meta.test.js | 20 +++--- .../js/series/series-page/series-page.js | 6 +- .../series-video-grid/series-video-grid.js | 46 ++++++------- .../series-video-grid.test.js | 20 +++--- .../series-video-latest-episode.js | 12 ++-- .../series-video-latest-episode.test.js | 45 ++++++------ .../series-video-list/series-video-list.js | 14 ++-- .../series-video-list.test.js | 19 ++--- .../video-detail-page/video-detail-page.js | 11 +-- .../video-detail-series-meta.js | 16 ++--- .../video-detail-series-meta.test.js | 39 ++++++----- test_helper.js | 69 ++++++++++--------- 22 files changed, 215 insertions(+), 217 deletions(-) diff --git a/.eslintrc b/.eslintrc index 3f2266a7..3a64f4e7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -17,6 +17,7 @@ "Cookies": false, "Clickventure": false, "SpecialCoverageLoader": false, + "TestHelper": false }, "ecmaFeatures": { "arrowFunctions": true, diff --git a/bulbs/ads/static/js/mobile-ad-placer.js b/bulbs/ads/static/js/mobile-ad-placer.js index 6fe58438..f932fb24 100644 --- a/bulbs/ads/static/js/mobile-ad-placer.js +++ b/bulbs/ads/static/js/mobile-ad-placer.js @@ -1,9 +1,10 @@ 'use strict'; var _ = require('lodash/lodash'); -var adHtml = '
\ - Content continues below advertisement \ -
'; - +var adHtml = [ + '
', + 'Content continues below advertisement', + '
', +].join(''); var MobileAdPlacer = { placeAds: function () { diff --git a/bulbs/ads/static/js/mobile-ad-placer.test.js b/bulbs/ads/static/js/mobile-ad-placer.test.js index 9ebb5d7b..4de28fa9 100644 --- a/bulbs/ads/static/js/mobile-ad-placer.test.js +++ b/bulbs/ads/static/js/mobile-ad-placer.test.js @@ -2,13 +2,12 @@ describe('MobileAdPlacer', function () { var mobileAdPlacer = require('./mobile-ad-placer'); var faker = require('faker'); - var article = '
' + var article = '
'; var paragraph351 = '

' + faker.lorem.words(351) + '

'; - var paragraph20 = '

' + faker.lorem.words(20) + '

'; beforeEach(function () { $('body').append(article); - window.ads = {loadAds: function() { return }}; + window.ads = {loadAds: function () { return; }}; }); afterEach(function () { @@ -19,25 +18,24 @@ describe('MobileAdPlacer', function () { $('.article-text').append(paragraph351); mobileAdPlacer.placeAds(); var articleContents = $('.article-text').children(); - expect($(articleContents[1]).attr('class')).to.equal("dfp dfp-slot-inread"); + expect($(articleContents[1]).attr('class')).to.equal('dfp dfp-slot-inread'); }); it('places multiple ads', function () { $('.article-text').append(paragraph351); $('.article-text').append(paragraph351); - adElement = document.createElement('ad'); + var adElement = document.createElement('ad'); mobileAdPlacer.placeAds(adElement); var ads = $('.article-text').find('.dfp-slot-inread'); expect(ads.length).to.equal(2); }); it('only places ads after paragraph breaks', function () { - adElement = document.createElement('ad'); + var adElement = document.createElement('ad'); var bigAssParagraph = '

' + faker.lorem.words(1000) + '

'; $('.article-text').append(bigAssParagraph); mobileAdPlacer.placeAds(adElement); - var articleContents = $('.article-text').children(); // sanity check ad is placed expect($('.article-text').find('.dfp').length).to.equal(1); // not placed within p element @@ -45,7 +43,6 @@ describe('MobileAdPlacer', function () { }); it('places no more than 4 ads', function () { - adElement = document.createElement('ad'); for(var i = 0; i < 5; i++) { $('.article-text').append(paragraph351); } @@ -55,7 +52,7 @@ describe('MobileAdPlacer', function () { }); it('does not call loadAds() if window.ads is undefined', function () { - window.ads = undefined; + window.ads = undefined; // eslint-disable-line no-undefined expect(mobileAdPlacer.placeAds).to.not.throw(Error); }); }); diff --git a/bulbs/videos/static/videos/js/recirc/main.browserify.js b/bulbs/videos/static/videos/js/recirc/main.browserify.js index 72af4a6a..a7568a89 100644 --- a/bulbs/videos/static/videos/js/recirc/main.browserify.js +++ b/bulbs/videos/static/videos/js/recirc/main.browserify.js @@ -4,4 +4,4 @@ var SeriesVideoList = require('../series/series-video-list/series-video-list'); $(document).ready(function () { new VideoRecircList(); new SeriesVideoList(); -}); \ No newline at end of file +}); diff --git a/bulbs/videos/static/videos/js/recirc/video-recirc-list/video-recirc-list.js b/bulbs/videos/static/videos/js/recirc/video-recirc-list/video-recirc-list.js index c9e86291..46b4bf73 100644 --- a/bulbs/videos/static/videos/js/recirc/video-recirc-list/video-recirc-list.js +++ b/bulbs/videos/static/videos/js/recirc/video-recirc-list/video-recirc-list.js @@ -18,14 +18,14 @@ VideoRecircList.prototype.loadVideoRecirc = function () { VideoRecircList.prototype.videoRecircFetched = function (data) { var that = this; - + var recirc = data.videos.slice(0,that.recircCount); recirc .forEach(function (video) { - var videoTitle = video.title; - var videoHref = '/v/' + video.id; - var posterSource = that.bettyUrl + '/' + video.poster.id; + var videoTitle = video.title; + var videoHref = '/v/' + video.id; + var posterSource = that.bettyUrl + '/' + video.poster.id; $('',{ 'class' : that.videoItem, 'href' : videoHref, @@ -35,10 +35,10 @@ VideoRecircList.prototype.videoRecircFetched = function (data) { 'class' : 'content', 'html' : '
', }).add($('

',{ - 'html' : videoTitle - })) + 'html' : videoTitle, + })), }).appendTo(that.$videoRecircList); }); }; -module.exports = VideoRecircList; \ No newline at end of file +module.exports = VideoRecircList; diff --git a/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.js b/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.js index 82a4770e..4787cc09 100644 --- a/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.js +++ b/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.js @@ -1,4 +1,4 @@ -CurrentEpisodeData = function(video) { +var CurrentEpisodeData = function (video) { this.$videoPlayer = $('bulbs-video'); this.$currentVideoTitle = $('#current-video-title'); this.$currentVideoDescription = $('#current-video-description'); @@ -15,15 +15,15 @@ CurrentEpisodeData = function(video) { this.$currentVideoShareTools.attr('share-title', this.currentVideoTitle); $('', { - 'href' : this.currentEpisodeHref, - 'data-track-action' : 'Single Series: Current Episode Title', - 'data-track-label' : this.currentEpisodeHref, - 'html' : '

' + this.currentVideoTitle + '

' + href: this.currentEpisodeHref, + 'data-track-action': 'Single Series: Current Episode Title', + 'data-track-label': this.currentEpisodeHref, + html: '

' + this.currentVideoTitle + '

', }).appendTo(this.$currentVideoTitle); if (video.description) { - $('

' + video.description + '

') + $('

' + video.description + '

') .appendTo(this.$currentVideoDescription); } diff --git a/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.test.js b/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.test.js index b9a92290..bafaf1a0 100644 --- a/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.test.js +++ b/bulbs/videos/static/videos/js/series/current-episode-data/current-episode-data.test.js @@ -1,11 +1,11 @@ describe('CurrentEpisodeData', function () { var CurrentEpisodeData = require('./current-episode-data'); var video = { - id: 5400, - title: 'A Show About Music', - poster: { id: 1234 }, - description: 'it sucks' - }; + id: 5400, + title: 'A Show About Music', + poster: { id: 1234 }, + description: 'it sucks', + }; var videoPlayer; var videohubBaseUrl = 'http://onionstudios.com'; @@ -19,7 +19,7 @@ describe('CurrentEpisodeData', function () { context('normal functionality', function () { - beforeEach(function() { + beforeEach(function () { $('body').append(videoPlayer); $('body').append(currentVideoTitle); @@ -29,44 +29,44 @@ describe('CurrentEpisodeData', function () { currentEpisodeData = new CurrentEpisodeData(video); }); - afterEach(function() { + afterEach(function () { videoPlayer.remove(); $('#current-video-title').remove(); $('#current-video-description').remove(); $('share-tools').remove(); }); - it('adds current video in series to player', function() { + it('adds current video in series to player', function () { var expected = videohubBaseUrl + '/video/' + video.id + '.json'; expect($(videoPlayer).attr('src')).to.equal(expected); }); - it('appends the current video title', function() { - var videoTitle = $('#current-video-title h2').html() - expect(videoTitle).to.equal("A Show About Music"); + it('appends the current video title', function () { + var videoTitle = $('#current-video-title h2').html(); + expect(videoTitle).to.equal('A Show About Music'); }); - it('appends the current video description', function() { - var videoDescription = $('#current-video-description p').html() - expect(videoDescription).to.equal("it sucks"); + it('appends the current video description', function () { + var videoDescription = $('#current-video-description p').html(); + expect(videoDescription).to.equal('it sucks'); }); describe('share-tools', function () { - it('appends the current video title', function() { + it('appends the current video title', function () { var videoShareToolsTitle = $('.current-video-share-tools').attr('share-title'); - expect(videoShareToolsTitle).to.equal("A Show About Music"); + expect(videoShareToolsTitle).to.equal('A Show About Music'); }); - it('appends the current video url', function() { + it('appends the current video url', function () { var videoShareToolsUrl = $('.current-video-share-tools').attr('share-url'); - expect(videoShareToolsUrl).to.equal("http://foo.bar/v/5400"); + expect(videoShareToolsUrl).to.equal('http://foo.bar/v/5400'); }); }); }); context('should fail when', function () { - it('not provided videohub base url', function() { + it('not provided videohub base url', function () { videoPlayer = $(''); $('body').append(videoPlayer); var subject = sinon.spy(CurrentEpisodeData); diff --git a/bulbs/videos/static/videos/js/series/popular-series/popular-series.js b/bulbs/videos/static/videos/js/series/popular-series/popular-series.js index b5252302..e18402b1 100644 --- a/bulbs/videos/static/videos/js/series/popular-series/popular-series.js +++ b/bulbs/videos/static/videos/js/series/popular-series/popular-series.js @@ -25,7 +25,7 @@ PopularSeries.prototype.popularSeriesFetched = function (data) { for(var i = 0; i < data.length; i++) { var series = data[i]; this.loadSeriesData(series.slug); - }; + } }; PopularSeries.prototype.seriesDataFetched = function (data) { diff --git a/bulbs/videos/static/videos/js/series/popular-series/popular-series.test.js b/bulbs/videos/static/videos/js/series/popular-series/popular-series.test.js index b27c1602..fff469bc 100644 --- a/bulbs/videos/static/videos/js/series/popular-series/popular-series.test.js +++ b/bulbs/videos/static/videos/js/series/popular-series/popular-series.test.js @@ -8,11 +8,11 @@ describe('PopularSeries', function () { series_description: 'blah blah blah', series_logo: 'http://foobar.com/image/600.png', total_episodes: 6, - total_seasons: 0 + total_seasons: 0, }, { total_episodes: 20, - total_seasons: 1 + total_seasons: 1, }]; beforeEach(function () { @@ -20,7 +20,7 @@ describe('PopularSeries', function () { data-channel-series='foobar.com/channel/funky/series.json' \ data-vidoehub-base='foobar.com' \ data-series-slug='funk-yeah'> \ - " + "; $('body').append(popularSeriesDiv); }); diff --git a/bulbs/videos/static/videos/js/series/series-meta/series-meta.js b/bulbs/videos/static/videos/js/series/series-meta/series-meta.js index 6dd987d0..4f70df82 100644 --- a/bulbs/videos/static/videos/js/series/series-meta/series-meta.js +++ b/bulbs/videos/static/videos/js/series/series-meta/series-meta.js @@ -1,4 +1,4 @@ -SeriesMeta = function() { +SeriesMeta = function () { this.$seriesGrid = $('#series-video-list'); this.videohubBase = this.$seriesGrid.data('videohub-base'); this.seriesSlug = this.$seriesGrid.data('series-slug') || window.location.href.split('/')[4]; @@ -10,18 +10,18 @@ SeriesMeta = function() { this.fetchSeriesMeta(); }; -SeriesMeta.prototype.fetchSeriesMeta = function() { +SeriesMeta.prototype.fetchSeriesMeta = function () { $.getJSON(this.source, this.seriesMetaFetched.bind(this)); }; -SeriesMeta.prototype.seriesMetaFetched = function(data) { +SeriesMeta.prototype.seriesMetaFetched = function (data) { /* Some shows are standalone and have no seasons */ if (data.total_seasons != 0) { $('
  • ', { - 'class': 'series-seasons', - 'html' : data.total_seasons + ' Seasons' + 'class': 'series-seasons', + 'html' : data.total_seasons + ' Seasons', }).insertBefore(this.$seriesEpisodes); } @@ -33,10 +33,10 @@ SeriesMeta.prototype.seriesMetaFetched = function(data) { if (data.series_logo) { var isOnion = $('.onion-series-page').length > 0; - var logo = isOnion ? data.series_logo_3x1 : data.series_logo; + var logo = isOnion ? data.series_logo_3x1 : data.series_logo; $('', { - 'src' : logo, - 'alt' : data.series_name + 'src' : logo, + 'alt' : data.series_name, }).appendTo(this.$seriesImage); } }; diff --git a/bulbs/videos/static/videos/js/series/series-meta/series-meta.test.js b/bulbs/videos/static/videos/js/series/series-meta/series-meta.test.js index 5954f70d..3bd3cdb6 100644 --- a/bulbs/videos/static/videos/js/series/series-meta/series-meta.test.js +++ b/bulbs/videos/static/videos/js/series/series-meta/series-meta.test.js @@ -1,8 +1,8 @@ -describe('SeriesMeta', function() { +describe('SeriesMeta', function () { var SeriesMeta = require('./series-meta'); var seriesContainer; - beforeEach(function() { + beforeEach(function () { seriesContainer = $('
    ') .append('
    ') .append('
    ') @@ -13,38 +13,38 @@ describe('SeriesMeta', function() { $('body').append(seriesContainer); }); - afterEach(function() { + afterEach(function () { seriesContainer.remove(); }); - describe('#seriesMetaFetched', function() { + describe('#seriesMetaFetched', function () { var seriesMeta, data; - beforeEach(function() { + beforeEach(function () { data = { series_description: 'AV Undercover description', series_name: 'AV Undercover', series_logo: 'www.picture.com/regular-picture', - series_logo_3x1: 'www.picture.com/three-by-one' + series_logo_3x1: 'www.picture.com/three-by-one', }; TestHelper.stub(SeriesMeta.prototype, 'fetchSeriesMeta'); seriesMeta = new SeriesMeta(); seriesMeta.seriesMetaFetched(data); }); - it('populates the series description', function() { + it('populates the series description', function () { var seriesDescriptionHtml = seriesMeta.$seriesDescription.html(); var expected = data.series_description; expect(seriesDescriptionHtml).to.eql(expected); }); - it('populates the series title', function() { + it('populates the series title', function () { var seriesTitleHtml = seriesMeta.$seriesTitle.html(); var expected = data.series_name; expect(seriesTitleHtml).to.eql(expected); }); - it('populates the series logo', function() { + it('populates the series logo', function () { var seriesLogoSrc = $('.series-image img').attr('src'); var expected = data.series_logo; expect(seriesLogoSrc).to.eql(expected); @@ -57,7 +57,7 @@ describe('SeriesMeta', function() { $('body').append('
    '); data = { series_logo: 'www.picture.com/regular-picture', - series_logo_3x1: 'www.picture.com/three-by-one' + series_logo_3x1: 'www.picture.com/three-by-one', }; TestHelper.stub(SeriesMeta.prototype, 'fetchSeriesMeta'); seriesMeta = new SeriesMeta(); diff --git a/bulbs/videos/static/videos/js/series/series-page/series-page.js b/bulbs/videos/static/videos/js/series/series-page/series-page.js index cf0fab13..38aa8959 100644 --- a/bulbs/videos/static/videos/js/series/series-page/series-page.js +++ b/bulbs/videos/static/videos/js/series/series-page/series-page.js @@ -1,4 +1,4 @@ -SeriesPage = function() { +SeriesPage = function () { this.$seriesGrid = $('#series-video-list'); this.seriesSlug = this.$seriesGrid.data('series-slug'); this.videohubBase = this.$seriesGrid.data('videohub-base'); @@ -7,11 +7,11 @@ SeriesPage = function() { this.fetchSeriesVideos(sourceUrl); }; -SeriesPage.prototype.fetchSeriesVideos = function(sourceUrl) { +SeriesPage.prototype.fetchSeriesVideos = function (sourceUrl) { $.getJSON(sourceUrl, this.seriesVideosFetched.bind(this)); }; -SeriesPage.prototype.seriesVideosFetched = function(data) { +SeriesPage.prototype.seriesVideosFetched = function (data) { this.latestEpisode = new LatestEpisode(data.results); }; diff --git a/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.js b/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.js index 074f0ba0..4c14dd7b 100644 --- a/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.js +++ b/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.js @@ -33,7 +33,7 @@ SeriesVideoGrid.prototype.initNextListener = function () { }; SeriesVideoGrid.prototype.carouselStateChanged = function (eventObject) { - var detailObj = eventObject.originalEvent.detail + var detailObj = eventObject.originalEvent.detail; if (detailObj.desc !== 'next') { return; } @@ -49,31 +49,31 @@ SeriesVideoGrid.prototype.appendVideos = function (videos) { videos .forEach(function (video) { - var videoTitle = video.title; - var videoHref = '/v/' + video.id; - var posterSource = that.bettyUrl + '/' + video.poster.id + '/16x9/480.jpg'; + var videoTitle = video.title; + var videoHref = '/v/' + video.id; + var posterSource = that.bettyUrl + '/' + video.poster.id + '/16x9/480.jpg'; - var anchor = $('',{ - 'class' : 'video-item', - 'href' : videoHref, - 'data-track-action' : 'Single Series: Episodes', - 'data-track-label' : videoHref, - 'html': $('
    ',{ - 'class' : 'content', - 'html' : '
    ', - }).add($('

    ',{ - 'html' : videoTitle - })) - }); + var anchor = $('',{ + 'class' : 'video-item', + 'href' : videoHref, + 'data-track-action' : 'Single Series: Episodes', + 'data-track-label' : videoHref, + 'html': $('

    ',{ + 'class' : 'content', + 'html' : '
    ', + }).add($('

    ',{ + 'html' : videoTitle, + })), + }); - if (that.$seriesGrid.length > 0) { - anchor.appendTo(that.$seriesGrid); - } + if (that.$seriesGrid.length > 0) { + anchor.appendTo(that.$seriesGrid); + } - if (that.$carouselItemContainer.length > 0) { - $('').html(anchor).appendTo(that.$carouselItemContainer); - } - }); + if (that.$carouselItemContainer.length > 0) { + $('').html(anchor).appendTo(that.$carouselItemContainer); + } + }); }; module.exports = SeriesVideoGrid; diff --git a/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.test.js b/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.test.js index c156aaee..04f6de86 100644 --- a/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.test.js +++ b/bulbs/videos/static/videos/js/series/series-video-grid/series-video-grid.test.js @@ -1,9 +1,9 @@ -describe('SeriesVideoGrid', function() { +describe('SeriesVideoGrid', function () { var SeriesVideoGrid = require('./series-video-grid'); var videos = [ { id: 5400, title: 'A Show About Music', poster: { id: 1234 } }, - { id: 6000, title: 'A Show About Movies', poster: { id: 1235 } } + { id: 6000, title: 'A Show About Movies', poster: { id: 1235 } }, ]; var seriesGrid; @@ -13,7 +13,7 @@ describe('SeriesVideoGrid', function() { context('normal functionality', function () { - beforeEach(function() { + beforeEach(function () { bettyUrl = 'http://i.onionstatic.com'; seriesGrid = $('

    '); @@ -22,27 +22,27 @@ describe('SeriesVideoGrid', function() { seriesVideoGrid = new SeriesVideoGrid(videos); }); - it('adds a link for every video series', function() { + it('adds a link for every video series', function () { var links = seriesVideoGrid.$seriesGrid.find('a'); - links.each(function(index, link) { + links.each(function (index, link) { expect($(link).attr('href')).to.equal('/v/' + videos[index].id); expect($(link).find('p').html()).to.equal(videos[index].title); }); }); - it('adds a title for every video series', function() { + it('adds a title for every video series', function () { var title = seriesVideoGrid.$seriesGrid.find('a p'); - title.each(function(index, title) { + title.each(function (index, title) { expect($(title).html()).to.equal(videos[index].title); }); }); - it('adds a poster image url for every video series', function() { + it('adds a poster image url for every video series', function () { var poster = seriesVideoGrid.$seriesGrid.find('a img'); - poster.each(function(index, poster) { + poster.each(function (index, poster) { expect($(poster).attr('src')).to.equal(bettyUrl + '/' + videos[index].poster.id + '/16x9/480.jpg'); }); }); @@ -50,7 +50,7 @@ describe('SeriesVideoGrid', function() { context('should fail when', function () { - it('not provided betty url data attr', function() { + it('not provided betty url data attr', function () { seriesGrid = $('
    '); $('body').append(seriesGrid); var subject = sinon.spy(SeriesVideoGrid); diff --git a/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.js b/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.js index 9206b5be..8a29115d 100644 --- a/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.js +++ b/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.js @@ -1,4 +1,4 @@ -LatestEpisode = function(videos) { +LatestEpisode = function (videos) { this.$videoPlayer = $('bulbs-video'); this.$latestVideoTitle = $('#latest-video-title'); @@ -16,15 +16,15 @@ LatestEpisode = function(videos) { this.$latestVideoShareTools.attr('share-title', this.latestVideoTitle); $('', { - 'href' : this.latestEpisodeHref, - 'data-track-action' : 'Single Series: Latest Episode Title', - 'data-track-label' : this.latestEpisodeHref, - 'html' : '

    ' + this.latestVideoTitle + '

    ' + 'href' : this.latestEpisodeHref, + 'data-track-action' : 'Single Series: Latest Episode Title', + 'data-track-label' : this.latestEpisodeHref, + 'html' : '

    ' + this.latestVideoTitle + '

    ', }).appendTo(this.$latestVideoTitle); if (videos[0].description) { - $('

    ' + videos[0].description + '

    ') + $('

    ' + videos[0].description + '

    ') .appendTo(this.$latestVideoDescription); } diff --git a/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.test.js b/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.test.js index fdae564f..5dee0bef 100644 --- a/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.test.js +++ b/bulbs/videos/static/videos/js/series/series-video-latest-episode/series-video-latest-episode.test.js @@ -1,4 +1,4 @@ -describe('LatestEpisode', function() { +describe('LatestEpisode', function () { var LatestEpisode = require('./series-video-latest-episode'); var videos = [ @@ -6,77 +6,72 @@ describe('LatestEpisode', function() { id: 5400, title: 'A Show About Music', poster: { id: 1234 }, - description: 'it sucks' + description: 'it sucks', }, - { id: 6000, title: 'A Show About Movies', poster: { id: 1235 } } + { id: 6000, title: 'A Show About Movies', poster: { id: 1235 } }, ]; - var videoPlayer; - var videohubBaseUrl = 'http://onionstudios.com'; var videoPlayer = $(''); var latestVideoTitle = '
    '; var latestVideoDescription = '
    '; - var latestVideoShareTools = ''; + var latestVideoShareTools = ''; context('normal functionality', function () { - beforeEach(function() { + beforeEach(function () { $('body').append(videoPlayer); $('body').append(latestVideoTitle); $('body').append(latestVideoDescription); $('body').append(latestVideoShareTools); - latestEpisode = new LatestEpisode(videos); + new LatestEpisode(videos); // eslint-disable-line no-new }); - afterEach(function() { + afterEach(function () { videoPlayer.remove(); $('#latest-video-title').remove(); $('#latest-video-description').remove(); $('share-tools').remove(); }); - it('adds most recent video in series to player', function() { + it('adds most recent video in series to player', function () { var expected = videohubBaseUrl + '/video/' + videos[0].id + '.json'; expect($(videoPlayer).attr('src')).to.equal(expected); }); - it('appends the latest video title', function() { - var videoTitle = $('#latest-video-title h2').html() - expect(videoTitle).to.equal("A Show About Music"); + it('appends the latest video title', function () { + var videoTitle = $('#latest-video-title h2').html(); + expect(videoTitle).to.equal('A Show About Music'); }); - it('appends the latest video description', function() { - var videoDescription = $('#latest-video-description p').html() - expect(videoDescription).to.equal("it sucks"); + it('appends the latest video description', function () { + var videoDescription = $('#latest-video-description p').html(); + expect(videoDescription).to.equal('it sucks'); }); describe('share-tools', function () { - it('appends the latest video title', function() { + it('appends the latest video title', function () { var videoShareToolsTitle = $('.latest-video-share-tools').attr('share-title'); - expect(videoShareToolsTitle).to.equal("A Show About Music"); + expect(videoShareToolsTitle).to.equal('A Show About Music'); }); - it('appends the latest video url', function() { + it('appends the latest video url', function () { var videoShareToolsUrl = $('.latest-video-share-tools').attr('share-url'); - expect(videoShareToolsUrl).to.equal("http://foo.bar/v/5400"); + expect(videoShareToolsUrl).to.equal('http://foo.bar/v/5400'); }); }); }); context('should fail when', function () { - it('not provided videohub base url', function() { + it('not provided videohub base url', function () { videoPlayer = $(''); $('body').append(videoPlayer); var subject = sinon.spy(LatestEpisode); expect(function () { - new subject(videos); + new subject(videos); // eslint-disable-line no-new }).to.throw('LatestEpisode requires bulbs-video to have a videohub base url.'); $('bulbs-video').remove(); }); diff --git a/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.js b/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.js index 7134324d..1777131d 100644 --- a/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.js +++ b/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.js @@ -14,15 +14,15 @@ SeriesVideoList.prototype.seriesFetched = function (data) { data .forEach(function (series) { $('
  • ',{ - 'data-track-action' : 'Series Flyout: Browse', - 'data-track-label' : '/series/' + series.slug, + 'data-track-action': 'Series Flyout: Browse', + 'data-track-label': '/series/' + series.slug, 'html': $('',{ - 'class' : '', - 'href' : '/series/' + series.slug, - 'html' : series.name, - }) + 'class': '', + href: '/series/' + series.slug, + html: series.name, + }), }).appendTo(that.$seriesList); }); }; -module.exports = SeriesVideoList; \ No newline at end of file +module.exports = SeriesVideoList; diff --git a/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.test.js b/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.test.js index 3ecff40b..9bd35fd3 100644 --- a/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.test.js +++ b/bulbs/videos/static/videos/js/series/series-video-list/series-video-list.test.js @@ -1,37 +1,38 @@ -describe('SeriesVideoList', function() { +describe('SeriesVideoList', function () { var SeriesVideoList = require('./series-video-list'); var seriesList; - beforeEach(function() { + beforeEach(function () { seriesList = document.createElement('div'); seriesList.id = 'series-list'; $('body').append(seriesList); }); - afterEach(function() { + afterEach(function () { document.body.removeChild(seriesList); }); - describe('#seriesFetched', function() { - var seriesVideoList, data; + describe('#seriesFetched', function () { + var seriesVideoList; + var data; - beforeEach(function() { + beforeEach(function () { TestHelper.stub(SeriesVideoList.prototype, 'loadSeries'); data = [ { slug: 'av-undercover', name: 'AV Undercover' }, - { slug: 'polite-fight', name: 'Polite Fight' } + { slug: 'polite-fight', name: 'Polite Fight' }, ]; seriesVideoList = new SeriesVideoList(); seriesVideoList.seriesFetched(data); }); - it('adds a link for every video series', function() { + it('adds a link for every video series', function () { var links = seriesVideoList.$seriesList.find('li a'); - links.each(function(index, link) { + links.each(function (index, link) { expect($(link).attr('href')).to.equal('/series/' + data[index].slug); expect($(link).html()).to.equal(data[index].name); }); diff --git a/bulbs/videos/static/videos/js/series/video-detail-page/video-detail-page.js b/bulbs/videos/static/videos/js/series/video-detail-page/video-detail-page.js index db7f778c..d812317c 100644 --- a/bulbs/videos/static/videos/js/series/video-detail-page/video-detail-page.js +++ b/bulbs/videos/static/videos/js/series/video-detail-page/video-detail-page.js @@ -1,21 +1,22 @@ var SeriesVideoGrid = require('../series-video-grid/series-video-grid'); var VideoDetailSeriesMeta = require('../video-detail-series-meta/video-detail-series-meta'); +var CurrentEpisodeData = require('../current-episode-data/current-episode-data'); -VideoDetailPage = function() { +var VideoDetailPage = function () { this.$detailGrid = $('#detail-video-list'); this.currentVideoSrc = $('bulbs-video').attr('src'); this.videohubBase = this.$detailGrid.data('videohub-base'); this.fetchVideo(); }; -VideoDetailPage.prototype.fetchVideo = function() { +VideoDetailPage.prototype.fetchVideo = function () { $.getJSON(this.currentVideoSrc, this.videoDataFetched.bind(this)); }; -VideoDetailPage.prototype.videoDataFetched = function(videoObject) { +VideoDetailPage.prototype.videoDataFetched = function (videoObject) { var source = this.videohubBase + '/api/series/' + videoObject.series_slug + '/videos'; - new CurrentEpisodeData(videoObject); - new VideoDetailSeriesMeta(videoObject.series_slug); + new CurrentEpisodeData(videoObject); // eslint-disable-line no-new + new VideoDetailSeriesMeta(videoObject.series_slug); // eslint-disable-line no-new this.seriesVideoGrid = new SeriesVideoGrid(source, '#detail-video-list'); }; diff --git a/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.js b/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.js index 651c6651..eb62966d 100644 --- a/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.js +++ b/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.js @@ -1,4 +1,4 @@ -VideoDetailSeriesMeta = function (seriesSlug) { +var VideoDetailSeriesMeta = function (seriesSlug) { this.seriesSlug = seriesSlug; this.$detailGrid = $('#detail-video-list'); this.videohubBase = this.$detailGrid.data('videohub-base'); @@ -13,13 +13,13 @@ VideoDetailSeriesMeta = function (seriesSlug) { VideoDetailSeriesMeta.prototype.fetchSeriesMeta = function () { $.getJSON(this.source, this.seriesMetaFetched.bind(this)); -} +}; -VideoDetailSeriesMeta.prototype.seriesMetaFetched = function(data) { - if (data.total_seasons != 0) { +VideoDetailSeriesMeta.prototype.seriesMetaFetched = function (data) { + if (data.total_seasons !== 0) { $('
  • ', { - 'class': 'series-seasons', - 'html' : data.total_seasons + ' Seasons' + 'class': 'series-seasons', + html: data.total_seasons + ' Seasons', }).insertBefore(this.$seriesEpisodes); } @@ -36,8 +36,8 @@ VideoDetailSeriesMeta.prototype.seriesMetaFetched = function(data) { if (data.series_logo) { $('', { - 'src' : data.series_logo, - 'alt' : data.series_name + src: data.series_logo, + alt: data.series_name, }).appendTo(this.$seriesImage); } }; diff --git a/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.test.js b/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.test.js index 75ecd948..4b6e2d9e 100644 --- a/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.test.js +++ b/bulbs/videos/static/videos/js/series/video-detail-series-meta/video-detail-series-meta.test.js @@ -1,12 +1,12 @@ -describe('SeriesMeta', function() { +describe('SeriesMeta', function () { var VideoDetailSeriesMeta = require('./video-detail-series-meta'); var seriesSummary; - beforeEach(function() { - $('body').append( + beforeEach(function () { + $('body').append( '
    ' ); - seriesSummary = $('') + seriesSummary = $('') .append('