Permalink
Browse files

tmp commit

  • Loading branch information...
omgimanerd committed Sep 5, 2017
1 parent 05356be commit 8bfd6949bb4fc4b3df59bbab895bb957da56b5d1
Showing with 242 additions and 9 deletions.
  1. +2 −1 .eslintrc.js
  2. +6 −2 package.json
  3. +6 −1 server/api.js
  4. +30 −0 test/api_test.js
  5. +198 −5 yarn.lock
View
@@ -6,7 +6,8 @@ module.exports = {
'env': {
'browser': true,
'es6': true,
'node': true
'node': true,
'mocha': true
},
'extends': 'eslint:recommended',
'parserOptions': {
View
@@ -4,7 +4,7 @@
"description": "A web server that fetches data from the News API and formats it for display in the terminal.",
"main": "server.js",
"repository": "git@github.com:omgimanerd/getnews.tech",
"author": "omgimanerd <alvin@omgimanerd.tech>",
"author": "Alvin Lin <alvin@omgimanerd.tech> (http://omgimanerd.tech)",
"license": "Apache-2.0",
"dependencies": {
"bluebird": "^3.5.0",
@@ -34,6 +34,10 @@
"winston": "^2.3.1"
},
"devDependencies": {
"eslint": "^4.4.1"
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^4.4.1",
"mocha": "^3.5.0",
"nock": "^9.0.14"
}
}
View
@@ -159,5 +159,10 @@ const fetchArticles = source => {
}
module.exports = exports = {
BAD_SOURCE, shortenUrl, fetchSources, fetchArticles
BAD_SOURCE,
NEWS_API_BASE_URL,
URL_SHORTENER_BASE_URL,
shortenUrl,
fetchSources,
fetchArticles
}
View
@@ -0,0 +1,30 @@
/**
* @fileoverview Test suite for api.js
* @author alvin@omgimanerd.tech (Alvin Lin)
*/
const chai = require('chai')
const chaiAsPromised = require('chai-as-promised')
const nock = require('nock')
chai.use(chaiAsPromised)
chai.should()
process.env.NEWS_API_KEY = 'news_api_key'
process.env.URL_SHORTENER_API_KEY = 'key'
const api = require('../server/api')
describe('shortenUrl()', () => {
before(() => {
nock(api.URL_SHORTENER_BASE_URL).post().reply(200, {
id: 'test'
})
})
it('should work', () => {
return api.shortenUrl('asdf').should.eventually.equal('no')
})
after(() => nock.restore())
})
Oops, something went wrong.

0 comments on commit 8bfd694

Please sign in to comment.