From cf7181b3419b6acff78abd07f9b0d42e7a95f03a Mon Sep 17 00:00:00 2001 From: Jake Champion Date: Thu, 12 Oct 2017 16:30:48 +0100 Subject: [PATCH] Update codebase for obt7 (#112) * use chai should explicitly * use if statements to improve readability * use forEach instead of filter as we are not using the returned array for anything at all * remove unneeded semicolon * move instance method to static method as it does not use any instance properties or methods. * fix indentation * Wrap cases in blocks to stop lexical declarations being hoisted to start of switch statement * Add a default case to capture scenarios where and ad has a type we not match against * Fix linting issues in sass * use proclaim instead of chai as to conform with all other origami components * Remove features not needed for obt7 * fix linting issues * Update circle.yml * Update ads.js * Update ads.js --- circle.yml | 6 +- karma.conf.js | 116 ------------ package-lock.json | 52 ++++++ package.json | 26 +-- src/js/ads.js | 34 ++-- src/js/helpers/get-rendition.js | 2 +- src/js/helpers/supported-formats.js | 6 +- src/js/playlist.js | 4 +- src/js/video.js | 26 +-- src/scss/_ads.scss | 4 +- src/scss/_info.scss | 2 + src/scss/_placeholder.scss | 2 + test/ads.test.js | 56 +++--- test/helpers/get-rendition.test.js | 34 ++-- test/helpers/supported-formats.test.js | 7 +- test/playlist.test.js | 35 ++-- test/video.test.js | 233 +++++++++++++------------ 17 files changed, 305 insertions(+), 340 deletions(-) delete mode 100644 karma.conf.js create mode 100644 package-lock.json diff --git a/circle.yml b/circle.yml index 434fa4f..5987749 100644 --- a/circle.yml +++ b/circle.yml @@ -1,10 +1,8 @@ machine: - pre: - - sudo curl --output /usr/local/bin/phantomjs https://s3.amazonaws.com/circle-downloads/phantomjs-2.1.1 node: version: 6 post: - - npm install -g origami-build-tools + - npm install -g origami-build-tools@^7 dependencies: override: - obt install @@ -12,5 +10,5 @@ dependencies: - "node_modules" test: override: - - obt test - obt verify + - obt test diff --git a/karma.conf.js b/karma.conf.js deleted file mode 100644 index 986f9c6..0000000 --- a/karma.conf.js +++ /dev/null @@ -1,116 +0,0 @@ -/*eslint-env node*/ - -const BowerPlugin = require('bower-webpack-plugin'); -const path = require('path'); -const cwd = process.cwd(); - -module.exports = function(config) { - config.set({ - - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: '', - - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'sinon', 'chai'], - - - plugins: [ - 'karma-mocha', - 'karma-sinon', - 'karma-chai', - 'karma-firefox-launcher', - 'karma-webpack' - ], - - - // list of files / patterns to load in the browser - files: [ - 'http://cdn.polyfill.io/v2/polyfill.js?features=fetch&flags=gated', - 'test/**/*.test.js' - ], - - - // list of files to exclude - exclude: [ - ], - - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - 'test/**/*.test.js': ['webpack'] - }, - - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress'], - - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - - // start these browsers - // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['Firefox'], - - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: true, - - webpack: { - quiet: true, - module: { - loaders: [ - { - test: /\.js$/, - exclude: /node_modules/, - loaders: [ - 'babel?optional[]=runtime', - 'imports?define=>false' - ] - }, - { - test: /\.json$/, - loader: 'json' - } - ], - noParse: [ - /\/sinon\.js/, - ] - }, - resolve: { - root: [path.join(cwd, 'bower_components')] - }, - plugins: [ - new BowerPlugin({ - includes: /\.js$/ - }) - ] - }, - - // Hide webpack output logging - webpackMiddleware: { - noInfo: true - } - - }); -}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..2a32bd6 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,52 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "assertion-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", + "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", + "dev": true + }, + "chai": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz", + "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", + "dev": true, + "requires": { + "assertion-error": "1.0.2", + "deep-eql": "0.1.3", + "type-detect": "1.0.0" + } + }, + "deep-eql": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", + "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", + "dev": true, + "requires": { + "type-detect": "0.1.1" + }, + "dependencies": { + "type-detect": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", + "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", + "dev": true + } + } + }, + "karma-chai": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/karma-chai/-/karma-chai-0.1.0.tgz", + "integrity": "sha1-vuWtQEAFF4Ea40u5RfdikJEIt5o=", + "dev": true + }, + "type-detect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", + "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=", + "dev": true + } + } +} diff --git a/package.json b/package.json index fc631d1..352055c 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,3 @@ { - "private": true, - "scripts": { - "test": "./node_modules/karma/bin/karma start karma.conf.js" - }, - "devDependencies": { - "babel-loader": "^5.3.2", - "babel-runtime": "^5.6.15", - "bower-webpack-plugin": "^0.1.8", - "chai": "^3.5.0", - "imports-loader": "^0.6.4", - "json-loader": "^0.5.4", - "karma": "^0.13.15", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^1.0.1", - "karma-cli": "^0.1.1", - "karma-firefox-launcher": "^1.0.0", - "karma-mocha": "^1.3.0", - "karma-phantomjs-launcher": "^1.0.0", - "karma-sinon": "^1.0.4", - "karma-webpack": "^1.7.0", - "mocha": "^3.3.0", - "origami-build-tools": "^5.0.0", - "sinon": "^2.0.0-pre.5", - "webpack": "^1.12.2" - } + "private": true } diff --git a/src/js/ads.js b/src/js/ads.js index d82629e..83a14c6 100644 --- a/src/js/ads.js +++ b/src/js/ads.js @@ -238,8 +238,10 @@ class VideoAds { // Initialize the video. Must be done via a user action on mobile devices. this.video.videoEl.load(); - this.overlayEl && this.overlayEl.removeEventListener('click', this.playAdEventHandler); - this.overlayEl && this.video.containerEl.removeChild(this.overlayEl); + if (this.overlayEl) { + this.overlayEl.removeEventListener('click', this.playAdEventHandler); + this.video.containerEl.removeChild(this.overlayEl); + } delete this.overlayEl; } @@ -263,7 +265,7 @@ class VideoAds { }; switch (adEvent.type) { - case google.ima.AdEvent.Type.LOADED: + case google.ima.AdEvent.Type.LOADED: { // This is the first event sent for an ad - it is possible to // determine whether the ad is a video ad or an overlay. if (!ad.isLinear()) { @@ -272,7 +274,8 @@ class VideoAds { this.playUserVideo(); } break; - case google.ima.AdEvent.Type.STARTED: + } + case google.ima.AdEvent.Type.STARTED: { // This event indicates the ad has started - the video player // can adjust the UI, for example display a pause button and // remaining time. @@ -288,7 +291,8 @@ class VideoAds { // const remainingTime = this.adsManager.getRemainingTime(); } break; - case google.ima.AdEvent.Type.COMPLETE: + } + case google.ima.AdEvent.Type.COMPLETE: { options.detail.action = 'adComplete'; const endEvent = new CustomEvent('oTracking.event', options); @@ -298,22 +302,28 @@ class VideoAds { // Would be used to clear the interval } break; + } // Add tracking for when an advert becomes skippable, and whether it's skipped - case google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED: + case google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED: { options.detail.action = 'adSkippable'; const skippableEvent = new CustomEvent('oTracking.event', options); document.body.dispatchEvent(skippableEvent); break; - case google.ima.AdEvent.Type.SKIPPED: + } + case google.ima.AdEvent.Type.SKIPPED: { options.detail.action = 'adSkip'; const skipEvent = new CustomEvent('oTracking.event', options); document.body.dispatchEvent(skipEvent); break; + } + default: { + throw new Error('adEvent has type ' + adEvent.type + ', which is not handled by adEventHandler'); + } } } - reportError(error) { + reportError(error) { // eslint-disable-line class-methods-use-this document.body.dispatchEvent(new CustomEvent('oErrors.log', { bubbles: true, detail: { error: error } })); } @@ -325,14 +335,18 @@ class VideoAds { const message = `${actualError.getErrorCode()}, ${actualError.getType()}, ${actualError.getMessage()}, ${actualError.getVastErrorCode()}`; this.reportError(new Error(message)); - this.adsManager && this.adsManager.destroy(); + if (this.adsManager) { + this.adsManager.destroy(); + } this.video.containerEl.removeChild(this.adContainerEl); if (this.overlayEl) { this.overlayEl.removeEventListener('click', this.playAdEventHandler); this.video.containerEl.removeChild(this.overlayEl); delete this.overlayEl; } - this.video.placeholderEl && this.video.placeholderEl.removeEventListener('click', this.playAdEventHandler); + if (this.video.placeholderEl) { + this.video.placeholderEl.removeEventListener('click', this.playAdEventHandler); + } this.video.opts.advertising = false; this.startAds(); } diff --git a/src/js/helpers/get-rendition.js b/src/js/helpers/get-rendition.js index 3f53acd..6df641a 100644 --- a/src/js/helpers/get-rendition.js +++ b/src/js/helpers/get-rendition.js @@ -29,6 +29,6 @@ function getRendition(renditions, options) { }); return appropriateRendition || orderedRenditions.pop(); -}; +} export default getRendition; diff --git a/src/js/helpers/supported-formats.js b/src/js/helpers/supported-formats.js index e47ca15..a501e35 100644 --- a/src/js/helpers/supported-formats.js +++ b/src/js/helpers/supported-formats.js @@ -19,8 +19,10 @@ function supportedFormats () { const supported = []; try { - Object.keys(formats).filter(format => { - formats[format].some(type => testEl.canPlayType(type)) && supported.push(format); + Object.keys(formats).forEach(format => { + if (formats[format].some(type => testEl.canPlayType(type))) { + supported.push(format); + } }); } catch(e) { } diff --git a/src/js/playlist.js b/src/js/playlist.js index 0e1e073..670f7dc 100644 --- a/src/js/playlist.js +++ b/src/js/playlist.js @@ -53,7 +53,9 @@ class Playlist { }; return this.opts.player.update(nextVideoOpts).then(() => { - this.opts.player.videoEl && this.opts.player.videoEl.play(); + if (this.opts.player.videoEl) { + this.opts.player.videoEl.play(); + } }); } } diff --git a/src/js/video.js b/src/js/video.js index db9829d..7d7c827 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -46,11 +46,13 @@ function fireEvent(action, video, extraDetail = {}) { function shouldDispatch(progress) { - const relevantProgressPoints = [8, 9, 10, 11, 12, - 23, 24, 25, 26, 27, - 48, 49, 50, 51, 52, - 73, 74, 75, 76, 77, - 100]; + const relevantProgressPoints = [ + 8, 9, 10, 11, 12, + 23, 24, 25, 26, 27, + 48, 49, 50, 51, 52, + 73, 74, 75, 76, 77, + 100 + ]; return relevantProgressPoints.includes(progress); } @@ -138,8 +140,6 @@ class Video { this.containerEl = el; // amount of the video, in milliseconds, that has actually been 'watched' this.amountWatched = 0; - // stores the timestamp of when the current play was started - this.playStart; this.fireWatchedEvent = unloadListener.bind(this); this.visibilityListener = visibilityListener.bind(this); @@ -339,7 +339,9 @@ class Video { this.videoEl.focus(); this.containerEl.removeChild(this.placeholderEl); - this.infoPanel && this.infoPanel.teardown(); + if (this.infoPanel) { + this.infoPanel.teardown(); + } delete this.placeholderEl; delete this.placeholderImageEl; @@ -353,11 +355,15 @@ class Video { this.placeholderImageEl.src = this.posterImage; } - this.infoPanel && this.infoPanel.update(); + if (this.infoPanel) { + this.infoPanel.update(); + } } update(newOpts) { - this.videoEl && this.videoEl.pause(); + if (this.videoEl) { + this.videoEl.pause(); + } this.clearCurrentlyPlaying(); this.opts = Object.assign(this.opts, { data: null }, newOpts); diff --git a/src/scss/_ads.scss b/src/scss/_ads.scss index 858948e..8c2c38d 100644 --- a/src/scss/_ads.scss +++ b/src/scss/_ads.scss @@ -24,8 +24,10 @@ > div, > div > iframe { + // sass-lint:disable no-important width: 100% !important; height: 100% !important; + // sass-lint:enable no-important } } @@ -52,4 +54,4 @@ } } -} \ No newline at end of file +} diff --git a/src/scss/_info.scss b/src/scss/_info.scss index 7fc47de..5808232 100644 --- a/src/scss/_info.scss +++ b/src/scss/_info.scss @@ -66,7 +66,9 @@ background-color: oColorsGetPaletteColor('claret'); color: oColorsGetPaletteColor('white'); &:empty { + // sass-lint:disable no-important display: none !important; + // sass-lint:enable no-important } } diff --git a/src/scss/_placeholder.scss b/src/scss/_placeholder.scss index 995d10f..7e69ee4 100644 --- a/src/scss/_placeholder.scss +++ b/src/scss/_placeholder.scss @@ -12,8 +12,10 @@ .o-video__placeholder { background: oColorsGetPaletteColor('slate'); color: oColorsGetPaletteColor('white'); + // sass-lint:disable no-vendor-prefixes -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + // sass-lint:enable no-vendor-prefixes } .o-video__placeholder-image { diff --git a/test/ads.test.js b/test/ads.test.js index ef0c70f..5d1f180 100644 --- a/test/ads.test.js +++ b/test/ads.test.js @@ -1,6 +1,10 @@ -/* global describe, it, beforeEach, afterEach, google */ -const Ads = require('./../src/js/ads'); -const sinon = require('sinon/pkg/sinon'); +/* global google */ +/* eslint-env mocha */ +/* eslint-disable no-unused-expressions */ + +import Ads from './../src/js/ads'; +import sinon from 'sinon/pkg/sinon'; +import proclaim from 'proclaim'; describe('Ads', () => { @@ -28,17 +32,17 @@ describe('Ads', () => { }); it('should have all ad event handlers', () => { - Ads.prototype.adsManagerLoadedHandler.should.be.a('function'); - Ads.prototype.adErrorHandler.should.be.a('function'); - Ads.prototype.adEventHandler.should.be.a('function'); - Ads.prototype.contentPauseRequestHandler.should.be.a('function'); - Ads.prototype.contentResumeRequestHandler.should.be.a('function'); + proclaim.isTypeOf(Ads.prototype.adsManagerLoadedHandler, 'function'); + proclaim.isTypeOf(Ads.prototype.adErrorHandler, 'function'); + proclaim.isTypeOf(Ads.prototype.adEventHandler, 'function'); + proclaim.isTypeOf(Ads.prototype.contentPauseRequestHandler, 'function'); + proclaim.isTypeOf(Ads.prototype.contentResumeRequestHandler, 'function'); }); it('should add the video advertising script if the configuration parameter is passed', () => { return ads.loadAdsLibrary() .then(() => { - document.querySelector('[src="//imasdk.googleapis.com/js/sdkloader/ima3.js"]').should.exist; + proclaim.ok(document.querySelector('[src="//imasdk.googleapis.com/js/sdkloader/ima3.js"]')); }); }); @@ -46,9 +50,9 @@ describe('Ads', () => { it('should set up ads', () => { ads.setUpAds(); - ads.adContainerEl.should.be.an('htmldivelement'); - ads.adDisplayContainer.should.be.an('object'); - ads.adsLoader.should.be.an('object'); + proclaim.equal(ads.adContainerEl.nodeName, 'DIV'); + proclaim.isTypeOf(ads.adDisplayContainer, 'object'); + proclaim.isTypeOf(ads.adsLoader, 'object'); }); it('should set up event handlers', () => { @@ -58,8 +62,8 @@ describe('Ads', () => { ads.setUpAds(); - google.ima.AdsLoader.prototype.addEventListener.calledWith(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, ads.adsManagerLoadedHandler).should.equal(true); - google.ima.AdsLoader.prototype.addEventListener.calledWith(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, ads.adsManagerLoadedHandler).should.equal(true); + proclaim.equal(google.ima.AdsLoader.prototype.addEventListener.calledWith(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, ads.adsManagerLoadedHandler), true); + proclaim.equal(google.ima.AdsLoader.prototype.addEventListener.calledWith(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, ads.adsManagerLoadedHandler), true); google.ima.AdsLoader.prototype.addEventListener = realAddEventListener; }); @@ -77,8 +81,8 @@ describe('Ads', () => { }; ads.adsManagerLoadedHandler(adsManagerLoadedEvent); - ads.adsManager.should.be.an('object'); - adsManagerLoadedEvent.getAdsManager.called.should.equal(true); + proclaim.isTypeOf(ads.adsManager, 'object'); + proclaim.equal(adsManagerLoadedEvent.getAdsManager.called, true); }); }); @@ -101,7 +105,7 @@ describe('Ads', () => { it('should play ad', () => { ads.playAdEventHandler(); - ads.adContainerEl.classList.toString().should.contain('o-video__ad'); + proclaim.include(ads.adContainerEl.classList.toString(), 'o-video__ad'); }); }); @@ -112,7 +116,7 @@ describe('Ads', () => { name: 'Authers Note' } }; - ads.getVideoBrand().should.equal('Authers Note'); + proclaim.equal(ads.getVideoBrand(), 'Authers Note'); }); }); @@ -120,8 +124,8 @@ describe('Ads', () => { it('should set state correctly at different phases', () => { const realAddEventListener = google.ima.AdsLoader.prototype.addEventListener; - ads.adsLoaded.should.equal(false); - ads.adsCompleted.should.equal(false); + proclaim.equal(ads.adsLoaded, false); + proclaim.equal(ads.adsCompleted, false); // Substitute in a mock addEventListener into the AdsLoader which captures // listeners so they can be fed fake events @@ -147,24 +151,24 @@ describe('Ads', () => { handler(adsManagerLoadedEvent); } - ads.adsLoaded.should.equal(true); - ads.adsCompleted.should.equal(false); + proclaim.equal(ads.adsLoaded, true); + proclaim.equal(ads.adsCompleted, false); // Trigger the ads manager all-playing-done listener for (const handler of mockAdsManager.eventListeners[google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED]) { handler(); } - ads.adsLoaded.should.equal(true); - ads.adsCompleted.should.equal(true); + proclaim.equal(ads.adsLoaded, true); + proclaim.equal(ads.adsCompleted, true); // Trigger the ads manager another-ad-is-playing listener for (const handler of mockAdsManager.eventListeners[google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED]) { handler(); } - ads.adsLoaded.should.equal(true); - ads.adsCompleted.should.equal(false); + proclaim.equal(ads.adsLoaded, true); + proclaim.equal(ads.adsCompleted, false); // Restore the original event listener google.ima.AdsLoader.prototype.addEventListener = realAddEventListener; diff --git a/test/helpers/get-rendition.test.js b/test/helpers/get-rendition.test.js index 84e1c46..628e326 100644 --- a/test/helpers/get-rendition.test.js +++ b/test/helpers/get-rendition.test.js @@ -1,34 +1,46 @@ -/* global describe, it */ -const getRendition = require('./../../src/js/helpers/get-rendition'); +/* eslint-env mocha */ +/* eslint-disable no-unused-expressions */ + +import getRendition from './../../src/js/helpers/get-rendition'; const renditions = require('./../fixtures/media-api-1.json').renditions; +import proclaim from 'proclaim'; describe('Get Appropriate Renditions', () => { const supportedFormats = ['h264']; it('should exist', () => { - getRendition.should.exist; + proclaim.ok(getRendition); }); it('should get largest if no width supplied', () => { - getRendition(renditions, { supportedFormats: supportedFormats }) - .should.have.property('url', 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); + proclaim.equal( + getRendition(renditions, { supportedFormats: supportedFormats })['url'], + 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001' + ); }); it('should get rendition of at least the width supplied', () => { - getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 600 }) - .should.have.property('url', 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625604001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); + proclaim.equal( + getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 600 })['url'], + 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625604001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001' + ); }); it('should get smallest rendition if width is small', () => { - getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 390 }) - .should.have.property('url', 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625602001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); + proclaim.equal( + getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 390 })['url'], + 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625602001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001' + ); }); it('should get largest rendition if width is bigger than any renditions', () => { - getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 2048 }) - .should.have.property('url', 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); + proclaim.equal( + getRendition(renditions, { supportedFormats: supportedFormats, optimumvideowidth: 2048 })['url'], + 'https://bcsecure04-a.akamaihd.net/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001' + ); }); }); +/* eslint-enable no-unused-expressions */ diff --git a/test/helpers/supported-formats.test.js b/test/helpers/supported-formats.test.js index cc4c8ce..926dec0 100644 --- a/test/helpers/supported-formats.test.js +++ b/test/helpers/supported-formats.test.js @@ -1,10 +1,11 @@ -/* global describe, it */ -const supportedFormats = require('./../../src/js/helpers/supported-formats'); +/* eslint-env mocha */ +import supportedFormats from './../../src/js/helpers/supported-formats'; +import proclaim from 'proclaim'; describe('Supported Formats', () => { it('should exist', () => { - supportedFormats.should.exist; + proclaim.ok(supportedFormats); }); }); diff --git a/test/playlist.test.js b/test/playlist.test.js index 6fbdaca..806f01d 100644 --- a/test/playlist.test.js +++ b/test/playlist.test.js @@ -1,7 +1,10 @@ -/* global describe, it, beforeEach */ -const Player = require('../src/js/video'); -const Subject = require('../src/js/playlist'); -const sinon = require('sinon/pkg/sinon'); +/* eslint-env mocha */ +/* eslint-disable no-unused-expressions */ + +import Player from '../src/js/video'; +import Subject from '../src/js/playlist'; +import sinon from 'sinon/pkg/sinon'; +import proclaim from 'proclaim'; function createPlayer () { const stub = sinon.createStubInstance(Player); @@ -27,10 +30,10 @@ describe('Playlist', () => { it('can instantiate', () => { const instance = new Subject({ player, queue: [] }); - instance.should.be.an.instanceOf(Subject); + proclaim.isInstanceOf(instance, Subject); - instance.opts.should.exist; - instance.opts.player.should.equal(player); + proclaim.ok(instance.opts); + proclaim.equal(instance.opts.player, player); }); it('selects currently playing video from playlist', () => { @@ -38,13 +41,13 @@ describe('Playlist', () => { const instance = new Subject({ player, queue }); - instance.currentIndex.should.equal(1); + proclaim.equal(instance.currentIndex, 1); }); it('starts the playlist if the current video does not match', () => { const instance = new Subject({ player, queue, autoplay: true }); - instance.currentIndex.should.equal(0); + proclaim.equal(instance.currentIndex, 0); sinon.assert.calledOnce(player.update); }); @@ -75,9 +78,9 @@ describe('Playlist', () => { it('calls the next in the queue', () => { const instance = new Subject({ player, queue, autoplay: true }); - instance.currentIndex.should.equal(0); + proclaim.equal(instance.currentIndex, 0); instance.next(); - instance.currentIndex.should.equal(1); + proclaim.equal(instance.currentIndex, 1); }); }); @@ -85,9 +88,9 @@ describe('Playlist', () => { it('calls the previous in the queue', () => { const instance = new Subject({ player, queue, autoplay: true }); - instance.currentIndex.should.equal(0); + proclaim.equal(instance.currentIndex, 0); instance.prev(); - instance.currentIndex.should.equal(instance.opts.queue.length - 1); + proclaim.equal(instance.currentIndex, instance.opts.queue.length - 1); }); }); @@ -96,11 +99,11 @@ describe('Playlist', () => { const instance = new Subject({ player, queue }); instance.goto(10); - instance.currentIndex.should.equal(0); + proclaim.equal(instance.currentIndex, 0); sinon.assert.calledWith(player.update, sinon.match({ id: 'foo' })); instance.goto(-10); - instance.currentIndex.should.equal(3); + proclaim.equal(instance.currentIndex, 3); sinon.assert.calledWith(player.update, sinon.match({ id: 'qux' })); }); @@ -111,7 +114,7 @@ describe('Playlist', () => { instance.goto(1); - instance.cache.hasOwnProperty('abc').should.be.true; + proclaim.isTrue(instance.cache.hasOwnProperty('abc')); }); it('retrieves next video from cache when available', () => { diff --git a/test/video.test.js b/test/video.test.js index 8dfc3b3..6194b53 100644 --- a/test/video.test.js +++ b/test/video.test.js @@ -1,8 +1,11 @@ -/* global describe, context, it, beforeEach, afterEach, should */ -const Video = require('./../src/js/video'); -const mediaApiResponse1 = require('./fixtures/media-api-1.json'); -const mediaApiResponse2 = require('./fixtures/media-api-2.json'); -const sinon = require('sinon/pkg/sinon'); +/* eslint-env mocha */ +/* eslint-disable no-unused-expressions */ + +import Video from './../src/js/video'; +import mediaApiResponse1 from './fixtures/media-api-1.json'; +import mediaApiResponse2 from './fixtures/media-api-2.json'; +import sinon from 'sinon/pkg/sinon'; +import proclaim from 'proclaim'; describe('Video', () => { @@ -24,31 +27,31 @@ describe('Video', () => { describe('constructor', () => { it('should be able to instantiate', () => { const video = new Video(containerEl); - video.should.be.an.instanceOf(Video); + proclaim.isInstanceOf(video, Video); - video.opts.should.exist; - video.opts.id.should.eql('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); + proclaim.ok(video.opts); + proclaim.equal(video.opts.id, 'eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); - video.targeting.should.exist; - video.targeting.site.should.eql('/5887/ft.com'); - video.targeting.position.should.eql('video'); - video.targeting.sizes.should.eql('592x333|400x225'); - video.targeting.videoId.should.eql('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); + proclaim.ok(video.targeting); + proclaim.equal(video.targeting.site, '/5887/ft.com'); + proclaim.equal(video.targeting.position, 'video'); + proclaim.equal(video.targeting.sizes, '592x333|400x225'); + proclaim.equal(video.targeting.videoId, 'eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); - video.containerEl.should.eql(containerEl); - video.containerEl.hasAttribute('data-o-video-js').should.be.true; + proclaim.equal(video.containerEl, containerEl); + proclaim.isTrue(video.containerEl.hasAttribute('data-o-video-js')); }); it('should set default options', () => { const video = new Video(containerEl); - video.opts.advertising.should.eql(false); - video.opts.classes.should.be.an.instanceOf(Array); - video.opts.classes.should.contain('o-video__video'); - should.equal(video.opts.optimumwidth, null); - video.opts.placeholder.should.eql(false); - video.opts.playsinline.should.eql(false); - should.equal(video.opts.data, null); + proclaim.equal(video.opts.advertising, false); + proclaim.isInstanceOf(video.opts.classes, Array); + proclaim.include(video.opts.classes, 'o-video__video'); + proclaim.equal(video.opts.optimumwidth, null); + proclaim.equal(video.opts.placeholder, false); + proclaim.equal(video.opts.playsinline, false); + proclaim.equal(video.opts.data, null); }); it('should allow setting options through attribute', () => { @@ -59,27 +62,27 @@ describe('Video', () => { containerEl.setAttribute('data-o-video-show-captions', true); const video = new Video(containerEl); - video.opts.optimumwidth.should.eql(300); - video.opts.placeholder.should.eql(true); - video.opts.placeholderInfo.should.eql(['title', 'description']); - video.opts.classes.should.contain('a-class'); - video.opts.classes.should.contain('another-class'); - video.opts.showCaptions.should.eql(true); + proclaim.equal(video.opts.optimumwidth, 300); + proclaim.equal(video.opts.placeholder, true); + proclaim.deepEqual(video.opts.placeholderInfo, ['title', 'description']); + proclaim.include(video.opts.classes, 'a-class'); + proclaim.include(video.opts.classes, 'another-class'); + proclaim.equal(video.opts.showCaptions, true); }); }); describe('#init', () => { it('should return an array of video instances', () => { const videos = Video.init(); - videos.length.should.eql(1); - videos[0].should.be.an.instanceOf(Video); + proclaim.equal(videos.length, 1); + proclaim.isInstanceOf(videos[0], Video); }); it('should create Video objects only once', () => { const videos = Video.init(); - videos.length.should.eql(1); + proclaim.equal(videos.length, 1); const videos2 = Video.init(); - videos2.length.should.eql(0); + proclaim.equal(videos2.length, 0); }); }); @@ -105,8 +108,8 @@ describe('Video', () => { const video = new Video(containerEl); return video.getData().then(() => { - fetchStub.calledWithMatch('4084879507001').should.eql(true); - video.videoData.id.should.eql('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); + proclaim.equal(fetchStub.calledWithMatch('4084879507001'), true); + proclaim.equal(video.videoData.id, 'eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); }); }); @@ -115,8 +118,8 @@ describe('Video', () => { const video = new Video(containerEl); return video.getData().then(() => { - fetchStub.calledWithMatch('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526').should.eql(true); - video.videoData.id.should.eql('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); + proclaim.equal(fetchStub.calledWithMatch('eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'), true); + proclaim.equal(video.videoData.id, 'eebe9cb5-8d4c-3bd7-8dd9-50e869e2f526'); }); }); }); @@ -130,12 +133,12 @@ describe('Video', () => { video.posterImage = 'mockimage'; video.addVideo(); - video.videoEl.should.be.an.instanceOf(HTMLElement); - video.videoEl.parentElement.should.equal(containerEl); - video.videoEl.poster.should.include('mockimage'); - video.videoEl.src.should.equal('http://url.mock/'); - video.videoEl.controls.should.equal(true); - video.videoEl.hasAttribute('playsinline').should.be.false; + proclaim.isInstanceOf(video.videoEl, HTMLElement); + proclaim.deepEqual(video.videoEl.parentElement, containerEl); + proclaim.include(video.videoEl.poster, 'mockimage'); + proclaim.deepEqual(video.videoEl.src, 'http://url.mock/'); + proclaim.deepEqual(video.videoEl.controls, true); + proclaim.isFalse(video.videoEl.hasAttribute('playsinline')); }); @@ -146,7 +149,7 @@ describe('Video', () => { }); video.addVideo(); - video.videoEl.className.should.equal('class-one class-two o-video__video'); + proclaim.deepEqual(video.videoEl.className, 'class-one class-two o-video__video'); }); it('should support the playsinline option set to true', () => { @@ -156,8 +159,8 @@ describe('Video', () => { }); video.addVideo(); - video.videoEl.hasAttribute('playsinline').should.be.true; - video.videoEl.hasAttribute('webkit-playsinline').should.be.true; + proclaim.isTrue(video.videoEl.hasAttribute('playsinline')); + proclaim.isTrue(video.videoEl.hasAttribute('webkit-playsinline')); }); it('should support the playsinline option set to false', () => { @@ -167,8 +170,8 @@ describe('Video', () => { }); video.addVideo(); - video.videoEl.hasAttribute('playsinline').should.be.false; - video.videoEl.hasAttribute('webkit-playsinline').should.be.false; + proclaim.isFalse(video.videoEl.hasAttribute('playsinline')); + proclaim.isFalse(video.videoEl.hasAttribute('webkit-playsinline')); }); it('should set event handlers', () => { @@ -178,7 +181,7 @@ describe('Video', () => { Element.prototype.addEventListener = addEventListenerSpy; video.addVideo(); - addEventListenerSpy.alwaysCalledOn(video.videoEl).should.equal(true); + proclaim.deepEqual(addEventListenerSpy.alwaysCalledOn(video.videoEl), true); addEventListenerSpy.calledWith('playing', video.pauseOtherVideos); addEventListenerSpy.calledWith('playing', video.markPlayStart); addEventListenerSpy.calledWith('pause', video.updateAmountWatched); @@ -223,8 +226,8 @@ describe('Video', () => { return video.init().then(() => { video.addVideo(); - containerEl.querySelector('video > track').getAttribute('kind').should.equal('captions'); - containerEl.querySelector('video > track').getAttribute('src').should.equal('https://next-media-api.ft.com/v1/5393611350001.vtt'); + proclaim.deepEqual(containerEl.querySelector('video > track').getAttribute('kind'), 'captions'); + proclaim.deepEqual(containerEl.querySelector('video > track').getAttribute('src'), 'https://next-media-api.ft.com/v1/5393611350001.vtt'); }); }); @@ -233,7 +236,7 @@ describe('Video', () => { containerEl.setAttribute('data-o-video-show-captions', 'true'); const video = new Video(containerEl); - video.addVideo.should.throw(); + proclaim.throws(video.addVideo); }); it('shouldn‘t add a track element if specified', () => { @@ -242,7 +245,7 @@ describe('Video', () => { const video = new Video(containerEl); video.addVideo(); - should.equal(containerEl.querySelector('video > track'), null); + proclaim.equal(containerEl.querySelector('video > track'), null); }); it('should use the captionsUrl from the API if not passed in directly', () => { @@ -250,8 +253,8 @@ describe('Video', () => { const video = new Video(containerEl); return video.init().then(() => { - containerEl.querySelector('video > track').getAttribute('kind').should.equal('captions'); - containerEl.querySelector('video > track').getAttribute('src').should.equal('https://next-media-api.ft.com/v1/5393611350001.vtt'); + proclaim.deepEqual(containerEl.querySelector('video > track').getAttribute('kind'), 'captions'); + proclaim.deepEqual(containerEl.querySelector('video > track').getAttribute('src'), 'https://next-media-api.ft.com/v1/5393611350001.vtt'); }); }); @@ -260,7 +263,7 @@ describe('Video', () => { const video = new Video(containerEl); return video.init().then(() => { - should.equal(containerEl.querySelector('video > track'), null); + proclaim.equal(containerEl.querySelector('video > track'), null); }); }); }); @@ -310,8 +313,8 @@ describe('Video', () => { window.dispatchEvent(new Event(unloadEventName, { cancelable: true })); const eventDetail = trackingSpy.lastCall.args[0].detail; - eventDetail.amount.should.equal(1235); - eventDetail.amountPercentage.should.equal(16); + proclaim.deepEqual(eventDetail.amount, 1235); + proclaim.deepEqual(eventDetail.amountPercentage, 16); }); it('should not include time watched if tab isn’t visible (while video playing)', () => { @@ -332,8 +335,8 @@ describe('Video', () => { window.dispatchEvent(new Event(unloadEventName, { cancelable: true })); const eventDetail = trackingSpy.lastCall.args[0].detail; - eventDetail.amount.should.equal(10); - eventDetail.amountPercentage.should.equal(5); + proclaim.deepEqual(eventDetail.amount, 10); + proclaim.deepEqual(eventDetail.amountPercentage, 5); clock.restore(); }); @@ -359,8 +362,8 @@ describe('Video', () => { window.dispatchEvent(new Event(unloadEventName, { cancelable: true })); const eventDetail = trackingSpy.lastCall.args[0].detail; - eventDetail.amount.should.equal(10); - eventDetail.amountPercentage.should.equal(5); + proclaim.deepEqual(eventDetail.amount, 10); + proclaim.deepEqual(eventDetail.amountPercentage, 5); clock.restore(); }); @@ -391,14 +394,14 @@ describe('Video', () => { video.posterImage = 'mockimage'; video.addPlaceholder(); - video.placeholderEl.should.be.an.instanceOf(HTMLElement); - video.placeholderEl.parentElement.should.equal(containerEl); - video.placeholderEl.classList.contains('o-video__placeholder').should.equal(true); + proclaim.isInstanceOf(video.placeholderEl, HTMLElement); + proclaim.deepEqual(video.placeholderEl.parentElement, containerEl); + proclaim.deepEqual(video.placeholderEl.classList.contains('o-video__placeholder'), true); - video.placeholderImageEl.should.be.an.instanceOf(HTMLImageElement); - video.placeholderImageEl.parentElement.should.equal(video.placeholderEl); - video.placeholderImageEl.src.should.include('mockimage'); - video.placeholderImageEl.classList.contains('o-video__placeholder-image').should.equal(true); + proclaim.isInstanceOf(video.placeholderImageEl, HTMLImageElement); + proclaim.deepEqual(video.placeholderImageEl.parentElement, video.placeholderEl); + proclaim.include(video.placeholderImageEl.src, 'mockimage'); + proclaim.deepEqual(video.placeholderImageEl.classList.contains('o-video__placeholder-image'), true); }); it('should be able to create a placeholder with an info panel', () => { @@ -411,18 +414,18 @@ describe('Video', () => { video.videoData = mediaApiResponse1; video.addPlaceholder(); - video.infoPanel.should.exist; + proclaim.ok(video.infoPanel); - video.infoPanel.infoEl.parentElement.should.equal(video.placeholderEl); + proclaim.deepEqual(video.infoPanel.infoEl.parentElement, video.placeholderEl); - video.infoPanel.titleEl.textContent.should.equal('Markets cautious, oil eases'); - video.infoPanel.titleEl.parentElement.should.equal(video.infoPanel.infoEl); + proclaim.deepEqual(video.infoPanel.titleEl.textContent, 'Markets cautious, oil eases'); + proclaim.deepEqual(video.infoPanel.titleEl.parentElement, video.infoPanel.infoEl); - video.infoPanel.descriptionEl.textContent.should.contain('Top stories in the markets'); - video.infoPanel.descriptionEl.parentElement.should.equal(video.infoPanel.infoEl); + proclaim.include(video.infoPanel.descriptionEl.textContent, 'Top stories in the markets'); + proclaim.deepEqual(video.infoPanel.descriptionEl.parentElement, video.infoPanel.infoEl); - video.infoPanel.brandEl.textContent.should.equal('Market Minute'); - video.infoPanel.brandEl.parentElement.should.equal(video.infoPanel.infoEl); + proclaim.deepEqual(video.infoPanel.brandEl.textContent, 'Market Minute'); + proclaim.deepEqual(video.infoPanel.brandEl.parentElement, video.infoPanel.infoEl); }); it('should be able to create an info panel when there is no brand name', () => { @@ -435,7 +438,7 @@ describe('Video', () => { video.videoData = Object.assign({}, mediaApiResponse1, { brand: null }); video.addPlaceholder(); - video.infoPanel.brandEl.textContent.should.equal(''); + proclaim.deepEqual(video.infoPanel.brandEl.textContent, ''); }); it('should be able to create a placeholder with a play button', () => { @@ -456,11 +459,11 @@ describe('Video', () => { const playButtonTextEl = playButtonEl.querySelector('.o-video__play-button-text'); const playIconEl = playButtonEl.querySelector('.o-video__play-button-icon'); - playButtonEl.should.exist; - playButtonTextEl.should.exist; - playIconEl.should.exist; - addEventListenerSpy.called.should.equal(true); - addEventListenerSpy.calledWith('click').should.equal(true); + proclaim.ok(playButtonEl); + proclaim.ok(playButtonTextEl); + proclaim.ok(playIconEl); + proclaim.deepEqual(addEventListenerSpy.called, true); + proclaim.deepEqual(addEventListenerSpy.calledWith('click'), true); addEventListenerSpy.calledOn(playButtonEl); Element.prototype.addEventListener = realAddEventListener; @@ -514,20 +517,20 @@ describe('Video', () => { const newOpts = { prop: 'new prop', id: mediaApiResponse2.id }; return video.update(newOpts).then(() => { - video.opts.prop.should.equal(newOpts.prop); - video.opts.id.should.equal(newOpts.id); + proclaim.deepEqual(video.opts.prop, newOpts.prop); + proclaim.deepEqual(video.opts.id, newOpts.id); }); }); it('updates the placeholder image and title', () => { const newOpts = { id: mediaApiResponse2.id }; - video.placeholderImageEl.src.should.include('5393611350001'); - video.infoPanel.titleEl.textContent.should.equal(mediaApiResponse1.title); + proclaim.include(video.placeholderImageEl.src, '5393611350001'); + proclaim.deepEqual(video.infoPanel.titleEl.textContent, mediaApiResponse1.title); return video.update(newOpts).then(() => { - video.placeholderImageEl.src.should.include('5394885102001'); - video.infoPanel.titleEl.textContent.should.equal(mediaApiResponse2.title); + proclaim.include(video.placeholderImageEl.src, '5394885102001'); + proclaim.deepEqual(video.infoPanel.titleEl.textContent, mediaApiResponse2.title); }); }); @@ -543,10 +546,10 @@ describe('Video', () => { const newOpts = { id: mediaApiResponse2.id }; - video.infoPanel.brandEl.textContent.should.equal('Market Minute'); + proclaim.deepEqual(video.infoPanel.brandEl.textContent, 'Market Minute'); return video.update(newOpts).then(() => { - video.infoPanel.brandEl.textContent.should.equal(''); + proclaim.deepEqual(video.infoPanel.brandEl.textContent, ''); }); }); }); @@ -567,12 +570,12 @@ describe('Video', () => { it('updates the video source and poster', () => { const newOpts = { id: mediaApiResponse2.id }; - video.videoEl.poster.should.include('5393611350001'); - video.videoEl.src.should.include('/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); + proclaim.include(video.videoEl.poster, '5393611350001'); + proclaim.include(video.videoEl.src, '/34/47628783001/201704/970/47628783001_5393625770001_5393611350001.mp4?pubId=47628783001&videoId=5393611350001'); return video.update(newOpts).then(() => { - video.videoEl.poster.should.include('5394885102001'); - video.videoEl.src.should.include('/34/47628783001/201704/873/47628783001_5394886872001_5394885102001.mp4?pubId=47628783001&videoId=5394885102001'); + proclaim.include(video.videoEl.poster, '5394885102001'); + proclaim.include(video.videoEl.src, '/34/47628783001/201704/873/47628783001_5394886872001_5394885102001.mp4?pubId=47628783001&videoId=5394885102001'); }); }); @@ -586,11 +589,11 @@ describe('Video', () => { fetchStub.resetBehavior(); fetchStub.returns(Promise.resolve(resNoPoster)); - video.videoEl.poster.should.include('5393611350001'); + proclaim.include(video.videoEl.poster, '5393611350001'); const newOpts = { id: mediaApiResponse2.id }; return video.update(newOpts).then(() => { - video.videoEl.poster.should.equal(''); + proclaim.deepEqual(video.videoEl.poster, ''); }); }); @@ -606,8 +609,8 @@ describe('Video', () => { const newOpts = { id: mediaApiResponse2.id }; return video.update(newOpts).then(() => { const tracks = document.querySelectorAll('track'); - tracks.length.should.equal(1); - tracks[0].src.should.equal('https://next-media-api.ft.com/v1/5394885102001.vtt'); + proclaim.deepEqual(tracks.length, 1); + proclaim.deepEqual(tracks[0].src, 'https://next-media-api.ft.com/v1/5394885102001.vtt'); }); }); @@ -624,7 +627,7 @@ describe('Video', () => { const newOpts = { id: mediaApiResponse2.id }; return video.update(newOpts).then(() => { const tracks = document.querySelectorAll('track'); - tracks.length.should.equal(0); + proclaim.deepEqual(tracks.length, 0); }); }); }); @@ -663,13 +666,13 @@ describe('Video', () => { }); it('should return 0 if duration is not set', () => { - video.getProgress().should.equal(0); + proclaim.deepEqual(video.getProgress(), 0); }); it('should return the progress of the video as a percentage', () => { video.videoEl.duration = 200; video.videoEl.currentTime = 50; - video.getProgress().should.equal(25); + proclaim.deepEqual(video.getProgress(), 25); }); }); @@ -701,7 +704,7 @@ describe('Video', () => { video.getData().then(() => { video.addVideo(); - video.getTrackMode().should.eventually.equal('disabled'); + video.getTrackMode().then(mode => proclaim.equal(mode, 'disabled')); }); }); @@ -711,7 +714,7 @@ describe('Video', () => { video.getData().then(() => { video.addVideo(); - video.getTrackMode().should.eventually.equal(undefined); + video.getTrackMode().then(mode => proclaim.isUndefined(mode)); }); }); @@ -730,12 +733,12 @@ describe('Video', () => { }); it('should return 0 if duration is not set', () => { - video.getDuration().should.equal(0); + proclaim.deepEqual(video.getDuration(), 0); }); it('should return the duration of the video as a integer', () => { video.videoEl.duration = 22.46324646; - video.getDuration().should.equal(22); + proclaim.deepEqual(video.getDuration(), 22); }); }); @@ -768,7 +771,7 @@ describe('Video', () => { const video = new Video(containerEl); return video.getData() .then(() => { - video.posterImage.should.equal( + proclaim.deepEqual(video.posterImage, 'https://www.ft.com/__origami/service/image/v2/images/raw/' + 'https%3A%2F%2Fbcsecure01-a.akamaihd.net%2F13%2F47628783001%2F201704%2F970%2F47628783001_5393625566001_5393611350001-vs.jpg%3FpubId%3D47628783001%26videoId%3D5393611350001' + '?source=o-video&quality=low&fit=scale-down&width=300' @@ -781,7 +784,7 @@ describe('Video', () => { const video = new Video(containerEl); return video.getData() .then(() => { - video.rendition.pixelWidth.should.equal(480); + proclaim.deepEqual(video.rendition.pixelWidth, 480); }); }); @@ -798,9 +801,9 @@ describe('Video', () => { return video .getData() .then(() => { - video.videoData.prop.should.equal('val'); - video.videoData.videoStillUrl.should.equal('abc'); - video.videoData.renditions.length.should.equal(0); + proclaim.deepEqual(video.videoData.prop, 'val'); + proclaim.deepEqual(video.videoData.videoStillUrl, 'abc'); + proclaim.deepEqual(video.videoData.renditions.length, 0); }); }); @@ -813,10 +816,10 @@ describe('Video', () => { }; const videoDataShouldMatch = video => { - video.videoData.title.should.equal('Macron - What next?'); - video.videoData.standfirst.should.equal('President-elect\'s "pro-EU" and trade agenda'); - video.videoData.description.should.equal('Another \'great\' "quote here"'); - video.videoData.renditions.length.should.equal(0); + proclaim.deepEqual(video.videoData.title, 'Macron - What next?'); + proclaim.deepEqual(video.videoData.standfirst, 'President-elect\'s "pro-EU" and trade agenda'); + proclaim.deepEqual(video.videoData.description, 'Another \'great\' "quote here"'); + proclaim.deepEqual(video.videoData.renditions.length, 0); }; it('can deal with quotes when data passed via constructor', () => { @@ -840,3 +843,5 @@ describe('Video', () => { }); }); }); + +/* eslint-enable no-unused-expressions */ \ No newline at end of file