Skip to content

Instantly share code, notes, and snippets.

View hjumeau's full-sized avatar

Harry JUMEAU hjumeau

  • Paris
View GitHub Profile
@hjumeau
hjumeau / renderWithProviders.js
Created January 6, 2020 22:15
A simple test helper - store provider for react-testing-library
import { render, RenderOptions } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import { store } from '../../store';
const Providers: React.FC = ({ children }) => {
return (
<Provider store={store}>
{children}
</Provider>
@hjumeau
hjumeau / LoginForm.test.js
Last active January 12, 2020 09:00
Test of a login redux-form with react-testing-library
import React from 'react';
import { fireEvent } from '@testing-library/react';
import { renderWithProviders } from '../../../../helpers/test';
import { LoginForm } from './LoginForm';
describe('LoginForm Component', () => {
it('should submit the username and password', () => {
// GIVEN
const onSubmitMock = jest.fn();
const password = 'test';
@hjumeau
hjumeau / LoginForm.enzyme.test.js
Last active January 12, 2020 08:42
A test of a login redux-form with enzyme+mount
import React from 'react';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { mountWithProviders } from '../../../../helpers/test';
import { LoginForm } from './LoginForm';
configure({ adapter: new Adapter() });
describe('LoginForm Component', () => {
it('should show username label', () => {
@hjumeau
hjumeau / mountWithProviders.js
Created December 28, 2019 15:47
A simple test helper - redux-form provider for enzyme mount component
import React from "react";
import { mount } from "enzyme";
import { Provider } from "react-redux";
import { createStore } from "redux";
import { reducer as formReducer } from "redux-form";
const store = createStore(() => ({
form: formReducer,
}));
@hjumeau
hjumeau / BasicLoginForm.js
Last active December 28, 2019 15:41
A basic login form react redux-form typescript
import React from "react";
import { Field, reduxForm } from "redux-form";
const LoginComponent = ({errorMessage, handleSubmit}) => {
return (
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="username">USERNAME</label>
<Field id="username" name="username" component="input" type="text" />
</div>
#!/usr/bin/env bash
shopt -s nocasematch
set -e
set -o pipefail
FIX_PATTERN="*FIX*"
MASTER_BRANCH="master"
B2C_REPOSITORY="ClubMediterranee/cm-b2c"
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember 2.0'
});
import Ember from 'ember';
var Person = Ember.Object.extend({
firstName: null,
lastName: null,
age: null,
country: null,
dateOfDeath: null,
fullName: Ember.computed('firstName', 'lastName', function() {
@hjumeau
hjumeau / application.controller.js
Created February 26, 2016 15:39
ComponentLifecycle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@hjumeau
hjumeau / application.controller.js
Last active February 25, 2016 18:01
CustomizingComponent
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});