Skip to content

Instantly share code, notes, and snippets.

@rcdexta
rcdexta / TodoListItem.test.js
Last active October 9, 2018 00:34
TodoListItem.test
import React from 'react'
import {render, fireEvent} from 'react-testing-library'
import TodoListItem from '../TodoListItem'
test('TodoListItem should render passed props as content body and respond to callback props', () => {
const markTodoDone = jest.fn()
const removeItem = jest.fn()
const item = {index: 3, value: "Fill Gas", done: false}
let itemIndex = 5
@rcdexta
rcdexta / TodoListItem.jsx
Created October 9, 2018 00:28
TodoListItem
class TodoListItem extends React.Component {
static propTypes = {
item: PropTypes.object,
removeItem: PropTypes.func,
markTodoDone: PropTypes.func
}
onClickClose = () => {
const {index, removeItem} = this.props;
import React from 'react'
import ReactDOM from 'react-dom'
import Autosuggest from 'react-autosuggest'
import axios from 'axios'
import { debounce } from 'throttle-debounce'
import './styles.css'
class AutoComplete extends React.Component {
state = {
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"multi_match": {
"query": "CMB14",
"fields": ["fullName", "shortCode"]
}
},
"sort": ["_score", {"createdDate": "desc"}]
}
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"match": {
"fullName": "geller"
}
}
POST http://localhost:9200/crm_app/customers/_search
{
"query": {
"match": {
"fullName": "geller"
}
},
"sort": ["_score", {"createdDate": "desc"}]
}
POST http://localhost:9200/crm_app/customers
{
"fullName": "Rachel Karen Green",
"shortCode": "RKG10",
"createdDate": "2018-10-10"
}
fullName shortCode createdDate
Rachel Karen Green RKG10 2018-10-10
Monica Eustace Geller MEG52 2018-01-12
Ross Eustace Geller REG12 2018-02-21
Chandler Muriel Bing CMB14 2018-02-21
Phoebe Buffay PBF01 2018-04-12
Joey Francis Tribbiani JFT99 2018-05-15
PUT http://localhost:9200/crm_app
{
"settings": {
"index": {
"analysis": {
"filter": {},
"analyzer": {
"analyzer_keyword": {
"tokenizer": "keyword",
"filter": "lowercase"
@rcdexta
rcdexta / BitcoinTicker.js
Created August 12, 2018 08:34
BitcoinTicker
import React, { Component } from "react";
import Pollable from "@bit/rcdexta.hoc.components.pollable";
class BitcoinTicker extends Component {
state = { value: null, lastUpdated: null };
componentDidMount() {
this.props.onInterval(this.refresh);
}