Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

Commit ed1049e

Browse files
authored
Merge pull request #418 from quran/master
Merge master into production
2 parents f64d839 + d8ab10f commit ed1049e

File tree

26 files changed

+261
-204
lines changed

26 files changed

+261
-204
lines changed

.babelrc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
"transform-react-display-name"
88
],
99
"env": {
10-
"test": {
11-
"plugins": [
12-
"rewire"
13-
]
14-
},
1510
"development": {
1611
"plugins": [
1712
"typecheck"

.eslintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"webpackIsomorphicTools": true,
5151
ga: true,
5252
Raven: true,
53-
mixpanel: true
53+
mixpanel: true,
54+
"expect": true,
55+
"browser": true
5456
}
5557
}

nightwatch.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

nightwatch.json

Lines changed: 0 additions & 78 deletions
This file was deleted.

package.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
"version": "1.0.0",
44
"private": false,
55
"scripts": {
6-
"test": "./node_modules/karma/bin/karma start",
6+
"test": "npm run test:dev:unit",
77
"test:ci:unit": "./node_modules/karma/bin/karma start --browsers PhantomJS --single-run; npm run test:ci:lint",
8-
"test:ci:functional": "node ./nightwatch.js -c ./nightwatch.json -e production",
8+
"test:ci:functional": "BROWSER=phantomjs bash tests/functional/test.sh start-ci",
9+
"posttest:ci:functional": "bash tests/functional/test.sh stop",
10+
"test:ci:unit": "karma start --browsers PhantomJS --single-run; npm run test:ci:lint",
11+
"test:dev:unit": "karma start",
912
"test:ci:lint": "eslint ./src/**/*.js",
1013
"test:dev:unit": "./node_modules/karma/bin/karma start",
11-
"test:dev:functional": "node ./nightwatch.js -c ./nightwatch.json",
14+
"test:dev:functional": "BROWSER=chrome bash tests/functional/test.sh start",
15+
"posttest:dev:functional": "bash tests/functional/test.sh stop",
1216
"test:dev:lint": "eslint ./src/scripts/**/*.js",
17+
"test:stylelint": "stylelint './src/**/*.scss' --config webpack/.stylelintrc",
1318
"dev": "node webpack/dev-server.js & PORT=8000 node start.js",
1419
"start": "NODE_PATH=\"./src\" node ./start",
1520
"build": "node ./node_modules/webpack/bin/webpack.js --config webpack/prod.config.js",
@@ -134,11 +139,12 @@
134139
"karma-sourcemap-loader": "^0.3.7",
135140
"karma-webpack": "^1.6.0",
136141
"mocha": "^2.2.5",
137-
"nightwatch": "^0.8.6",
138142
"nodemon": "^1.7.1",
139143
"path": "^0.11.14",
144+
"phantomjs": "^1.9.20",
140145
"phantomjs-polyfill": "0.0.1",
141146
"piping": "^0.3.0",
147+
"pre-commit": "^1.1.3",
142148
"react-addons-test-utils": "^0.14.7",
143149
"react-transform-catch-errors": "^1.0.0",
144150
"react-transform-hmr": "^1.0.1",
@@ -149,11 +155,14 @@
149155
"selenium-server": "^2.48.2",
150156
"sinon": "^1.15.3",
151157
"sinon-chai": "^2.8.0",
158+
"stylelint-webpack-plugin": "^0.2.0",
159+
"wdio-mocha-framework": "^0.3.7",
160+
"wdio-spec-reporter": "0.0.3",
161+
"webdriverio": "4.2.1",
152162
"webpack-dev-server": "^1.6.5"
153163
},
154164
"pre-commit": [
155-
"lint",
156-
"validate",
157-
"test"
165+
"test:dev:lint",
166+
"test:stylelint"
158167
]
159168
}

