Best JavaScript code snippet using storybook-root
StoryWin.ts
Source:StoryWin.ts
1/*2 * @Author: zhoulanglang 3 * @Date: 2020-07-14 11:14:29 4 * @Last Modified by: zhoulanglang5 * @Last Modified time: 2020-07-17 21:02:496 */7class StoryWin extends BaseEuiView {8 private img: eui.Image9 private arr1 = ["story2_00_png", "story2_01_png", "story2_03_png", 'story2_04_png', 'story2_06_png', 'story2_07_png', 'story2_09_png', 'story2_10_png', 'story2_12_png', 'story2_13_png', 'story2_15_png', 'story2_16_png', 'story2_18_png', 'story2_19_png', 'story2_21_png', 'story2_22_png', 'story2_24_png', 'story2_25_png', 'story2_27_png', 'story2_28_png', 'story2_30_png', 'story2_31_png', 'story2_33_png', 'story2_34_png',]10 private arr2 = ['story3_00_png', 'story3_02_png', 'story3_03_png', 'story3_05_png', 'story3_06_png', 'story3_08_png', 'story3_09_png', 'story3_11_png', 'story3_12_png', 'story3_14_png', 'story3_15_png', 'story3_17_png', 'story3_18_png', 'story3_20_png', 'story3_21_png', 'story3_23_png', 'story3_24_png', 'story3_26_png', 'story3_27_png', 'story3_29_png', 'story3_30_png', 'story3_32_png', 'story3_33_png', 'story3_35_png', 'story3_36_png', 'story3_38_png', 'story3_39_png', 'story3_41_png', 'story3_42_png', 'story3_44_png', 'story3_45_png', 'story3_47_png', 'story3_48_png']11 private arr3 = [12 'story4_00_png', 'story4_01_png', 'story4_02_png', 'story4_03_png', 'story4_04_png', 'story4_05_png', 'story4_06_png', 'story4_07_png', 'story4_08_png', 'story4_09_png', 'story4_10_png', 'story4_11_png', 'story4_12_png', 'story4_13_png', 'story4_14_png', 'story4_15_png', 'story4_16_png', 'story4_17_png', 'story4_18_png', 'story4_19_png', 'story4_20_png', 'story4_21_png', 'story4_22_png', 'story4_23_png', 'story4_24_png', 'story4_25_png', 'story4_26_png', 'story4_27_png', 'story4_28_png', 'story4_29_png', 'story4_30_png', 'story4_31_png', 'story4_32_png', 'story4_33_png', 'story4_34_png', 'story4_35_png', 'story4_36_png', 'story4_37_png', 'story4_38_png', 'story4_39_png', 'story4_40_png', 'story4_41_png', 'story4_42_png', 'story4_43_png', 'story4_44_png', 'story4_45_png', 'story4_46_png', 'story4_47_png', 'story4_48_png', 'story4_49_png', 'story4_50_png', 'story4_51_png', 'story4_52_png', 'story4_53_png', 'story4_54_png', 'story4_55_png', 'story4_56_png', 'story4_57_png', 'story4_58_png', 'story4_59_png', 'story4_60_png', 'story4_61_png', 'story4_62_png', 'story4_63_png', 'story4_64_png', 'story4_65_png', 'story4_66_png', 'story4_67_png', 'story4_68_png', 'story4_69_png', 'story4_70_png', 'story4_71_png', 'story4_72_png', 'story4_73_png', 'story4_74_png', 'story4_75_png'13 ]14 cur = 015 next = 016 callBack: Function17 public constructor() {18 super();19 this.skinName = 'StorySkin'20 }21 public open(...param: any[]): void {22 this.addTouchEvent(this.img, this.onClick);23 this.callBack = param[0]24 this.upView()25 }26 private async upView() {27 // await RES.loadGroup('storyGroup')28 ViewManager.ins().close(LoadingUI)29 this.cur = 030 this.img.source = this.arr1[this.cur]31 TimerManager.ins().doTimer(1000 / 8, 0, this.fun, this)32 }33 fun() {34 this.cur++35 if (this.cur >= this.arr1.length) {36 TimerManager.ins().remove(this.fun, this)37 return38 }39 this.img.source = this.arr1[this.cur]40 }41 fun2() {42 this.cur++43 if (this.cur >= this.arr2.length) {44 TimerManager.ins().remove(this.fun2, this)45 return46 }47 this.img.source = this.arr2[this.cur]48 }49 fun3() {50 this.cur++51 if (this.cur >= this.arr3.length) {52 return53 }54 this.img.source = this.arr3[this.cur]55 }56 end() {57 TimerManager.ins().removeAll(this)58 this.callBack && this.callBack()59 ViewManager.ins().close(this)60 RES.destroyRes('storyGroup')61 }62 public close(...param: any[]): void {63 this.callBack = null64 }65 private onClick(e: egret.TouchEvent): void {66 switch (e.currentTarget) {67 case this.img:68 if (this.next == 0) {69 if (this.cur >= this.arr1.length) {70 this.next = 171 this.cur = 072 this.img.source = this.arr2[this.cur]73 TimerManager.ins().doTimer(1000 / 8, 0, this.fun2, this)74 }75 }76 else if (this.next == 1) {77 if (this.cur >= this.arr2.length) {78 this.next = 279 this.cur = 080 this.img.source = this.arr3[this.cur]81 TimerManager.ins().doTimer(1000 / 8, 0, this.fun3, this)82 }83 }84 else if (this.next == 2) {85 if (this.cur >= this.arr3.length || this.cur >= 60) {86 let obj = { isFinish: true }87 CacheUtil.set(Constant.STORY_DATA, JSON.stringify(obj))88 this.end()89 }90 }91 break;92 }93 }94}95ViewManager.ins().reg(StoryWin, LayerManager.UI_Popup);...
addon-actions.stories.js
Source:addon-actions.stories.js
1import { withActions } from '@storybook/addon-actions';2const buttonStory = () => () => `<button type="button">Hello World</button>`;3export default {4 title: 'Addons/Actions',5};6export const Story1 = buttonStory();7Story1.storyName = 'Hello World';8Story1.parameters = {9 actions: {10 handles: ['click'],11 },12};13export const Story2 = buttonStory();14Story2.storyName = 'Multiple actions';15Story2.parameters = {16 actions: {17 handles: ['click', 'contextmenu'],18 },19};20export const Story3 = buttonStory();21Story3.storyName = 'Multiple actions + config';22Story3.parameters = {23 actions: {24 handles: ['click', 'contextmenu', { clearOnStoryChange: false }],25 },26};27export const Story4 = buttonStory();28Story4.storyName = 'Multiple actions, object';29Story4.parameters = {30 actions: {31 handles: [{ click: 'clicked', contextmenu: 'right clicked' }],32 },33};34export const Story5 = () => `35 <div>36 Clicks on this button will be logged: <button class="btn" type="button">Button</button>37 </div>38 `;39Story5.storyName = 'Multiple actions, selector';40Story5.parameters = {41 actions: {42 handles: [{ 'click .btn': 'clicked', contextmenu: 'right clicked' }],43 },44};45export const Story6 = buttonStory();46Story6.storyName = 'Multiple actions, object + config';47Story6.parameters = {48 actions: {49 handles: [{ click: 'clicked', contextmenu: 'right clicked' }, { clearOnStoryChange: false }],50 },51};52export const DeprecatedDecoratorsStory1 = buttonStory();53DeprecatedDecoratorsStory1.storyName = 'Deprecated decorators - Single action';54DeprecatedDecoratorsStory1.decorators = [withActions('click')];55export const DeprecatedDecoratorsStory2 = buttonStory();56DeprecatedDecoratorsStory2.storyName = 'Deprecated decorators - Multiple actions';57DeprecatedDecoratorsStory2.decorators = [withActions('click', 'contextmenu')];58export const DeprecatedDecoratorsStory3 = buttonStory();59DeprecatedDecoratorsStory3.storyName = 'Deprecated decorators - Multiple actions + config';60DeprecatedDecoratorsStory3.decorators = [61 withActions('click', 'contextmenu', { clearOnStoryChange: false }),62];63export const DeprecatedDecoratorsStory4 = buttonStory();64DeprecatedDecoratorsStory4.storyName = 'Deprecated decorators - Multiple actions, object';65DeprecatedDecoratorsStory4.decorators = [66 withActions({ click: 'clicked', contextmenu: 'right clicked' }),...
arrayCarrousel.ts
Source:arrayCarrousel.ts
1export const Recomendado = [2 "XMenWolverine",3 "Violetta",4 "Mulan",5 "WandaVision",6 "Soul",7 "StarWars",8 "phinFerb",9 "ToyStory4",10 "Frozen2",11 "AvengersEndGame",12];13export const Lançamentos = [14 "WandaVision",15 "Soul",16 "phinFerb",17 "Frozen2",18 "ToyStory4",19 "Violetta",20 "StarWars",21 "XMenWolverine",22 "Mulan",23 "AvengersEndGame",24];25export const Originals = [26 "StarWars",27 "phinFerb",28 "Frozen2",29 "Mulan",30 "AvengersEndGame",31 "Violetta",32 "WandaVision",33 "XMenWolverine",34 "ToyStory4",35 "Soul",36];37export const Populares = [38 "Violetta",39 "WandaVision",40 "XMenWolverine",41 "ToyStory4",42 "Soul",43 "StarWars",44 "phinFerb",45 "Frozen2",46 "Mulan",47 "AvengersEndGame",48];49export const Marvel = [50 "AvengersEndGame",51 "WandaVision",52 "XMenWolverine",53 "AvengersEndGame",54 "WandaVision",55 "XMenWolverine",56 "AvengersEndGame",57 "WandaVision",58 "XMenWolverine",59 "AvengersEndGame",...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!