Skip to content

Instantly share code, notes, and snippets.

View antoinejaussoin's full-sized avatar

Antoine Jaussoin antoinejaussoin

View GitHub Profile
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Copy of City Route</name>
<description/>
<Style id="icon-1899-DB4436-nodesc-normal">
<IconStyle>
<color>ff3644db</color>
<scale>1</scale>
<Icon>
// ✅ This is covered by Jooks.
// It is a function starting by "use" and using basic hooks internally.
const useMyHook = () => {
const [first, setFirst] = useState('alpha');
const update = () => {
setFirst(first + 'a');
};
return { first, update };
};
import { useEffect, useState } from 'react';
export default () => {
const [activity, setActivity] = useState(null);
const fetchData = async () => {
const result = await fetch('http://someapi');
if (result.ok) {
const content = await result.json();
setActivity(content);
}
import init from 'jooks';
describe('Testing a custom hook', () => {
const jooks = init(() => useLoadActivity());
it('Should load activities properly', async () => {
// By default, before it has a change to load anything, the hook
// will return a null
let result = jooks.run();
expect(result.activity).toBeNull();
import { renderHook, cleanup, act } from "react-hooks-testing-library";
import useLoadActivity from "../useLoadActivity";
import fetchFunctions from "../fetchActivity";
import mockFetchFunction from "../__mocks__/fetchActivity";
describe("Testing a custom hook (without Jooks)", () => {
it("should load activities properly", async () => {
const { result } = renderHook(() => useLoadActivity());
const { activity, next } = result.current;
// Ok so that's ok, it's indeed null at first
server {
listen 80;
server_name plannipoker.com;
return 301 http://www.plannipoker.com$request_uri;
}
server {
listen 80;
server_name www.plannipoker.com;
@antoinejaussoin
antoinejaussoin / App.jsx
Created March 30, 2018 10:29
Consuming an API on a React component
import React, { Component } from 'react';
import styled from 'styled-components';
import Card from './Components/Card';
const Container = styled.div`
display: flex;
margin: 30px;
> * {
margin-right: 20px;
@antoinejaussoin
antoinejaussoin / index.js
Created March 30, 2018 09:27
First endpoint
const express = require('express');
const app = express();
const port = process.env.PORT || 3001;
app.get('/api/test', (req, res) => {
res.send({ plannipoker: 'Response from server' });
});
app.listen(port, () => console.log(`Listening on port ${port}`));
@antoinejaussoin
antoinejaussoin / index.js
Created March 23, 2018 11:59
Card Component rewritten with Styled Components
import React from 'react';
import styled from 'styled-components';
const Container = styled.div`
display: flex;
width: 100px;
height: 150px;
border: 3px solid ${props => props.color};
border-radius: 15px;
justify-content: space-around;

Keybase proof

I hereby claim:

  • I am antoinejaussoin on github.
  • I am anj (https://keybase.io/anj) on keybase.
  • I have a public key whose fingerprint is 7139 61D2 525D 2ACC 2385 A003 058A 45B1 A55E 591F

To claim this, I am signing this object: