How to use props method in storybook-root

Best JavaScript code snippet using storybook-root

ui.js

Source:ui.js Github

copy

Full Screen

1import React from "react";2import ReactDOM from "react-dom";3import { css } from "@emotion/css";4export const render = (node, mount) => ReactDOM.render(node, mount);5export const element = (el, props, ...children) =>6 React.createElement(el, props, children);7export const fragment = (...children) =>8 element(React.Fragment, null, ...children);9export const useEffect = (callback, deps = undefined) =>10 React.useEffect(callback, deps);11export const useState = (init) => React.useState(init);12export const clone = (elem) => React.cloneElement(elem);13export { css };14export const a = (props = {}, ...children) => element("a", props, ...children);15export const abbr = (props = {}, ...children) =>16 element("abbr", props, ...children);17export const address = (props = {}, ...children) =>18 element("address", props, ...children);19export const area = (props = {}, ...children) =>20 element("area", props, ...children);21export const article = (props = {}, ...children) =>22 element("article", props, ...children);23export const aside = (props = {}, ...children) =>24 element("aside", props, ...children);25export const audio = (props = {}, ...children) =>26 element("audio", props, ...children);27export const b = (props = {}, ...children) => element("b", props, ...children);28export const bdi = (props = {}, ...children) =>29 element("bdi", props, ...children);30export const bdo = (props = {}, ...children) =>31 element("bdo", props, ...children);32export const blockquote = (props = {}, ...children) =>33 element("blockquote", props, ...children);34export const br = (props = {}, ...children) =>35 element("br", props, ...children);36export const button = (props = {}, ...children) =>37 element("button", props, ...children);38export const caption = (props = {}, ...children) =>39 element("caption", props, ...children);40export const canvas = (props = {}, ...children) =>41 element("canvas", props, ...children);42export const cite = (props = {}, ...children) =>43 element("cite", props, ...children);44export const code = (props = {}, ...children) =>45 element("code", props, ...children);46export const col = (props = {}, ...children) =>47 element("col", props, ...children);48export const colgroup = (props = {}, ...children) =>49 element("colgroup", props, ...children);50export const data = (props = {}, ...children) =>51 element("data", props, ...children);52export const datalist = (props = {}, ...children) =>53 element("datalist", props, ...children);54export const dd = (props = {}, ...children) =>55 element("dd", props, ...children);56export const del = (props = {}, ...children) =>57 element("del", props, ...children);58export const details = (props = {}, ...children) =>59 element("details", props, ...children);60export const dfn = (props = {}, ...children) =>61 element("dfn", props, ...children);62export const dialog = (props = {}, ...children) =>63 element("dialog", props, ...children);64export const div = (props = {}, ...children) =>65 element("div", props, ...children);66export const dl = (props = {}, ...children) =>67 element("dl", props, ...children);68export const dt = (props = {}, ...children) =>69 element("dt", props, ...children);70export const em = (props = {}, ...children) =>71 element("em", props, ...children);72export const embed = (props = {}, ...children) =>73 element("embed", props, ...children);74export const fieldset = (props = {}, ...children) =>75 element("fieldset", props, ...children);76export const figcaption = (props = {}, ...children) =>77 element("figcaption", props, ...children);78export const figure = (props = {}, ...children) =>79 element("figure", props, ...children);80export const footer = (props = {}, ...children) =>81 element("footer", props, ...children);82export const form = (props = {}, ...children) =>83 element("form", props, ...children);84export const h1 = (props = {}, ...children) =>85 element("h1", props, ...children);86export const h2 = (props = {}, ...children) =>87 element("h2", props, ...children);88export const h3 = (props = {}, ...children) =>89 element("h3", props, ...children);90export const h4 = (props = {}, ...children) =>91 element("h4", props, ...children);92export const h5 = (props = {}, ...children) =>93 element("h5", props, ...children);94export const h6 = (props = {}, ...children) =>95 element("h6", props, ...children);96export const header = (props = {}, ...children) =>97 element("header", props, ...children);98export const hr = (props = {}, ...children) =>99 element("hr", props, ...children);100export const i = (props = {}, ...children) => element("i", props, ...children);101export const iframe = (props = {}, ...children) =>102 element("iframe", props, ...children);103export const img = (props = {}, ...children) =>104 element("img", props, ...children);105export const input = (props = {}, ...children) =>106 element("input", props, ...children);107export const ins = (props = {}, ...children) =>108 element("ins", props, ...children);109export const kbd = (props = {}, ...children) =>110 element("kbd", props, ...children);111export const label = (props = {}, ...children) =>112 element("label", props, ...children);113export const legend = (props = {}, ...children) =>114 element("legend", props, ...children);115export const li = (props = {}, ...children) =>116 element("li", props, ...children);117export const main = (props = {}, ...children) =>118 element("main", props, ...children);119export const map = (props = {}, ...children) =>120 element("map", props, ...children);121export const mark = (props = {}, ...children) =>122 element("mark", props, ...children);123export const math = (props = {}, ...children) =>124 element("math", props, ...children);125export const menu = (props = {}, ...children) =>126 element("menu", props, ...children);127export const meter = (props = {}, ...children) =>128 element("meter", props, ...children);129export const nav = (props = {}, ...children) =>130 element("nav", props, ...children);131export const object = (props = {}, ...children) =>132 element("object", props, ...children);133export const ol = (props = {}, ...children) =>134 element("ol", props, ...children);135export const optgroup = (props = {}, ...children) =>136 element("optgroup", props, ...children);137export const option = (props = {}, ...children) =>138 element("option", props, ...children);139export const output = (props = {}, ...children) =>140 element("output", props, ...children);141export const p = (props = {}, ...children) => element("p", props, ...children);142export const param = (props = {}, ...children) =>143 element("param", props, ...children);144export const picture = (props = {}, ...children) =>145 element("picture", props, ...children);146export const portal = (props = {}, ...children) =>147 element("portal", props, ...children);148export const pre = (props = {}, ...children) =>149 element("pre", props, ...children);150export const progress = (props = {}, ...children) =>151 element("progress", props, ...children);152export const q = (props = {}, ...children) => element("q", props, ...children);153export const rp = (props = {}, ...children) =>154 element("rp", props, ...children);155export const rt = (props = {}, ...children) =>156 element("rt", props, ...children);157export const ruby = (props = {}, ...children) =>158 element("ruby", props, ...children);159export const s = (props = {}, ...children) => element("s", props, ...children);160export const samp = (props = {}, ...children) =>161 element("samp", props, ...children);162export const section = (props = {}, ...children) =>163 element("section", props, ...children);164export const select = (props = {}, ...children) =>165 element("select", props, ...children);166export const small = (props = {}, ...children) =>167 element("small", props, ...children);168export const source = (props = {}, ...children) =>169 element("source", props, ...children);170export const span = (props = {}, ...children) =>171 element("span", props, ...children);172export const strong = (props = {}, ...children) =>173 element("strong", props, ...children);174export const sub = (props = {}, ...children) =>175 element("sub", props, ...children);176export const summary = (props = {}, ...children) =>177 element("summary", props, ...children);178export const sup = (props = {}, ...children) =>179 element("sup", props, ...children);180export const svg = (props = {}, ...children) =>181 element("svg", props, ...children);182export const table = (props = {}, ...children) =>183 element("table", props, ...children);184export const tbody = (props = {}, ...children) =>185 element("tbody", props, ...children);186export const td = (props = {}, ...children) =>187 element("td", props, ...children);188export const textarea = (props = {}, ...children) =>189 element("textarea", props, ...children);190export const tfoot = (props = {}, ...children) =>191 element("tfoot", props, ...children);192export const th = (props = {}, ...children) =>193 element("th", props, ...children);194export const thead = (props = {}, ...children) =>195 element("thead", props, ...children);196export const time = (props = {}, ...children) =>197 element("time", props, ...children);198export const tr = (props = {}, ...children) =>199 element("tr", props, ...children);200export const track = (props = {}, ...children) =>201 element("track", props, ...children);202export const u = (props = {}, ...children) => element("u", props, ...children);203export const ul = (props = {}, ...children) =>204 element("ul", props, ...children);205export const video = (props = {}, ...children) =>206 element("video", props, ...children);207export const wbr = (props = {}, ...children) =>...

