Skip to content

Instantly share code, notes, and snippets.

View hdsenevi's full-sized avatar
😙
Typing my life away...

Sha Senevirathne hdsenevi

😙
Typing my life away...
View GitHub Profile
@hdsenevi
hdsenevi / Readme
Last active January 16, 2018 00:52
Dark theme on Slack 3.0.0 above
Dark theme on Slack 3.0.0 above
Paste bellow two files into
Mac: /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/
Restart slack
@hdsenevi
hdsenevi / jest.config.json
Last active December 13, 2018 13:22
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
{
"preset": "react-native",
"collectCoverage": true,
"moduleDirectories": [
"node_modules",
"src"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
@hdsenevi
hdsenevi / setup.js
Last active December 13, 2018 13:20
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
@hdsenevi
hdsenevi / Button.js
Last active December 10, 2018 11:11
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import { Text, TouchableOpacity } from 'react-native';
const Button = (props) => {
const { buttonStyle, textStyle } = styles;
const { onPress, label } = props
return (
<TouchableOpacity onPress={onPress} style={buttonStyle}>
<Text style={textStyle}>
{label}
@hdsenevi
hdsenevi / Button.test.js
Created December 10, 2018 11:11
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import {shallow} from 'enzyme';
import Button from './Button';
describe('Button', () => {
describe('Rendering', () => {
it('should match to snapshot', () => {
const component = shallow(<Button label="test label"/>)
expect(component).toMatchSnapshot()
});
@hdsenevi
hdsenevi / BACKUP_Button.js
Last active December 11, 2018 09:01
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React, { Component } from 'react';
import { Text, TouchableOpacity, Platform, Linking } from 'react-native';
// 1. Changed to a class based component
class Button extends Component {
constructor(props) {
super(props);
}
// 2. Custom function called onPress TouchableOpacity
@hdsenevi
hdsenevi / BACKUP_Button.test.js
Last active December 11, 2018 09:00
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import {shallow} from 'enzyme';
import Button from './Button';
jest.mock('Platform', () => {
const Platform = require.requireActual('Platform');
Platform.OS = 'ios';
return Platform;
})
@hdsenevi
hdsenevi / Button.js
Last active December 11, 2018 09:07
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React, { Component } from 'react';
import { Text, TouchableOpacity, Linking } from 'react-native';
// 1. Changed to a class based component
class Button extends Component {
constructor(props) {
super(props);
}
// 2. Custom function called onPress TouchableOpacity
@hdsenevi
hdsenevi / Button.test.js
Created December 11, 2018 11:29
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import {shallow} from 'enzyme';
import Button from './Button';
describe('Button', () => {
describe('Rendering', () => {
it('should match to snapshot - Primary', () => {
const component = shallow(<Button label="test label" primary />)
expect(component).toMatchSnapshot("Primary button snapshot")
});
@hdsenevi
hdsenevi / Button.test.js
Last active December 11, 2018 12:24
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import {shallow} from 'enzyme';
import Button from './Button';
describe('Button', () => {
describe('Rendering', () => {
it('should match to snapshot - Primary', () => {
const component = shallow(<Button label="test label" primary />)
expect(component).toMatchSnapshot("Primary button snapshot")
});