Skip to content

Commit

Permalink
chore!: rename packages name and add tests for the Mobile packge
Browse files Browse the repository at this point in the history
  • Loading branch information
vydimitrov committed Apr 22, 2020
1 parent 49fd34a commit 82c7c3b
Show file tree
Hide file tree
Showing 42 changed files with 267 additions and 35 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"scripts": {
"build": "lerna run build",
"bootstrap": "lerna bootstrap",
"test": "jest",
"test-watch": "jest --watch",
"test": "lerna run test",
"test-coverage": "jest --collectCoverage --coverageDirectory=\"coverage\"",
"dev:push": "lerna run dev:push"
},
Expand All @@ -34,12 +33,14 @@
"prop-types": ">=15.7.0",
"react": ">=16.8.0",
"react-dom": ">=16.8.0",
"react-test-renderer": ">=16.8.0",
"codecov": "^3.6.1",
"jest": "^24.9.0",
"path": "^0.12.7",
"@babel/core": "^7.5.5",
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
"@babel/preset-env": "^7.5.5",
"@babel/core": "^7.9.0",
"@babel/plugin-transform-modules-commonjs": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.0",
"babel-loader": "^8.0.6",
"webpack": "^4.40.2",
"webpack-cli": "^3.3.8"
Expand Down
12 changes: 0 additions & 12 deletions packages/mobile-react-native/babel.config.js

This file was deleted.

File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions packages/mobile/__tests__/CountdownCircleTimer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import { Text } from 'react-native'
import renderer from 'react-test-renderer'

import { CountdownCircleTimer } from '../src'

Math.random = () => 0.124578

const fixture = {
duration: 10,
colors: [['#004777', 0.33], ['#F7B801', 0.33], ['#A30000']],
}

describe('snapshot tests', () => {
it('renders', () => {
const tree = renderer.create(<CountdownCircleTimer {...fixture} />).toJSON()

expect(tree).toMatchSnapshot()
})

it('renders with time', () => {
const tree = renderer
.create(
<CountdownCircleTimer
{...fixture}
renderAriaTime={({ remainingTime }) => remainingTime}
>
{({ remainingTime }) => <Text>{remainingTime}</Text>}
</CountdownCircleTimer>
)
.toJSON()

expect(tree).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snapshot tests renders 1`] = `
<View
accessibilityLabel="Countdown timer"
accessible={true}
style={
Object {
"height": 180,
"position": "relative",
"width": 180,
}
}
>
<RNSVGSvgView
bbHeight={180}
bbWidth={180}
focusable={false}
height={180}
style={
Array [
Object {
"backgroundColor": "transparent",
"borderWidth": 0,
},
Object {
"flex": 0,
"height": 180,
"width": 180,
},
]
}
width={180}
>
<RNSVGGroup>
<RNSVGPath
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
fill={null}
propList={
Array [
"fill",
"stroke",
"strokeWidth",
]
}
stroke={4292467161}
strokeWidth={12}
/>
<RNSVGPath
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
fill={null}
propList={
Array [
"fill",
"stroke",
"strokeWidth",
"strokeDasharray",
"strokeDashoffset",
"strokeLinecap",
]
}
stroke={4278208375}
strokeDasharray={
Array [
527.7875658030853,
527.7875658030853,
]
}
strokeDashoffset={null}
strokeLinecap={1}
strokeWidth={12}
/>
</RNSVGGroup>
</RNSVGSvgView>
</View>
`;

exports[`snapshot tests renders with time 1`] = `
<View
accessibilityLabel="Countdown timer"
accessible={true}
style={
Object {
"height": 180,
"position": "relative",
"width": 180,
}
}
>
<RNSVGSvgView
bbHeight={180}
bbWidth={180}
focusable={false}
height={180}
style={
Array [
Object {
"backgroundColor": "transparent",
"borderWidth": 0,
},
Object {
"flex": 0,
"height": 180,
"width": 180,
},
]
}
width={180}
>
<RNSVGGroup>
<RNSVGPath
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
fill={null}
propList={
Array [
"fill",
"stroke",
"strokeWidth",
]
}
stroke={4292467161}
strokeWidth={12}
/>
<RNSVGPath
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
fill={null}
propList={
Array [
"fill",
"stroke",
"strokeWidth",
"strokeDasharray",
"strokeDashoffset",
"strokeLinecap",
]
}
stroke={4278208375}
strokeDasharray={
Array [
527.7875658030853,
527.7875658030853,
]
}
strokeDashoffset={null}
strokeLinecap={1}
strokeWidth={12}
/>
</RNSVGGroup>
</RNSVGSvgView>
<View
accessibilityElementsHidden={true}
importantForAccessibility="no-hide-descendants"
style={
Object {
"alignItems": "center",
"display": "flex",
"height": "100%",
"justifyContent": "center",
"left": 0,
"position": "absolute",
"top": 0,
"width": "100%",
}
}
>
<Text>
10
</Text>
</View>
<Text
accessibilityLiveRegion="assertive"
accessibilityRole="timer"
importantForAccessibility="yes"
style={
Object {
"height": 0,
"opacity": 0,
}
}
>
10
</Text>
</View>
`;
2 changes: 1 addition & 1 deletion babel.config.js → packages/mobile/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = (api) => {
api.cache(true)

const presets = ['@babel/preset-react']
const presets = ['module:metro-react-native-babel-preset']

const env = {
test: {
Expand Down
9 changes: 9 additions & 0 deletions packages/mobile/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
preset: 'react-native',
transformIgnorePatterns: [
'node_modules/(?!(react-native|react-native-svg)/)',
],
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"scripts": {
"build": "webpack",
"prepublish": "yarn run build",
"dev:push": "yarn run build && yalc push"
"dev:push": "yarn run build && yalc push",
"test": "jest",
"test-watch": "jest --watch"
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const webpackBaseConfig = require('../../webpack-react-base-config')
const webpackBaseConfig = require('../../webpack-base-config')

module.exports = {
...webpackBaseConfig,
Expand Down
4 changes: 1 addition & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"version": "1.0.2",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"scripts": {},
"author": "Vasil Dimitrov",
"license": "MIT"
}
3 changes: 0 additions & 3 deletions packages/web-react/webpack.config.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ module.exports = (api) => {
'@babel/preset-react',
]

const env = {
test: {
plugins: ['@babel/plugin-transform-modules-commonjs'],
},
}

return {
presets,
env,
}
}
8 changes: 4 additions & 4 deletions packages/web-react/package.json → packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"scripts": {
"build": "webpack",
"prepublish": "yarn run build",
"dev:push": "yarn run build && yalc push"
"dev:push": "yarn run build && yalc push",
"test": "jest",
"test-watch": "jest --watch"
},
"repository": {
"type": "git",
Expand All @@ -35,10 +37,8 @@
"react-dom": ">=16.8.0"
},
"devDependencies": {
"@babel/preset-react": "^7.0.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"react-test-renderer": "^16.8.0"
"@testing-library/react": "^9.4.0"
},
"dependencies": {
"@countdown-circle-timer/shared": "^1.0.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/web/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const webpackBaseConfig = require('../../webpack-base-config')

module.exports = webpackBaseConfig
File renamed without changes.
Loading

0 comments on commit 82c7c3b

Please sign in to comment.