Full Screen

Full Screen

FormElements.js

Source:FormElements.js Github

copy

Full Screen

1import { Component } from 'react'2class MyTextInput extends Component {3 constructor(props) {4 super(props)5 this.inputChange = this.inputChange.bind(this)6 this.inputBlur = this.inputBlur.bind(this)7 this.inputFocus = this.inputFocus.bind(this)8 this.setTextInputRef = (element) => {9 this.textInput = element10 }11 this.focusTextInput = () => {12 if (this.textInput) {13 this.textInput.focus()14 }15 }16 this.state = {17 notEmpty: this.props.inputValue.length ? true : false,18 error: this.props.error19 }20 }21 componentDidMount() {22 if (this.props.autofocus) {23 this.focusTextInput()24 }25 }26 inputFocus(event) {27 event.preventDefault()28 document.getElementById('label-' + this.props.uniqueID).classList.add('active')29 }30 31 inputBlur(event) {32 event.preventDefault()33 if (this.state.notEmpty) {34 document.getElementById('label-' + this.props.uniqueID).classList.add('active')35 } else {36 document.getElementById('label-' + this.props.uniqueID).classList.remove('active')37 }38 }39 inputChange(event) {40 event.preventDefault()41 if (this.props.onChange) {42 this.props.onChange(event)43 }44 console.log(event.target.name)45 console.log(event.target.value)46 this.setState({47 notEmpty: event.target.value.length ? true : false48 })49 }50 componentDidUpdate(prevProps) {51 if (this.props.inputValue !== prevProps.inputValue) {52 this.setState({53 notEmpty: this.props.inputValue ? true : false54 })55 }56 if (this.props.error !== prevProps.error) {57 this.setState({58 error: this.props.error59 })60 }61 }62 /**63 * rowClass, colClass, inputClass, validationClass64 * icon, type, name, inputValue, uniqueID, placeholder, label, autofocus65 * error, success, helperText66 * inputRef, inputChange, inputFocus, inputBlur67 */68 render() {69 const props = this.props70 const { error } = this.state71 console.log(error)72 return (73 <div className={props.rowClass ? props.rowClass : "row margin-yaxis-12"}>74 <div className={props.colClass ? props.colClass : "input-field col s6"}>75 <i className={"material-icons prefix fa fa-" + (props.icon ? props.icon : "")}></i> 76 <input 77 type={props.type ? props.type : "text"}78 ref={this.setTextInputRef}79 onChange={this.inputChange}80 onFocus={this.inputFocus}81 onBlur={this.inputBlur}82 className={props.inputClass ? props.inputClass : "white-text validate " + (error ? "invalid" : "")}83 name={props.name ? props.name : ""}84 defaultValue={props.inputValue ? props.inputValue : ""}85 id={props.uniqueID ? props.uniqueID : ""}86 placeholder={props.placeholder ? props.placeholder : ""}/>87 <label 88 htmlFor={props.uniqueID ? props.uniqueID : "prefix"}89 id={"label-" + (props.uniqueID ? props.uniqueID : "")}>90 {props.label ? props.label : ""}91 </label>92 <span 93 className={props.validationClass ? props.validationClass : "helper-text white-text margin-bottom-12"}94 data-error={error ? error : ""}95 data-success={props.success ? props.success : ""}>96 {props.helperText ? props.helperText : ""}97 </span>98 </div>99 </div>100 )101 }102}103class MyTextArea extends Component {104 constructor(props) {105 super(props)106 this.inputChange = this.inputChange.bind(this)107 this.inputBlur = this.inputBlur.bind(this)108 this.inputFocus = this.inputFocus.bind(this)109 this.setTextInputRef = (element) => {110 this.textInput = element111 }112 this.focusTextInput = () => {113 if (this.textInput) {114 this.textInput.focus()115 }116 }117 this.state = {118 notEmpty: this.props.inputValue.length ? true : false,119 inputValue: this.props.inputValue ? this.props.inputValue : "",120 error: this.props.error121 }122 }123 componentDidMount() {124 if (this.props.autofocus) {125 this.focusTextInput()126 }127 M.AutoInit();128 }129 inputFocus(event) {130 event.preventDefault()131 if (this.props.onFocus) {132 this.props.onFocus(event)133 }134 document.getElementById('label-' + this.props.uniqueID).classList.add('active')135 }136 inputBlur(event) {137 event.preventDefault()138 if (this.props.onBlur) {139 this.props.onBlur(event)140 }141 if (this.state.notEmpty) {142 document.getElementById('label-' + this.props.uniqueID).classList.add('active')143 } else {144 document.getElementById('label-' + this.props.uniqueID).classList.remove('active')145 }146 }147 inputChange(event) {148 event.preventDefault()149 if (this.props.onChange) {150 this.props.onChange(event)151 }152 console.log(event.target.name)153 console.log(event.target.value)154 this.setState({155 notEmpty: event.target.value.length ? true : false,156 inputValue: event.target.value157 })158 }159 componentDidUpdate(prevProps) {160 if (this.props.inputValue !== prevProps.inputValue) {161 this.setState({162 notEmpty: this.props.inputValue ? true : false,163 inputValue: this.props.inputValue164 })165 }166 if (this.props.error !== prevProps.error) {167 this.setState({168 error: this.props.error169 })170 }171 }172 render() {173 const props = this.props174 const { error } = this.state175 return (176 <div className={props.rowClass ? props.rowClass : "row margin-yaxis-12"}>177 <div className={props.colClass ? props.colClass : "input-field col s6"}>178 <i className={"material-icons prefix fa fa-" + (props.icon ? props.icon : "")}></i> 179 <textarea 180 ref={this.setTextInputRef}181 onChange={this.inputChange}182 onFocus={this.inputFocus}183 onBlur={this.inputBlur}184 className={props.inputClass ? props.inputClass : "materialize-textarea white-text validate " + (error ? "invalid" : "")}185 value={this.state.inputValue}186 name={props.name ? props.name : ""}187 id={props.uniqueID ? props.uniqueID : ""}188 placeholder={props.placeholder ? props.placeholder : ""}>189 </textarea>190 <label 191 htmlFor={props.uniqueID ? props.uniqueID : "prefix"}192 id={"label-" + (props.uniqueID ? props.uniqueID : "")}>193 {props.label ? props.label : ""}194 </label>195 <span 196 className={props.validationClass ? props.validationClass : "helper-text white-text margin-bottom-12"}197 data-error={error ? error : ""}198 data-success={props.success ? props.success : ""}>199 {props.helperText ? props.helperText : ""}200 </span>201 </div>202 </div>203 )204 }205}206class MySubmitButton extends Component {207 constructor(props) {208 super(props)209 }210 /**211 * isSuccess, confirmationSuccessMessage, confirmationErrorMessage212 */213 render() {214 const props = this.props215 return (216 <div>217 <div className="row margin-yaxis-12">218 <div className="col s6">219 <input type="submit" value="Confirm" className="btn waves-effect brown lighten-2 pointer" />220 </div>221 </div>222 <div className="row margin-yaxis-12">223 <div className="col s6">224 <div className={props.isSuccess ? "green-text text-darken-1" : "red-text text-darken-3"}>225 {props.confirmationSuccessMessage ? props.confirmationSuccessMessage : props.confirmationErrorMessage}226 </div>227 </div>228 </div>229 </div>230 )231 }232}...