src/components/Ayah/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class Ayah extends Component {
2020
ayah: PropTypes.object.isRequired,
2121
match: PropTypes.array,
2222
isSearch: PropTypes.bool,
23+
isPlaying: PropTypes.bool,
2324
tooltip: PropTypes.string,
2425
currentWord: PropTypes.any, // gets passed in an integer, null by default
2526
onWordClick: PropTypes.func,
@@ -46,11 +47,14 @@ export default class Ayah extends Component {
4647
}
4748

4849
handlePlay(ayah) {
49-
const {stop, setAyah, start} = this.props.actions;
50+
const {isPlaying, actions} = this.props;
51+
const {pause, setAyah, play} = actions;
5052

51-
stop();
53+
if (isPlaying) {
54+
pause();
55+
}
5256
setAyah(ayah);
53-
start();
57+
play();
5458
}
5559

5660
renderTranslations() {

src/components/Ayah/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
b{
9393
float: right;
94-
border-color:: transparent;
94+
border-color: transparent;
9595
border-width: 0px 0px 1px 0px;
9696
border-style: solid;
9797
&.active {

src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = Object.assign({
7979
],
8080
style: [
8181
{cssText: `@font-face {font-family: 'bismillah';
82-
src: url('http://quran-1f14.kxcdn.com/fonts/ttf/bismillah.ttf') format('truetype')}
82+
src: url('//quran-1f14.kxcdn.com/fonts/ttf/bismillah.ttf') format('truetype')}
8383
.bismillah{font-family: 'bismillah'; font-size: 36px !important; color: #000; padding: 25px 0px;}` // eslint-disable-line max-len
8484
}
8585
]

src/containers/Surah/Title/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const zeroPad = (num, places) => {
1313

1414
const Title = ({ surah }) => {
1515
const title = require(`../../../../static/images/titles/${zeroPad(surah.id, 3)}.svg`); // eslint-disable-line global-require,max-len
16-
1716
return (
1817
<div className={`row ${styles.container}`}>
1918
<div className="col-md-3 col-xs-1 surah-title">
@@ -23,7 +22,7 @@ const Title = ({ surah }) => {
2322
alt="Ornament left"
2423
/>
2524
{
26-
surah.id >= 1 &&
25+
surah.id > 1 &&
2726
<Link
2827
data-metrics-event-name="Title:PreviousSurah"
2928
className="navbar-text previous-chapter"
@@ -56,7 +55,7 @@ const Title = ({ surah }) => {
5655
</div>
5756
<div className="col-md-3 col-xs-1 surah-title text-right">
5857
{
59-
surah.id <= 114 &&
58+
surah.id < 114 &&
6059
<Link
6160
data-metrics-event-name="Title:NextSurah"
6261
className="navbar-text next-chapter"

src/containers/Surah/Title/spec.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import { shallow } from 'enzyme';
4+
5+
import Title from './index';
6+
import getSurahs from '../../../../tests/fixtures/getSurahs.js';
7+
8+
let wrapper;
9+
let surah = {
10+
"id": 1,
11+
"name": {
12+
"arabic": "الفاتحة",
13+
"simple": "Al-Fatihah",
14+
"complex": "Al-Fātiĥah",
15+
"english": "The Opener"
16+
}
17+
};
18+
19+
20+
describe('<Title />', () => {
21+
22+
it('should render', () => {
23+
wrapper = renderComponent(surah);
24+
expect(wrapper).to.be.ok;
25+
});
26+
27+
it('should not show previous surah if on the first surah', () => {
28+
wrapper = renderComponent(surah);
29+
30+
const previous = wrapper.find('.previous-chapter').length;
31+
const next = wrapper.find('.next-chapter').length;
32+
33+
expect(previous).to.equal(0);
34+
expect(next).to.equal(1);
35+
});
36+
37+
it('should not show next surah if on the last surah', () => {
38+
surah.id = 114;
39+
wrapper = renderComponent(surah);
40+
41+
const previous = wrapper.find('.previous-chapter').length;
42+
const next = wrapper.find('.next-chapter').length;
43+
44+
expect(previous).to.equal(1);
45+
expect(next).to.equal(0);
46+
});
47+
48+
it('should show both next and previous if surah is neither last or first', () => {
49+
surah.id = 14;
50+
wrapper = renderComponent(surah);
51+
52+
const previous = wrapper.find('.previous-chapter').length;
53+
const next = wrapper.find('.next-chapter').length;
54+
55+
expect(previous).to.equal(1);
56+
expect(next).to.equal(1);
57+
});
58+
});
59+
60+
function renderComponent(data) {
61+
return shallow(<Title surah={data}/>);
62+
}

0 commit comments

Comments
 (0)