forked from risan/quran-json
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test to check generated files
- Loading branch information
Showing
11 changed files
with
3,109 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json | ||
tanzil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
__tests__ | ||
scripts | ||
tanzil | ||
.eslintignore | ||
.eslintrc.js | ||
.travis.yml | ||
jest.config.js | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dist: xenial | ||
language: node_js | ||
node_js: | ||
- 11 | ||
cache: npm | ||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* global expect:false, test:false */ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const range = require("lodash.range"); | ||
const util = require("util"); | ||
|
||
const access = util.promisify(fs.access); | ||
|
||
const jsonPath = p => path.resolve(__dirname, `../json`, p); | ||
|
||
const isJsonExists = async p => { | ||
await access(jsonPath(p), fs.constants.F_OK); | ||
|
||
return true; | ||
}; | ||
|
||
const allJsonPairExists = async files => { | ||
const pairs = [ | ||
...files, | ||
...files.map(file => file.replace(/\.json$/i, ".pretty.json")) | ||
]; | ||
|
||
const res = await Promise.all(pairs.map(file => isJsonExists(file))); | ||
|
||
return !res.includes(false); | ||
}; | ||
|
||
test("it generate surah json files", async () => { | ||
const res = await allJsonPairExists(["surahs.json"]); | ||
expect(res).toBe(true); | ||
}); | ||
|
||
test("it generate quran json files", async () => { | ||
const res = await allJsonPairExists([ | ||
"quran/en-id.json", | ||
"quran/en.json", | ||
"quran/id.json", | ||
"quran/text.json" | ||
]); | ||
|
||
expect(res).toBe(true); | ||
}); | ||
|
||
test("it generate surah json files", async () => { | ||
const res = await allJsonPairExists( | ||
range(1, 115).map(num => `surahs/${num}.json`) | ||
); | ||
|
||
expect(res).toBe(true); | ||
}); | ||
|
||
test("it generate translations json files", async () => { | ||
const res = await allJsonPairExists([ | ||
"translations/en.json", | ||
"translations/id.json" | ||
]); | ||
|
||
expect(res).toBe(true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
testEnvironment: "node", | ||
verbose: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "quran-json", | ||
"version": "1.0.0", | ||
"description": "Quran text and translations in JSON format", | ||
"version": "1.0.1", | ||
"description": "Quran text and translations in JSON format.", | ||
"keywords": [ | ||
"tanzil", | ||
"translations", | ||
|
@@ -15,7 +15,7 @@ | |
"author": { | ||
"name": "Risan Bagja Pradana", | ||
"email": "[email protected]", | ||
"url": "https://risan.io" | ||
"url": "https://bagja.net" | ||
}, | ||
"main": "json/quran/en-id.pretty.json", | ||
"repository": { | ||
|
@@ -26,22 +26,23 @@ | |
"build": "scripts/build.js", | ||
"lint": "eslint ./", | ||
"lint-fix": "eslint ./ --fix", | ||
"prepublishOnly": "npm run lint && npm run build" | ||
"prepublishOnly": "npm run lint && npm run test", | ||
"test": "npm run build && jest" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.9.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^3.3.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"prettier": "^1.15.2" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"dependencies": { | ||
"jest": "^23.6.0", | ||
"lodash.groupby": "^4.6.0", | ||
"lodash.range": "^3.2.0", | ||
"prettier": "^1.15.2", | ||
"rimraf": "^2.6.2", | ||
"write-to-file": "^1.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.