diff --git a/.eslintrc b/.eslintrc.json similarity index 92% rename from .eslintrc rename to .eslintrc.json index 4e2e743..c2e91d9 100644 --- a/.eslintrc +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": "airbnb/base", + "extends": ["airbnb-base"], "env": { "mocha": true, "node": true diff --git a/.travis.yml b/.travis.yml index c68d23e..5f5db60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ cache: directories: - node_modules node_js: - - "5" + - "6" diff --git a/README.md b/README.md index d2e4b47..e9dcf22 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ const soundsData = { // Alternatively, we can pass a configuration object. // All valid howler.js options can be used here. winGame: { - urls: [ + src: [ 'https://s3.amazonaws.com/bucketName/win_game.mp3', 'https://s3.amazonaws.com/bucketName/win_game.wav' ], @@ -68,7 +68,7 @@ const soundsData = { // - the start time of the sound, in milliseconds // - the duration of the sound, in milliseconds jumps: { - urls: [ 'https://s3.amazonaws.com/bucketName/jumps.mp3' ], + src: [ 'https://s3.amazonaws.com/bucketName/jumps.mp3' ], sprite: { lowJump: [0, 1000], longJump: [1000, 2500], diff --git a/package.json b/package.json index 25fa512..f109e1e 100644 --- a/package.json +++ b/package.json @@ -31,26 +31,31 @@ "author": "Joshua Comeau ", "license": "MIT", "dependencies": { - "howler": "^1.1.28" + "howler": "2.0.4" }, "devDependencies": { "babel": "^6.1.18", "babel-cli": "^6.2.0", "babel-core": "^6.2.1", - "babel-eslint": "^5.0.0-beta4", - "babel-istanbul": "^0.6.0", - "babel-loader": "^6.2.1", - "babel-plugin-add-module-exports": "^0.1.1", + "babel-eslint": "^7.2.3", + "babel-istanbul": "^0.12.2", + "babel-loader": "^7.1.2", + "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-transform-object-assign": "^6.3.13", "babel-preset-es2015": "^6.1.18", "babel-preset-stage-0": "^6.1.18", - "chai": "^3.2.0", + "babel-register": "^6.26.0", + "chai": "^4.1.2", "coveralls": "^2.11.8", - "eslint": "^1.10.3", - "eslint-config-airbnb": "^3.1.0", - "mocha": "^2.2.5", - "sinon": "^1.17.2", + "eslint": "^4.6.1", + "eslint-config-airbnb": "^15.1.0", + "eslint-plugin-import": "^2.7.0", + "jsdom": "^11.2.0", + "jsdom-global": "^3.0.2", + "mocha": "^3.5.2", + "sinon": "^3.2.1", "sinon-chai": "^2.8.0", - "webpack": "^1.12.11" + "webpack": "^3.5.6", + "whatwg-fetch": "^2.0.3" } } diff --git a/src/howler_integration.js b/src/howler_integration.js index 4aba412..2f8fe23 100644 --- a/src/howler_integration.js +++ b/src/howler_integration.js @@ -11,7 +11,7 @@ module.exports = { // Allow strings instead of objects, for when all that is needed is a URL if ( typeof soundOptions === 'string' ) { - soundOptions = { urls: [soundOptions] }; + soundOptions = {src: [soundOptions]}; } return { ...memo, [name]: new Howl(soundOptions) } diff --git a/test/howlerFixSetup.js b/test/howlerFixSetup.js new file mode 100644 index 0000000..691b730 --- /dev/null +++ b/test/howlerFixSetup.js @@ -0,0 +1,11 @@ +const { HowlerGlobal } = require('howler'); +var jsdom = require('jsdom'); +// Create a fake DOM for testing with $.ajax +global.window = new jsdom.JSDOM().window; +global.document = window.document; +global.Audio = window.Audio; +global.HTMLElement = window.HTMLElement; +global.HTMLMediaElement = window.HTMLMediaElement; +global.HTMLMediaElement.prototype.load = function () {}; + +global.HowlerGlobal = HowlerGlobal; diff --git a/test/index.js b/test/index.js index c391d85..1b4dc89 100644 --- a/test/index.js +++ b/test/index.js @@ -18,11 +18,11 @@ chai.use(sinonChai); const soundsData = { endTurn: 'path/to/sound.mp3', winGame: { - urls: ['path/to/other_sound.mp3'], + src: ['path/to/other_sound.mp3'], volume: 0.75 }, allSounds: { - urls: ['sound1.mp3'], + src: ['sound1.mp3'], sprite: { boom: [0, 1000], bang: [1500, 2000], @@ -55,14 +55,14 @@ describe('howlerIntegration', () => { it('set up the URL for endTurn (string-based)', () => { expected = [ 'path/to/sound.mp3' ]; - actual = sounds.endTurn._urls; + actual = sounds.endTurn._src; expect(expected).to.deep.equal(actual); }); it('set up the URL for winGame (property-based)', () => { expected = [ 'path/to/other_sound.mp3' ]; - actual = sounds.winGame._urls; + actual = sounds.winGame._src; expect(expected).to.deep.equal(actual); }); diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 0000000..4b7a2ed --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1,5 @@ +--require test/howlerFixSetup.js +--compilers js:babel-register +--require jsdom-global/register +--require whatwg-fetch +test/index.js diff --git a/webpack.config.base.js b/webpack.config.base.js index 0470ee7..2275ab8 100644 --- a/webpack.config.base.js +++ b/webpack.config.base.js @@ -1,5 +1,3 @@ -var webpack = require('webpack'); - module.exports = { output: { library: 'ReduxSounds', @@ -7,17 +5,17 @@ module.exports = { }, module: { - loaders: [ + rules: [ { - test: /\.js$/, - loader: 'babel', - exclude: /node_modules/, - include: /src/ + test: /\.js$/, + use: { loader: 'babel-loader' }, + exclude: /node_modules/, + include: /src/ } ] }, resolve: { - extensions: ['', '.js'] + extensions: ['.js'] } -} +}; diff --git a/webpack.config.development.js b/webpack.config.development.js index d2674f7..94ff13c 100644 --- a/webpack.config.development.js +++ b/webpack.config.development.js @@ -1,12 +1,9 @@ -'use strict'; +const webpack = require('webpack'); +const baseConfig = require('./webpack.config.base'); -var webpack = require('webpack'); -var baseConfig = require('./webpack.config.base'); - -var config = Object.create(baseConfig); +const config = Object.create(baseConfig); config.plugins = [ - new webpack.optimize.OccurrenceOrderPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') }) diff --git a/webpack.config.production.js b/webpack.config.production.js index 54bd086..4ab20ea 100644 --- a/webpack.config.production.js +++ b/webpack.config.production.js @@ -1,12 +1,12 @@ -'use strict'; +const webpack = require('webpack'); +const baseConfig = require('./webpack.config.base'); -var webpack = require('webpack'); -var baseConfig = require('./webpack.config.base'); - -var config = Object.create(baseConfig); +const config = Object.create(baseConfig); config.plugins = [ - new webpack.optimize.OccurrenceOrderPlugin(), + new webpack.LoaderOptionsPlugin({ + minimize: true + }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),