Skip to content

Instantly share code, notes, and snippets.

View adrian-afergon's full-sized avatar
🏠
Working from home

Adrián Ferrera González adrian-afergon

🏠
Working from home
View GitHub Profile
@adrian-afergon
adrian-afergon / ExerciseDetail.spec.tsx
Created April 11, 2019 19:37
This is an example of a not readable test
import { shallow } from 'enzyme';
import * as React from 'react';
import { ExerciseDetail } from './';
describe('ExerciseDetail', () => {
it('should display the warning', () => {
const anExercise: Exercise = {
warning: 'irrelevant warning message',
tags: ['irrelevant tag', 'irrelevant tag'],
name: 'irrelevant name',
@adrian-afergon
adrian-afergon / ExerciseDetail.ts
Created April 11, 2019 19:18
This is an example about react component
import * as React from 'react';
import './ExerciseDetail.scss';
// ... more irrelevant imports for this example
interface ExerciseDetailsProp {
exercise: Exercise
}
export const ExerciseDetail: React.FC<ExerciseDetailsProp> = ({exercise}) => (
<div className="ExerciseDetail">
interface Character {
optionalProerty? : string
}
interface CarrouselProps {
children: ReactNode[]
}
class Carrousel extends React.PureComponent<CarrouselProps> {
public render () {
return (
<div>
{this.props.children.map(child => <div>{child}</div>)}
</div>);
}
class Carrousel extends React.PureComponent<{}> {
public render () {
return (
<div>
{this.props.children.map(child => <div>{child}</div>)}
</div>);
}
};
const MyComponent: React.SFC<{}> = () => (
<Carrousel>
<img src='image1.png' alt='image 1'/>
<img src='image2.png' alt='image 2'/>
<img src='image3.png' alt='image 3'/>
</Carrousel>);
// ts code:
const id: characterId = 'irrelevant';
const character: Hero = getCharacterBy(id);
// character.run(); -> Heros never run.
character.saveTheDay();
// js code:
const id = 'irrelevant'
const character = getCharacterBy(id);
character.run();
@adrian-afergon
adrian-afergon / App.js
Created August 17, 2018 16:19
Change method
import React from 'react';
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
export default class App extends React.Component {
constructor(props) {
super(props);
}
render() {
@adrian-afergon
adrian-afergon / App.test.js
Created August 17, 2018 16:18
Change event tested
import React from 'react';
import App from './App';
import renderer from 'react-test-renderer';
import Adapter from 'enzyme-adapter-react-16'
import { shallow, configure } from 'enzyme';
configure({ adapter: new Adapter() });
it('renders without crashing', () => {