Skip to content

Commit

Permalink
Merge pull request #113 from ClarityCafe/fix-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
Ayane Satomi authored Oct 24, 2019
2 parents 0eccd35 + fe724f0 commit 8d5b4fe
Show file tree
Hide file tree
Showing 15 changed files with 1,791 additions and 380 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@

sudo: false
dist: bionic
language: node_js
cache: yarn

node_js:
- "10"
- "12"
- '10'
- '12'

before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build

install:
- yarn
- yarn

script:
- yarn lint && yarn test
- yarn lint && yarn coverage

after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
5 changes: 1 addition & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module.exports = {
displayName: 'ts-jest',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['<rootDir>/tests/*.test.ts'],
setupFiles: ['<rootDir>/tests/jest.setup.ts']
testEnvironment: 'node'
};
9 changes: 2 additions & 7 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ const BASE_SITE_LIST: SiteList = {
backupURL: data =>
`https://www.pixiv.net/member_illust.php?mode=medium&illust_id=${data.data.pixiv_id}`,
getRating(data: string) {
const match = data.match(
/<div class="introduction-modal"><p class="title">(.*?)<\/p>/i
);

if (!match) return RATINGS[1];

return match[1].toLowerCase().includes('r-18') ? RATINGS[3] : RATINGS[1];
const isR18 = /r18/gi.test(data);
return isR18 ? RATINGS[3] : RATINGS[1];
}
},
'8': {
Expand Down
10 changes: 6 additions & 4 deletions lib/sagiri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ export default class Sagiri {
});

if (this.getRating)
returnData.map(async dataSet => ({
...dataSet,
rating: await this.resolveRating(dataSet.url)
}));
return Promise.all(
returnData.map(async dataSet => ({
...dataSet,
rating: await this.resolveRating(dataSet.url)
}))
);

return returnData;
}
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"url": "https://github.com/ClarityCafe/issues"
},
"scripts": {
"test": "jest --coverage",
"test": "jest",
"coverage": "jest --coverage",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
"prebuild": "yarn lint && yarn test",
"build": "tsc",
Expand Down Expand Up @@ -50,11 +51,11 @@
"devDependencies": {
"@types/dotenv": "6.1.1",
"@types/jest": "24.0.19",
"@types/lodash.ismatch": "^4.4.6",
"@types/node": "12.11.6",
"@types/node-fetch": "2.5.2",
"@typescript-eslint/eslint-plugin": "2.5.0",
"@typescript-eslint/parser": "2.5.0",
"dotenv": "8.2.0",
"eslint": "6.5.1",
"eslint-config-clarity": "0.2.11",
"eslint-plugin-import": "2.18.2",
Expand All @@ -64,6 +65,9 @@
"eslint-plugin-sift": "0.3.0",
"jest": "24.9.0",
"jsdoc-to-markdown": "5.0.2",
"lodash.ismatch": "4.4.0",
"nock": "11.4.0",
"parse-multipart": "^1.0.4",
"prettier": "1.18.2",
"replace": "1.1.1",
"ts-jest": "24.1.0",
Expand Down
20 changes: 0 additions & 20 deletions tests/file.test.ts

This file was deleted.

1 change: 0 additions & 1 deletion tests/fixtures/.env.sample

This file was deleted.

Loading

0 comments on commit 8d5b4fe

Please sign in to comment.