This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TodoForm extends React.Component { | |
| static propTypes = { | |
| onAddItem: PropTypes.func | |
| } | |
| state = {value: ''} | |
| handleChange = (event) => { | |
| this.setState({value: event.target.value}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test('TodoForm should add new item and call onAddItem callback prop', () => { | |
| const addItem = jest.fn() | |
| const {getByTestId} = render(<TodoForm onAddItem={addItem}/>) | |
| let newItem = 'Get Milk' | |
| fireEvent.change(getByTestId('newItemField'), {target: {value: newItem}}) | |
| getByTestId('addBtn').click() | |
| expect(addItem).toBeCalledWith({newItemValue: newItem}) | |
| expect(addItem).toHaveBeenCalledTimes(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import {SortableContainer, SortableElement, SortableHandle, arrayMove} from "react-sortable-hoc"; | |
| const DragHandle = SortableHandle(() => ( | |
| <span className="handle">≡</span> | |
| )); | |
| const SortableItem = SortableElement(({ value }) => ( | |
| <li> | |
| <DragHandle /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| export default class NewItem extends React.Component { | |
| state = { value: "" }; | |
| updateValue = evt => { | |
| this.setState({ value: evt.target.value }); | |
| }; | |
| addNewItem = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| class App extends React.Component { | |
| state = { | |
| items: ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"] | |
| }; | |
| addItem = newItem => { | |
| this.setState({ items: [...this.state.items, newItem] }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ItemList extends React.Component { | |
| state = { | |
| items: this.props.items | |
| }; | |
| onSortEnd = ({ oldIndex, newIndex }) => { | |
| this.setState({ | |
| items: arrayMove(this.state.items, oldIndex, newIndex) | |
| }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Client } = require('pg') | |
| const pg = { | |
| init: async function() { | |
| const client = new Client({ | |
| user: process.env['DB_USER'] || 'postgres', | |
| host: process.env['DB_HOST'] || 'localhost', | |
| database: process.env['DB_NAME'] || 'customers', | |
| password: process.env['DB_PASSWORD'] || '', | |
| port: 5432 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "Customers", | |
| "description": "All customer related details sync", | |
| "spreadsheetUrl": "https://docs.google.com/spreadsheets/d/1d4QXXx8qFRhcajpVcEbwVM8TlEXAvrclWpLGmqvw-Pc/edit#gid=0", | |
| "spreadsheetId": "1d4QXXx8qFRhcajpVcEbwVM8TlEXAvrclWpLGmqvw-Pc", | |
| "tables": [ | |
| { | |
| "tableName": "customer_details", | |
| "sheetName": "Sheet1" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| functions: | |
| lambda_sheets: | |
| handler: handler.runs | |
| description: Lambda function to pull data from Postgres and dump to Google Spreadsheet | |
| timeout: 900 | |
| events: | |
| - schedule: | |
| rate: rate(1 hour) | |
| enabled: true |