Skip to content

Commit

Permalink
Merge pull request #22 from unfoldingWord/feature-mcleanb-unitTests
Browse files Browse the repository at this point in the history
Feature/Enable Unit Tests
  • Loading branch information
RobH123 authored Sep 9, 2020
2 parents 32d26ec + c2d83b5 commit 3525480
Show file tree
Hide file tree
Showing 33 changed files with 1,372 additions and 3,213 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": [ "@babel/preset-env", "@babel/preset-react" ],
"plugins": [ "@babel/plugin-transform-runtime" ]
}
3 changes: 3 additions & 0 deletions __tests__/__snapshots__/tn-table-row-check.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`checkTN_TSVDataRow() should succeed 1`] = `undefined`;
45 changes: 45 additions & 0 deletions __tests__/tn-table-row-check.test.js

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

14 changes: 0 additions & 14 deletions babel.config.js

This file was deleted.

74 changes: 40 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,18 @@
"node": ">=4"
},
"scripts": {
"build": "react-scripts build",
"prepublishOnly": "rm -fr ./dist & babel ./src --out-dir ./dist -s inline",
"prepublishOnly": "rm -fr ./dist & babel ./src --out-dir ./dist -s inline && yarn test:unit",
"predeploy": "yarn styleguide:build",
"deploy": "gh-pages -d styleguide",
"postpublish": "yarn deploy",
"postpublish": "yarn deploy && git tag $npm_package_version && git push origin $npm_package_version",
"start": "styleguidist server",
"styleguide:build": "styleguidist build",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"nyc:report": "nyc report --reporter=json-summary --reporter=text",
"test": "start-test 6060 cypress:run && npm run nyc:report",
"build": "styleguidist build",
"test:unit": "eslint ./src && jest __tests__",
"test": "yarn test:unit && cat ./coverage/lcov.info | coveralls",
"create-coverage-badge": "bash scripts/create-badge-json.sh"
},
"dependencies": {
"@date-io/core": "^2.9.0",
"@material-ui/core": "^4.5.1",
"@material-ui/icons": "^4.5.1",
"axios": "^0.20.0",
"axios-cache-adapter": "^2.5.0",
"js-yaml-parser": "^1.0.0",
Expand All @@ -38,36 +33,40 @@
"lodash": "^4.17.19",
"material-table": "^1.51.1",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-bootstrap": "^1.2.2",
"react-dom": "^16.9.0",
"react-markdown": "^4.0.6",
"react-scripts": "^3.4.1",
"react-styleguidist": "^11.0.10",
"usfm-grammar": "^2.0.0-beta.4",
"usfm-js": "^2.1.0",
"yaml": "^1.10.0"
},
"devDependencies": {
"@babel/cli": "^7.5.5",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.11.5",
"@babel/cli": "^7.5.0",
"@babel/core": "^7.4.5",
"@babel/plugin-transform-runtime": "^7.5.0",
"@babel/preset-env": "^7.4.5",
"@babel/preset-react": "^7.0.0",
"@cypress/code-coverage": "^3.8.1",
"babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^6.0.0",
"cross-env": "^7.0.2",
"css-loader": "^4.2.2",
"cypress": "^5.1.0",
"file-loader": "^6.1.0",
"@material-ui/core": "^4.6.1",
"@material-ui/icons": "^4.5.1",
"@types/jest": "24.0.22",
"babel-eslint": "^10.1.0",
"coveralls": "^3.0.9",
"eslint": "^5.12.1",
"eslint-config-google": "^0.12.0",
"eslint-config-react-app": "^5.2.1",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^22.1.3",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"fs-extra": "4.0.3",
"gh-pages": "^3.1.0",
"istanbul-lib-coverage": "^3.0.0",
"markdown-translatable": "^1.0.3",
"nyc": "^15.1.0",
"start-server-and-test": "^1.10.6",
"style-loader": "^1.0.0",
"webpack": "^4.39.1"
"react": "^16.8.6",
"react-docgen": "4.1.1",
"react-dom": "^16.8.6",
"react-markdown": "^4.0.6",
"react-scripts": "^3.0.1",
"react-styleguidist": "^9.1.11",
"react-test-renderer": "^16.12.0",
"webpack": "4.42.0"
},
"browserslist": [
">0.2%",
Expand All @@ -78,5 +77,12 @@
"main": "dist/index.js",
"files": [
"dist/*"
]
],
"jest": {
"collectCoverageFrom": [
"src/core/**.{js,jsx,ts}",
"!**/node_modules/**",
"!**/vendor/**"
]
}
}
2 changes: 1 addition & 1 deletion src/core/BCS-usfm-grammar-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import grammar from 'usfm-grammar';
import * as books from '../core/books/books';


const USFM_GRAMMAR_VALIDATOR_VERSION = '0.3.1';
export const USFM_GRAMMAR_VALIDATOR_VERSION = '0.3.1';

const DEFAULT_EXTRACT_LENGTH = 10;

Expand Down
10 changes: 5 additions & 5 deletions src/core/annotation-row-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import checkTNLinks from './tn-links-check';
import checkOriginalLanguageQuote from './quote-check';


const TABLE_LINE_VALIDATOR_VERSION = '0.1.0';
export const TABLE_LINE_VALIDATOR_VERSION = '0.1.0';

const NUM_EXPECTED_TSV_FIELDS = 7; // so expects 6 tabs per line
const EXPECTED_TN_HEADING_LINE = 'Reference\tID\tTags\tSupportReference\tQuote\tOccurrence\tAnnotation';
Expand Down Expand Up @@ -258,12 +258,12 @@ async function checkAnnotationTSVDataRow(annotationType, line, bookID, C, V, giv
}
// else
// console.log(`Using supplied extractLength=${extractLength}`, `cf. default=${DEFAULT_EXTRACT_LENGTH}`);
const halfLength = Math.floor(extractLength / 2); // rounded down
const halfLengthPlus = Math.floor((extractLength + 1) / 2); // rounded up
// const halfLength = Math.floor(extractLength / 2); // rounded down
// const halfLengthPlus = Math.floor((extractLength + 1) / 2); // rounded up
// console.log(`Using halfLength=${halfLength}`, `halfLengthPlus=${halfLengthPlus}`);

let numChaptersThisBook;
if (bookID != 'OBS') {
if (bookID !== 'OBS') {
const lowercaseBookID = bookID.toLowerCase();
try {
numChaptersThisBook = books.chaptersInBook(lowercaseBookID).length;
Expand Down Expand Up @@ -297,7 +297,7 @@ async function checkAnnotationTSVDataRow(annotationType, line, bookID, C, V, giv
haveGoodChapterNumber = false;
}
try {
numVersesThisChapter = books.versesInChapter(lowercaseBookID, intC);
numVersesThisChapter = books.versesInChapter(bookID.toLowerCase(), intC);
haveGoodChapterNumber = true;
} catch (tlcNVerror) {
if (!haveBibleBookID)
Expand Down
Loading

0 comments on commit 3525480

Please sign in to comment.