Skip to content

Commit

Permalink
Merge 7273ebd into 4627ea5
Browse files Browse the repository at this point in the history
  • Loading branch information
ridvanaltun committed Aug 31, 2021
2 parents 4627ea5 + 7273ebd commit c60edd2
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 20 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Development](#development)
- [Commit Messages](#commit-messages)
- [Code Quality](#code-quality)
- [Testing](#testing)
- [Available Scripts](#available-scripts)
- [Special Thanks](#special-thanks)
- [License](#license)
Expand Down Expand Up @@ -80,6 +81,12 @@ Keeping code quality as good is a hard job in normally. Therefore, we are using

In short, run `npm run lint` command.

## Testing

Writing tests is boring but also necessary. If you want to write a test look at other tests and don't forget apply proxy over Travis because of ridvanaltun/eksi-sozluk#16. The proxy server running over my local environment therefore sometimes it is not reacable, test fails on Travis when my local environment is turned off or the proxy server is turned off.

I accept PRs by myself anyway so running tests over Travis is not a problem for a contributor. You can run tests on your local anytime.

## Available Scripts

```bash
Expand Down
12 changes: 11 additions & 1 deletion __tests__/agenda.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Agenda Test', () => {
test('Getting Agenda', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/debe.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Debe Test', () => {
test('Getting Debe', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/entries.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Entries Test', () => {
test('Getting Entries', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/entry.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Entry Test', () => {
test('Getting Entry By Id', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/questions.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Questions Test', () => {
test('Getting Questions in Agenda', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/tags.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Tags Test', () => {
test('Getting Tags', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/todayInHistory.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('Today in History Test', () => {
test('Getting Today in History', () => {
Expand Down
12 changes: 11 additions & 1 deletion __tests__/user.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const { EksiSozluk } = require('../src/index')
const HttpsProxyAgent = require('https-proxy-agent')

const instance = new EksiSozluk()
let httpClient = {};

// use proxy over Travis
if (process.env.TRAVIS) {
httpClient = {
httpsAgent: new HttpsProxyAgent(process.env.HTTP_PROXY)
}
}

const instance = new EksiSozluk({httpClient})

describe('User Test', () => {
test('Getting User', () => {
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = {
roots: ['__tests__/'],
// This line solves: Cross origin http://localhost forbidden
// @see https://github.com/axios/axios/issues/1754
testEnvironment: 'node'
testEnvironment: 'node',
testTimeout: 10000 // default 5 secs, we are using 10 secs
}
18 changes: 8 additions & 10 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"axios": "^0.21.1",
"cheerio": "^1.0.0-rc.10",
"form-data": "^4.0.0",
"https-proxy-agent": "^5.0.0",
"moment": "^2.29.1",
"object-assign-deep": "^0.4.0",
"querystring": "^0.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/EksiSozluk.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EksiSozluk extends EksiGuest {
)

// make http client ready
const httpClient = axios.create(_options.httpClient)
const httpClient = axios.create({..._options.httpClient, ...options.httpClient})

super(httpClient)

Expand Down

0 comments on commit c60edd2

Please sign in to comment.