From 682fb04a8420f615ffe68a3f7bf8454428b2bcd8 Mon Sep 17 00:00:00 2001 From: Oscar Andersson Date: Wed, 28 Jun 2017 10:07:42 +0200 Subject: [PATCH] Change test --- .../react-tag-input/react-tag-input-tests.ts | 72 ++++--------------- 1 file changed, 13 insertions(+), 59 deletions(-) diff --git a/types/react-tag-input/react-tag-input-tests.ts b/types/react-tag-input/react-tag-input-tests.ts index bdcdbc37ed..8f126d3609 100644 --- a/types/react-tag-input/react-tag-input-tests.ts +++ b/types/react-tag-input/react-tag-input-tests.ts @@ -1,64 +1,18 @@ import * as React from "react"; import { WithContext as ReactTags, TagItem } from "react-tag-input"; -export interface IState { - tags: TagItem[]; - suggestions: string[]; -} +let tags = [ + { id: 0, text: "test" }, { id: 1, text: "testing" } +]; -export class Tags extends React.Component { - constructor(props: any) { - super(props); - let tags: TagItem[] = []; - let tag: TagItem = { - id: 0, - text: "Test" - }; - tags.push(tag); +let suggestions = ["test", "testar"]; - let suggestions = ["test", "testar"]; - this.state = { - tags: tags, - suggestions: suggestions - } - } - //Not complete - handleDelete(i: number) { - let tags = this.state.tags; - tags.splice(i, 1); - this.setState({ tags: tags }); - } - - handleAddition(tag: string) { - let tags = this.state.tags; - let tagItem: TagItem = { - id: tags.length, - text: tag - }; - tags.push(tagItem); - this.setState({ tags: tags }); - } - //Not complete - handleDrag(tag: TagItem, currPos: number, newPos: number) { - let tags = this.state.tags; - - // mutate array - tags.splice(currPos, 1); - tags.splice(newPos, 0, tag); - - // re-render - this.setState({ tags: tags }); - } - - render() { - return ( -
- this.handleDelete(i)} - handleAddition={(tag: string) => this.handleAddition(tag)} - handleDrag={(tag: TagItem, currPos: number, newPos: number) => this.handleDrag(tag, currPos, newPos)} /> -
- ); - } -} +ReactDOM.render( + console.log("Delete: " + i)} + handleAddition={(tag: string) => console.log("Add: " + tag)} + handleDrag={(tag: TagItem, currPos: number, newPos: number) => console.log("Drag: " + tag.text)} /> + document.getElementById("tag-input") + +); \ No newline at end of file