Full Screen

Full Screen

BucketContext.types.ts

Source:BucketContext.types.ts Github

copy

Full Screen

1import { AccordionsProps } from '../collections/Accordions';2import { DropdownMenuProps } from '../collections/DropdownMenu';3import { FormFormikProps, FormProps } from '../collections/Form';4import { ColumnProps, ContainerProps, RowProps } from '../collections/Grid';5import { MenuItemProps, MenuProps } from '../collections/Menu';6import { MessageProps } from '../collections/Message';7import { RxTableProps } from '../collections/RxTable';8import {9 TableBodyProps,10 TableCellContentProps,11 TableCellProps,12 TableFooterProps, TableHeaderCellProps, TableHeaderProps,13 TableProps, TableRowProps14} from '../collections/Table';15import { TabsProps } from '../collections/Tabs';16import { TabPanelProps } from '../collections/Tabs/TabPanel.types';17import { AvatarProps } from '../elements/Avatar';18import { BadgeProps } from '../elements/Badge';19import { BoxProps } from '../elements/Box';20import { ButtonGroupProps, ButtonProps } from '../elements/Button';21import { CheckboxProps } from '../elements/Checkbox';22import { ColorPickerProps } from '../elements/ColorPicker';23import { DayPickerProps } from '../elements/DayPicker';24import { DividerProps } from '../elements/Divider';25import { EmptyContentProps } from '../elements/EmptyContent';26import { HeaderContentProps, HeaderProps, HeaderSubheaderProps } from '../elements/Header';27import { HeroButtonProps } from '../elements/HeroButton';28import { IconProps } from '../elements/Icon';29import { InputProps } from '../elements/Input';30import {31 ItemContentProps,32 ItemGroupProps,33 ItemHeaderProps,34 ItemMetaProps,35 ItemProps,36 ItemTextProps, ItemToolsProps37} from '../elements/Item';38import { LabelProps } from '../elements/Label';39import { LabelGroupProps } from '../elements/Label/LabelGroup.types';40import { LoaderProps } from '../elements/Loader';41import { NumericInputProps } from '../elements/NumericInput';42import { PanelBodyProps, PanelFooterProps, PanelHeaderProps, PanelProps } from '../elements/Panel';43import { CircularProgressProps, LinearProgressProps } from '../elements/Progress';44import { SectionProps } from '../elements/Section';45import { SelectMultiProps, SelectProps } from '../elements/Select';46import { ToastProps } from '../elements/Toast';47import { AutoSpacerProps } from '../hoc/AutoSpacer';48import { BackdropInnerProps, BackdropProps } from '../modules/Backdrop';49import { CollapsableProps } from '../modules/Collapsable';50import { DropzoneProps } from '../modules/Dropzone';51import { ModalActionsProps, ModalContentProps, ModalHeaderProps, ModalProps } from '../modules/Modal';52import { PopupProps } from '../modules/Popup';53import { StickyProps } from '../modules/Sticky';54import { VirtualizedTableProps } from '../modules/VirtualizedTable';55/* --------56 * Bucket Theme Provider57 * -------- */58type RecursivePartial<T> = {59 [P in keyof T]?: T[P] extends (infer U)[]60 ? RecursivePartial<U>[]61 : T[P] extends object62 ? RecursivePartial<T[P]>63 : T[P]64};65type ThemeComponentProps<Props> = Partial<Props>;66export interface ThemeOptions {67 accordions: ThemeComponentProps<AccordionsProps>;68 avatar: ThemeComponentProps<AvatarProps>;69 autoSpacer: ThemeComponentProps<AutoSpacerProps>;70 backdrop: ThemeComponentProps<BackdropProps>;71 backdropInner: ThemeComponentProps<BackdropInnerProps>;72 badge: ThemeComponentProps<BadgeProps>;73 box: ThemeComponentProps<BoxProps>;74 button: ThemeComponentProps<ButtonProps>;75 buttonGroup: ThemeComponentProps<ButtonGroupProps>;76 checkbox: ThemeComponentProps<CheckboxProps>;77 circularProgress: ThemeComponentProps<CircularProgressProps>;78 collapsable: ThemeComponentProps<CollapsableProps>;79 colorPicker: ThemeComponentProps<ColorPickerProps>;80 column: ThemeComponentProps<ColumnProps>;81 container: ThemeComponentProps<ContainerProps>;82 dayPicker: ThemeComponentProps<DayPickerProps<any>>;83 divider: ThemeComponentProps<DividerProps>;84 dropdownMenu: ThemeComponentProps<DropdownMenuProps>;85 dropzone: ThemeComponentProps<DropzoneProps>;86 emptyContent: ThemeComponentProps<EmptyContentProps>;87 form: ThemeComponentProps<FormProps>;88 formFormik: ThemeComponentProps<FormFormikProps<any>>;89 header: ThemeComponentProps<HeaderProps>;90 headerContent: ThemeComponentProps<HeaderContentProps>;91 headerSubheader: ThemeComponentProps<HeaderSubheaderProps>;92 heroButton: ThemeComponentProps<HeroButtonProps>;93 icon: ThemeComponentProps<IconProps>;94 input: ThemeComponentProps<InputProps>;95 item: ThemeComponentProps<ItemProps>;96 itemContent: ThemeComponentProps<ItemContentProps>;97 itemGroup: ThemeComponentProps<ItemGroupProps>;98 itemHeader: ThemeComponentProps<ItemHeaderProps>;99 itemMeta: ThemeComponentProps<ItemMetaProps>;100 itemText: ThemeComponentProps<ItemTextProps>;101 itemTools: ThemeComponentProps<ItemToolsProps>;102 label: ThemeComponentProps<LabelProps>;103 labelGroup: ThemeComponentProps<LabelGroupProps>;104 linearProgress: ThemeComponentProps<LinearProgressProps>;105 loader: ThemeComponentProps<LoaderProps>;106 menu: ThemeComponentProps<MenuProps>;107 menuItem: ThemeComponentProps<MenuItemProps>;108 message: ThemeComponentProps<MessageProps>;109 modal: ThemeComponentProps<ModalProps>;110 modalActions: ThemeComponentProps<ModalActionsProps>;111 modalContent: ThemeComponentProps<ModalContentProps>;112 modalHeader: ThemeComponentProps<ModalHeaderProps>;113 numericInput: ThemeComponentProps<NumericInputProps>;114 panel: ThemeComponentProps<PanelProps>;115 panelBody: ThemeComponentProps<PanelBodyProps>;116 panelFooter: ThemeComponentProps<PanelFooterProps>;117 panelHeader: ThemeComponentProps<PanelHeaderProps>;118 popup: ThemeComponentProps<PopupProps>;119 row: ThemeComponentProps<RowProps>;120 rxTable: ThemeComponentProps<RxTableProps<any>>;121 section: ThemeComponentProps<SectionProps>;122 select: ThemeComponentProps<SelectProps<any, any, any>>;123 selectMulti: ThemeComponentProps<SelectMultiProps<any, any>>;124 sticky: ThemeComponentProps<StickyProps>;125 table: ThemeComponentProps<TableProps>;126 tableBody: ThemeComponentProps<TableBodyProps>;127 tableCell: ThemeComponentProps<TableCellProps>;128 tableCellContent: ThemeComponentProps<TableCellContentProps>;129 tableFooter: ThemeComponentProps<TableFooterProps>;130 tableHeader: ThemeComponentProps<TableHeaderProps>;131 tableHeaderCell: ThemeComponentProps<TableHeaderCellProps>;132 tableRow: ThemeComponentProps<TableRowProps>;133 tabPanel: ThemeComponentProps<TabPanelProps>;134 tabs: ThemeComponentProps<TabsProps>;135 toast: ThemeComponentProps<ToastProps>;136 virtualizedTable: ThemeComponentProps<VirtualizedTableProps<any>>;137}138export type PartialThemeOptions = RecursivePartial<ThemeOptions>;139/* --------140 * The Bucket Context will contain the theme object and some useful functions141 * -------- */142export interface BucketThemeContext {143 /** Theme configuration */144 theme: ThemeOptions;...

Full Screen

Full Screen

07-will-properties.py

Source:07-will-properties.py Github

copy

Full Screen

1#!/usr/bin/env python32# Test for bug #1244. This occurs if a V5 will message is used where the first3# Will property is one of: content-type, payload-format-indicator,4# response-topic. These are the properties that are attached to the will for5# later use, as opposed to e.g. will-delay-interval which is a value which is6# read immediately and not passed7from mosq_test_helper import *8def do_test(will_props, recvd_props):9 rc = 110 keepalive = 6011 mid = 112 connect1_packet = mosq_test.gen_connect("will-helper", keepalive=keepalive, proto_ver=5)13 connack1_packet = mosq_test.gen_connack(rc=0, proto_ver=5)14 subscribe1_packet = mosq_test.gen_subscribe(mid, "will/test", 0, proto_ver=5)15 suback1_packet = mosq_test.gen_suback(mid, 0, proto_ver=5)16 connect2_packet = mosq_test.gen_connect("will-test", keepalive=keepalive, proto_ver=5, will_topic="will/test", will_payload=b"will payload", will_properties=will_props)17 connack2_packet = mosq_test.gen_connack(rc=0, proto_ver=5)18 publish_packet = mosq_test.gen_publish("will/test", qos=0, payload="will payload", proto_ver=5, properties=recvd_props)19 port = mosq_test.get_port()20 broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port)21 try:22 sock1 = mosq_test.do_client_connect(connect1_packet, connack1_packet, timeout=30, port=port)23 mosq_test.do_send_receive(sock1, subscribe1_packet, suback1_packet, "suback")24 sock2 = mosq_test.do_client_connect(connect2_packet, connack2_packet, timeout=30, port=port)25 sock2.close()26 if mosq_test.expect_packet(sock1, "publish", publish_packet):27 rc = 028 sock1.close()29 finally:30 broker.terminate()31 broker.wait()32 (stdo, stde) = broker.communicate()33 if rc:34 print(stde.decode('utf-8'))35 exit(rc)36# Single test property37will_props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")38#do_test(will_props, will_props)39# Multiple test properties40will_props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")41will_props += mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 0)42#do_test(will_props, will_props)43# Multiple test properties, with property that is removed44will_props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")45will_props += mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_WILL_DELAY_INTERVAL, 0)46will_props += mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 0)47recv_props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")48recv_props += mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 0)49#do_test(will_props, recv_props)50# Multiple test properties, with property that is removed *first*51will_props = mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_WILL_DELAY_INTERVAL, 0)52will_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")53will_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CORRELATION_DATA, "data")54recv_props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")55recv_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CORRELATION_DATA, "data")56#do_test(will_props, recv_props)57# All properties, plus multiple user properties (excluding58# message-expiry-interval, for ease of testing reasons)59will_props = mqtt5_props.gen_string_pair_prop(mqtt5_props.PROP_USER_PROPERTY, "key1", "value1")60will_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")61will_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CORRELATION_DATA, "data")62will_props += mqtt5_props.gen_uint32_prop(mqtt5_props.PROP_WILL_DELAY_INTERVAL, 0)63will_props += mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 1)64will_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CONTENT_TYPE, "application/test")65will_props += mqtt5_props.gen_string_pair_prop(mqtt5_props.PROP_USER_PROPERTY, "key2", "value2")66recv_props = mqtt5_props.gen_string_pair_prop(mqtt5_props.PROP_USER_PROPERTY, "key1", "value1")67recv_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_RESPONSE_TOPIC, "response/topic")68recv_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CORRELATION_DATA, "data")69recv_props += mqtt5_props.gen_byte_prop(mqtt5_props.PROP_PAYLOAD_FORMAT_INDICATOR, 1)70recv_props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_CONTENT_TYPE, "application/test")71recv_props += mqtt5_props.gen_string_pair_prop(mqtt5_props.PROP_USER_PROPERTY, "key2", "value2")...

Full Screen

Full Screen

09-extended-auth-multistep-reauth.py

Source:09-extended-auth-multistep-reauth.py Github

copy

Full Screen

1#!/usr/bin/env python2from mosq_test_helper import *3def write_config(filename, port):4 with open(filename, 'w') as f:5 f.write("port %d\n" % (port))6 f.write("auth_plugin c/auth_plugin_extended_multiple.so\n")7port = mosq_test.get_port()8conf_file = os.path.basename(__file__).replace('.py', '.conf')9write_config(conf_file, port)10rc = 111# First auth12# ==========13props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")14props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "step1")15connect1_packet = mosq_test.gen_connect("client-params-test", keepalive=42, proto_ver=5, properties=props)16# Server to client17props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")18props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "1pets")19auth1_1_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_CONTINUE_AUTHENTICATION, properties=props)20# Client to server21props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")22props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "supercalifragilisticexpialidocious")23auth1_2_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_CONTINUE_AUTHENTICATION, properties=props)24props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")25connack1_packet = mosq_test.gen_connack(rc=0, proto_ver=5, properties=props)26# Second auth27# ===========28props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")29props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "step1")30reauth2_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_REAUTHENTICATE, properties=props)31# Server to client32props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")33props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "1pets")34auth2_1_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_CONTINUE_AUTHENTICATION, properties=props)35# Client to server36props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")37props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "supercalifragilisticexpialidocious")38auth2_2_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_CONTINUE_AUTHENTICATION, properties=props)39props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")40auth2_3_packet = mosq_test.gen_auth(reason_code=0, properties=props)41# Third auth - bad due to different method42# ========================================43props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "badmethod")44props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "step1")45reauth3_packet = mosq_test.gen_auth(reason_code=mqtt5_rc.MQTT_RC_REAUTHENTICATE, properties=props)46# Server to client47disconnect3_packet = mosq_test.gen_disconnect(reason_code=mqtt5_rc.MQTT_RC_PROTOCOL_ERROR, proto_ver=5)48broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port)49try:50 sock = mosq_test.do_client_connect(connect1_packet, auth1_1_packet, timeout=20, port=port, connack_error="auth1")51 mosq_test.do_send_receive(sock, auth1_2_packet, connack1_packet, "connack1")52 mosq_test.do_ping(sock, "pingresp1")53 mosq_test.do_send_receive(sock, reauth2_packet, auth2_1_packet, "auth2_1")54 mosq_test.do_send_receive(sock, auth2_2_packet, auth2_3_packet, "auth2_3")55 mosq_test.do_ping(sock, "pingresp2")56 mosq_test.do_send_receive(sock, reauth3_packet, disconnect3_packet, "disconnect3")57 rc = 058 sock.close()59finally:60 os.remove(conf_file)61 broker.terminate()62 broker.wait()63 (stdo, stde) = broker.communicate()64 if rc:65 print(stde.decode('utf-8'))...

Full Screen

Full Screen

09-extended-auth-single.py

Source:09-extended-auth-single.py Github

copy

Full Screen

1#!/usr/bin/env python2# Multi tests for extended auth with a single step.3# * Error in plugin4# * No matching authentication method5# * Matching authentication method, but auth rejected6# * Matching authentication method, auth succeeds7# * Matching authentication method, auth succeeds, new auth data sent back to client8from mosq_test_helper import *9def write_config(filename, port):10 with open(filename, 'w') as f:11 f.write("port %d\n" % (port))12 f.write("auth_plugin c/auth_plugin_extended_single.so\n")13port = mosq_test.get_port()14conf_file = os.path.basename(__file__).replace('.py', '.conf')15write_config(conf_file, port)16rc = 117# Single, error in plugin18props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "error")19connect1_packet = mosq_test.gen_connect("client-params-test1", keepalive=42, proto_ver=5, properties=props)20# Single, no matching authentication method21props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "non-matching")22connect2_packet = mosq_test.gen_connect("client-params-test2", keepalive=42, proto_ver=5, properties=props)23connack2_packet = mosq_test.gen_connack(rc=mqtt5_rc.MQTT_RC_BAD_AUTHENTICATION_METHOD, proto_ver=5, properties=None)24# Single step, matching method, failure25props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "single")26props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "baddata")27connect3_packet = mosq_test.gen_connect("client-params-test3", keepalive=42, proto_ver=5, properties=props)28connack3_packet = mosq_test.gen_connack(rc=mqtt5_rc.MQTT_RC_NOT_AUTHORIZED, proto_ver=5, properties=None)29# Single step, matching method, success30props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "single")31props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "data")32connect4_packet = mosq_test.gen_connect("client-params-test5", keepalive=42, proto_ver=5, properties=props)33props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "single")34connack4_packet = mosq_test.gen_connack(rc=0, proto_ver=5, properties=props)35# Single step, matching method, success, auth data back to client36props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")37props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "somedata")38connect5_packet = mosq_test.gen_connect("client-params-test6", keepalive=42, proto_ver=5, properties=props)39props = mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_METHOD, "mirror")40props += mqtt5_props.gen_string_prop(mqtt5_props.PROP_AUTHENTICATION_DATA, "atademos")41connack5_packet = mosq_test.gen_connack(rc=0, proto_ver=5, properties=props)42broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port)43try:44 sock = mosq_test.do_client_connect(connect1_packet, b"", timeout=20, port=port)45 sock.close()46 sock = mosq_test.do_client_connect(connect2_packet, connack2_packet, timeout=20, port=port)47 sock.close()48 sock = mosq_test.do_client_connect(connect3_packet, connack3_packet, timeout=20, port=port)49 sock.close()50 sock = mosq_test.do_client_connect(connect4_packet, connack4_packet, timeout=20, port=port)51 sock.close()52 sock = mosq_test.do_client_connect(connect5_packet, connack5_packet, timeout=20, port=port)53 sock.close()54 rc = 055finally:56 os.remove(conf_file)57 broker.terminate()58 broker.wait()59 (stdo, stde) = broker.communicate()60 if rc:61 print(stde.decode('utf-8'))...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';4import { action } from '@storybook/addon-actions';5import MyComponent from './MyComponent';6storiesOf('MyComponent', module)7 .addDecorator(withKnobs)8 .add('with text', () => (9 foo={text('foo', 'bar')}10 bar={boolean('bar', false)}11 baz={number('baz', 42)}12 onClick={action('clicked')}13 ));

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { withProps } from 'storybook-root-decorator';4const stories = storiesOf('test', module);5stories.add('test', withProps({ prop: 'value' })(() => <div />));6import { addDecorator } from '@storybook/react';7import { withProps } from 'storybook-root-decorator';8addDecorator(withProps({ prop: 'value' }));9import { addDecorator } from '@storybook/react';10import { withProps } from 'storybook-root-decorator';11addDecorator(withProps({ prop: 'value' }));12import { addDecorator } from '@storybook/react';13import { withProps } from 'storybook-root-decorator';14addDecorator(withProps({ prop: 'value' }));15import { addDecorator } from '@storybook/react';16import { withProps } from 'storybook-root-decorator';17addDecorator(withProps({ prop: 'value' }));18import { addDecorator } from '@storybook/react';19import { withProps } from 'storybook-root-decorator';20addDecorator(withProps({ prop: 'value' }));21import { addDecorator } from '@storybook/react';22import { withProps } from 'storybook-root-decorator';23addDecorator(withProps({ prop: 'value' }));24import { addDecorator } from '@storybook/react';25import { withProps } from 'storybook-root-decorator';26addDecorator(withProps({ prop: 'value' }));27import { addDecorator } from '@storybook/react';28import { withProps } from 'storybook-root-decorator';29addDecorator(withProps({ prop: 'value' }));30import { addDecorator } from '@storybook/react';31import { withProps } from 'storybook-root-decorator';32addDecorator(withProps({ prop: 'value' }));33import { addDecorator } from '@storybook/react';34import { withProps } from 'storybook-root-decorator';35addDecorator(withProps({ prop: 'value' }));36import

Full Screen

Using AI Code Generation

copy

Full Screen

1import { props } from 'storybook-root-decorator';2import { storiesOf } from '@storybook/react';3import MyComponent from './MyComponent';4storiesOf('MyComponent', module)5 .addDecorator(props({ name: 'World' }))6 .add('with name', () => <MyComponent />);7import { withProps } from 'storybook-root-decorator';8import React from 'react';9const MyComponent = ({ name }) => <div>Hello {name}</div>;10export default withProps(MyComponent);11import React from 'react';12import { shallow } from 'enzyme';13import MyComponent from './MyComponent';14describe('MyComponent', () => {15 it('should render', () => {16 const wrapper = shallow(<MyComponent name="World" />);17 expect(wrapper.text()).toBe('Hello World');18 });19});20import { props } from 'storybook-root-decorator';21storiesOf('MyComponent', module)22 .addDecorator(props({ name: 'World' }))23 .add('with name', () => <MyComponent />);24import { withProps } from 'storybook-root-decorator';25const MyComponent = ({ name }) => <div>Hello {name}</div>;26export default withProps(MyComponent);27MIT © [Rajat S](

Full Screen

Using AI Code Generation

copy

Full Screen

1const props = require('storybook-root-decorator').props;2const { storiesOf } = require('@storybook/react');3const { withKnobs, text } = require('@storybook/addon-knobs');4const MyComponent = require('./MyComponent');5storiesOf('MyComponent', module)6 .addDecorator(withKnobs)7 .add('with default props', () => <MyComponent {...props()} />)8 .add('with custom props', () => (9 {...props({10 text: text('text', 'Hello world!'),11 })}12 ));13const MyComponent = ({ text }) => <div>{text}</div>;14module.exports = MyComponent;15props(options)

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful