Skip to content

Commit

Permalink
correct promise-based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Jul 14, 2018
1 parent 832f1bd commit 5de1f78
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 14 deletions.
50 changes: 43 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build:dist": "webpack --progress --colors --env=prod --define process.env.NODE_ENV=production && cp loader.css dist",
"build:electron:linux": "webpack --progress --colors --env.LINUX=true --config=webpack.config.electron.prod.js && cp index.prod.html dist/index.html",
"build:electron": "webpack --progress --colors --config=webpack.config.electron.prod.js && cp index.prod.html dist/index.html",
"test": "mocha --require babel-register",
"test": "mocha --require babel-register --require babel-polyfill --timeout 10000 --prof",
"pack": "electron-builder --dir -c.extraMetadata.main=dist/bundle.electron.js",
"dist": "babel-node electron-builder -c.extraMetadata.main=dist/bundle.electron.js",
"build:linux": "electron-builder -c.extraMetadata.main=dist/bundle.electron.js --linux",
Expand Down Expand Up @@ -64,6 +64,7 @@
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
Expand Down
33 changes: 27 additions & 6 deletions test/pitchfork.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,46 @@ import {
import { expect } from 'chai';

describe('Pitchfork API tests', () => {
it('gets best new albums', () => {
getBestNewAlbums().
it('gets best new albums', async () => {
const result = await getBestNewAlbums().
then(albums => {

return albums;
})
.catch(error => {
console.error(error);
expect(false).to.equal(true);
});

expect(result).to.be.an('array');
result.forEach(entry => {
expect(entry).to.be.an('object').that.has.all.keys('thumbnail',
'artist',
'title',
'reviewUrl',
'genres',
'score',
'abstract',
'review');
});
});

it('gets best new tracks', () => {
getBestNewTracks().
it('gets best new tracks', async () => {
const result = await getBestNewTracks().
then(tracks => {

return tracks;
})
.catch(error => {
console.error(error);
expect(false).to.equal(true);
});

expect(result).to.be.an('array');
result.forEach(entry => {
expect(entry).to.be.an('object').that.has.all.keys('thumbnail',
'artist',
'title',
'reviewUrl',
'review');
});
});
});

0 comments on commit 5de1f78

Please sign in to comment.