diff --git a/api/controllers/words.js b/api/controllers/words.js index 82f5a11e5..a50cdc99c 100644 --- a/api/controllers/words.js +++ b/api/controllers/words.js @@ -6,9 +6,8 @@ const COLLECTIONS = require('../constants/collections.js') const { capitalizeFirstLetter, shuffleArray, convertToLowerCase, getAllWordsFromTexts } = require('../services/texts') -const { timeAgo } = require('../services/utils') const { ObjectId } = require('mongodb') -const { removeAnythingBetweenBrackets } = require('../services/utils') +const { removeAnythingBetweenBrackets, timeAgo } = require('../services/utils') async function getWordId(request, reply) { try { diff --git a/api/services/texts.js b/api/services/texts.js index 4e5dd9d7d..2d795ffd2 100644 --- a/api/services/texts.js +++ b/api/services/texts.js @@ -254,7 +254,7 @@ function getWordsPairedWithId(word) { return { arabicWord, englishWord } } -export const removeAnythingBetweenBrackets = (text) => { +const removeAnythingBetweenBrackets = (text) => { // remove anything between brackets let updatedText = text.replaceAll(/\[.*?]/g, '') @@ -299,6 +299,7 @@ module.exports = { getAllWordsFromTexts, batchGenerateAudio, generateGuidForSentencesAndWords, + removeAnythingBetweenBrackets, addGuidToArray, addGuidToInnerArray, produceVocabularyCollection, diff --git a/mobile/.yarn/install-state.gz b/mobile/.yarn/install-state.gz index 0137db4d4..e87e40cc4 100644 Binary files a/mobile/.yarn/install-state.gz and b/mobile/.yarn/install-state.gz differ diff --git a/mobile/.yarn/versions/d23f4790.yml b/mobile/.yarn/versions/d23f4790.yml new file mode 100644 index 000000000..e69de29bb diff --git a/mobile/package.json b/mobile/package.json index 4d5d9fb36..a22e79094 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -4,7 +4,7 @@ "license": "MIT", "homepage": "https://openarabic.io", "repository": "https://github.com/edenmind/OpenArabic", - "version": "1444.12.318", + "version": "1444.12.323", "authors": [ "Yunus Andreasson (https://github.com/YunusAndreasson)" ], diff --git a/mobile/redux/reducers.js b/mobile/redux/reducers.js index ae7176e3e..d6ae259dc 100644 --- a/mobile/redux/reducers.js +++ b/mobile/redux/reducers.js @@ -129,7 +129,6 @@ const wordsReducer = createReducer(initialStateWords, (builder) => { }) }) - const textReducer = createReducer(initialStateText, (builder) => { builder .addCase(actions.SET_TEXT, (state, action) => { diff --git a/mobile/screens/text-grammar.js b/mobile/screens/text-grammar.js index 11a10241b..57f31a544 100644 --- a/mobile/screens/text-grammar.js +++ b/mobile/screens/text-grammar.js @@ -3,6 +3,7 @@ import { StyleSheet, ScrollView } from 'react-native' import React from 'react' import PropTypes from 'prop-types' import { formatGrammar } from '../services/ui-services.js' +import { transliterateArabicToEnglish } from '../services/utility-service.js' import { useSharedStyles } from '../styles/common.js' export default function TextGrammar({ route }) { @@ -17,6 +18,8 @@ export default function TextGrammar({ route }) { } }) + const transliteratedArabic = transliterateArabicToEnglish(arabic) + return ( - {english} + {english} - {transliteratedArabic} + {formatGrammar(grammar, sharedStyle)} diff --git a/mobile/screens/text-grammar.test.js b/mobile/screens/text-grammar.test.js new file mode 100644 index 000000000..cb8075014 --- /dev/null +++ b/mobile/screens/text-grammar.test.js @@ -0,0 +1,32 @@ +import { it } from '@jest/globals' +import TextGrammar from './text-grammar.js' +import React from 'react' +import { Provider } from 'react-redux' +import { store } from '../redux/store.js' +import { NavigationContainer } from '@react-navigation/native' +import { render } from '@testing-library/react-native' + +describe('TextGrammar', () => { + it('renders the required properties', () => { + const props = { + route: { + params: { + grammar: 'some grammar', + arabic: 'some arabic text', + english: 'some english text' + } + } + } + + const { getByText } = render( + + + + + + ) + + expect(getByText('some grammar')).toBeDefined() + expect(getByText('some arabic text')).toBeDefined() + }) +}) diff --git a/mobile/screens/text-list-card-grammar.js b/mobile/screens/text-list-card-grammar.js index eb5d2d106..66d9b436c 100644 --- a/mobile/screens/text-list-card-grammar.js +++ b/mobile/screens/text-list-card-grammar.js @@ -88,7 +88,7 @@ export default function TextListCardGrammar({ text, navigation, setShouldReload }) }} > - View Grammar Lesson + View Lesson diff --git a/mobile/screens/text-list-card-grammar.test.js b/mobile/screens/text-list-card-grammar.test.js new file mode 100644 index 000000000..f83de561c --- /dev/null +++ b/mobile/screens/text-list-card-grammar.test.js @@ -0,0 +1,30 @@ +import React from 'react' +import { render } from '@testing-library/react-native' +import { Provider } from 'react-redux' +import { store } from '../redux/store.js' +import { NavigationContainer } from '@react-navigation/native' +import TextListCardGrammar from './text-list-card-grammar.js' + +describe('TextListCardGrammar', () => { + it('renders the required properties', () => { + const props = { + navigation: {}, + setShouldReload: jest.fn(), + text: { + english: 'some english text', + arabic: 'some arabic text' + } + } + + const { getByText } = render( + + + + + + ) + + expect(getByText('some english text')).toBeDefined() + expect(getByText('some arabic text')).toBeDefined() + }) +}) diff --git a/web/src/__snapshots__/index.test.js.snap b/web/src/__snapshots__/index.test.js.snap deleted file mode 100644 index aecd7c2cf..000000000 --- a/web/src/__snapshots__/index.test.js.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Application root should match snapshot 1`] = ` -[MockFunction] { - "calls": Array [ - Array [ - , -
, - ], - ], - "results": Array [ - Object { - "type": "return", - "value": undefined, - }, - ], -} -`; diff --git a/web/src/index.test.js b/web/src/index.test.js deleted file mode 100644 index f8d250b8a..000000000 --- a/web/src/index.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import App from './app.js' - -jest.mock('react-dom', () => ({ render: jest.fn() })) - -describe('Application root', () => { - it('renders without crashing', () => { - const div = document.createElement('div') - ReactDOM.render(, div) - global.document.getElementById = (id) => id === 'root' && div - expect(ReactDOM.render).toHaveBeenCalled() - }) - - it('should match snapshot', () => { - const div = document.createElement('div') - ReactDOM.render(, div) - global.document.getElementById = (id) => id === 'root' && div - expect(ReactDOM.render).toMatchSnapshot() - }) -})