Best JavaScript code snippet using storybook-root
ability-ids.ts
Source:ability-ids.ts
1export const ABIL_CREWMEMBER_INFO = FourCC('A008');2export const ABIL_HUMAN_SPRINT = FourCC('A003');3export const ABIL_INQUIS_PURITY_SEAL = FourCC('A012');4export const ABIL_INQUIS_PURITY_SEAL_DUMMY = FourCC('A011');5export const ABIL_INQUIS_SMITE = FourCC('A013');6export const ABIL_INQUIS_CHURCH_CONSECRATED_AREA = FourCC('A02A');7export const ABIL_LEAVE_ASKELLON_CONTROLS = FourCC('A00N');8export const ABIL_DESPAIR = FourCC('A00D');9export const ABIL_RESOLVE = FourCC('A007');10export const ABIL_VOID_SICKNESS_APPLY = FourCC('A029');11export const ABIL_DEFILER_INFESTATION_APPLY = FourCC('A03I');12// Misc13export const ABILITY_SLOW_ID = FourCC('A00B');14// Alien abilities15export const ABIL_TRANSFORM_HUMAN_ALIEN = FourCC('TF01');16export const ABIL_TRANSFORM_ALIEN_HUMAN = FourCC('TF02');17export const ABIL_ALIEN_LATCH = FourCC('A015');18export const ABIL_ALIEN_BRAIN_FEAST = FourCC('A020');19export const ABIL_ALIEN_ACID_POOL = FourCC('ACID');20export const ABIL_ALIEN_ACID_HURL = FourCC('ASPI');21export const ABIL_ALIEN_LEAP = FourCC('LEAP');22export const ABIL_ALIEN_SCREAM = FourCC('A00G');23export const ABIL_ALIEN_CHARGE = FourCC('A00Z');24export const ABIL_ALIEN_SURVIVAL_INSTINCTS = FourCC('A016');25export const ABIL_ALIEN_NEURAL_TAKEOVER = FourCC('A018');26export const ABIL_ALIEN_FRENZY = FourCC('A01I');27export const ABIL_ALIEN_LEAP_MINION = FourCC('A036');28export const ABIL_ALIEN_BERSERK_MINION = FourCC('A037');29export const ABIL_ALIEN_BERSERK_HATCHERY = FourCC('A03T');30export const ABIL_ALIEN_SPAWN_HORDE = FourCC('A03W');31export const ABIL_ALIEN_EVOLVE_T1 = FourCC('A014');32export const ABIL_ALIEN_EVOLVE_T1_SPELLBOOK = FourCC('A025');33export const ABIL_ALIEN_EVOLVE_T2 = FourCC('A00U');34export const ABIL_ALIEN_EVOLVE_T3_DEFILER = FourCC('A031');35export const ABIL_ALIEN_EVOLVE_T2_SPELLBOOK = FourCC('A028');36export const ABIL_ALIEN_EVOLVE_T3 = FourCC('A00Y');37export const ABIL_ALIEN_EVOLVE_T3_SPELLBOOK = FourCC('A00Y');38export const ABIL_ALIEN_EVOLVE_ARMOR = FourCC('A00V');39export const ABIL_ALIEN_EVOLVE_T2_INFESTATION = FourCC('A03M');40export const ABIL_ALIEN_MINION_EVOLVE = FourCC('A01R');41export const ABIL_ALIEN_MINION_PLACE_EGG = FourCC('A01S');42export const ABIL_SHIP_CHAINGUN = FourCC('A00O');43export const ABIL_SHIP_DEEP_SCAN = FourCC('A00R');44export const ABIL_SHIP_BARREL_ROLL_RIGHT = FourCC('A001');45export const ABIL_SHIP_BARREL_ROLL_LEFT = FourCC('A006');46export const ABIL_SHIP_LASER = FourCC('A00S');47export const ABIL_STUN_25 = FourCC('A010');48export const ABIL_WEP_GRENADE = FourCC('GREN');49export const ABIL_WEP_DIODE_EJ = FourCC('DIOJ');50export const ABIL_WEP_MINIGUN = FourCC('A01A');51export const ABIL_WEP_MINIGUN_OVERSIZED = FourCC('A01B');52export const ABIL_WEP_MINIGUN_FULLER_AUTO = FourCC('A02D');53export const ABIL_WEP_NEOKATANA = FourCC('A022');54export const ABIL_WEP_FLAMETHROWER = FourCC('A02S');55export const ABIL_ITEM_REPAIR = FourCC('A00J');56export const ABIL_ITEM_TRIFEX = FourCC('A00P');57export const ABIL_ACCURACY_PENALTY_30 = FourCC('A00E');58export const ABIL_ACCURACY_BONUS_30 = FourCC('A00F');59export const FIRE_ARMOR_REDUCTION = FourCC('AFIR');60export const SPRINT_BUFF_ID = FourCC('B000');61export const TECH_WEP_DAMAGE = FourCC('RDAM');62export const TECH_MAJOR_WEAPONS_PRODUCTION = FourCC('RWEP');63export const TECH_MAJOR_HEALTHCARE = FourCC('RMED');64export const TECH_MAJOR_VOID = FourCC('RSPC');65export const TECH_MAJOR_RELIGION = FourCC('R007');66export const TECH_MAJOR_REACTOR = FourCC('R00A');67export const TECH_MAJOR_SECURITY = FourCC('R00F');68export const TECH_MAJOR_REPAIR_TESTER = FourCC('R00R');69export const TECH_INCREASE_SECURITY_VISION_HEALTH = FourCC('R00G');70export const TECH_NO_UNIT_IN_SPLICER = FourCC('RGEN');71export const TECH_MINERALS_PROGRESS = FourCC('R00E');72export const TECH_NO_GENES_TIER_1 = FourCC('RGN1');73export const TECH_NO_GENES_TIER_2 = FourCC('RGN2');74export const TECH_NO_GENES_TIER_3 = FourCC('RGN3');75export const TECH_HERO_LEVEL = FourCC('R003');76export const TECH_PLAYER_INFESTS = FourCC('R006');77export const TECH_HAS_GENES_TIER_1 = FourCC('RPG1');78export const TECH_HAS_GENES_TIER_2 = FourCC('RPG2');79export const TECH_HAS_GENES_TIER_3 = FourCC('RPG3');80export const TECH_ITEMS_IN_GENETIC_SEQUENCER = FourCC('R008');81export const ABIL_ACTIVATE_SEQUENCER_TEST = FourCC('A019');82export const TECH_20_RANGE_UPGRADE = FourCC('R004');83export const TECH_ROACH_DUMMY_UPGRADE = FourCC('R005');84export const TECH_LATCHED_IN_HUMAN = FourCC('R009');85export const TECH_LATCHED_IN_WHATEVER = FourCC('R00C');86export const TECH_CREW_ARMOR_HITPOINTS_INCREASE = FourCC('R00D');87// Infested Genetics Abilities88export const GENE_INFESTED_1 = FourCC('A02C');89export const GENE_INSTALL_NIGHTEYE = FourCC('A00I');90export const ABIL_GENE_NIGHTEYE = FourCC('A033');91export const ABIL_GENE_COSMIC = FourCC('ACSM');92export const ABIL_GENE_XENOPHOBIC = FourCC('A01L');93export const ABIL_GENE_REMOVE_VOCAL = FourCC('A02T');94export const UPGR_REMOVED_VOCAL_CHORDS = FourCC('R00N');95export const ABIL_REMOVED_VOCAL_CHORDS = FourCC('A02U');96export const GENE_INSTALL_MOBILITY = FourCC('AGJP');97export const GENE_TECH_MOBILITY = FourCC('R001');98export const GENE_TECH_PSI_POTENCY = FourCC('R00H');99export const GENE_INSTALL_XENOPHOBIC = FourCC('A01K');100export const ABIL_GENE_XENOPHOBIC_PUNCH = FourCC('A01M');101export const GENE_INSTALL_PSIONIC_POTENCY = FourCC('AGPS');102export const GENE_INSTALL_COSMIC_SENSITIVITY = FourCC('AGCM');103export const GENE_INSTALL_OSBORNE_GENE = FourCC('A01N');104export const ABIL_GENE_INSTANT_HEAL= FourCC('A01O');105export const ABIL_GENE_MIND_LASH = FourCC('A03K');106export const SMART_ORDER_ID = 851971;107export const MOVE_ORDER_ID = 851986;108export const STOP_ORDER_ID = 851972;109export const HOLD_ORDER_ID = 851993;110export const UNIT_IS_FLY = FourCC('A00C');111export const TECH_CREWMEMBER_ATTACK_ENABLE = FourCC('RATK');112export const ABIL_ITEM_EMOTIONAL_DAMP = FourCC('A00L');113export const ABIL_ITEM_CRYO_GRENADE = FourCC('A00M');114export const ABIL_ITEM_HELLFIRE_GRENADE = FourCC('A01F');115export const ABIL_ITEM_GENETIC_SAMPLER = FourCC('A017');116export const ABIL_ITEM_GENETIC_SAMPLE_INFESTED = FourCC('A018');117export const ABIL_ITEM_DRUG_COMEBACK = FourCC('A02V');118export const ABIL_U_DEX = FourCC('uDex');119export const ABIL_SYSTEM_REACTOR_DIAGNOSTICS = FourCC('A01P');120export const ABIL_SYSTEM_REACTOR_DIVERT_WEAPONS = FourCC('A01X');121export const TECH_DUMMY_DIVERT_WEAPONS = FourCC('R00B');122export const ABIL_SYSTEM_REACTOR_ROTATE_SHIELD_FREQUENCY = FourCC('A01W');123export const ABIL_SYSTEM_PURGE_VENTS = FourCC('A01C');124export const ABIL_SYSTEM_PURGE_VENTS_BRIDGE = FourCC('A038');125export const ABIL_GO_BACK_TO_ADMIN_CONTROLS = FourCC('A03C');126export const ABIL_SECURITY_TARGET_PLAYER_1 = FourCC('AC01');127export const ABIL_SECURITY_TARGET_PLAYER_2 = FourCC('AC02');128export const ABIL_SECURITY_TARGET_PLAYER_3 = FourCC('AC03');129export const ABIL_SECURITY_TARGET_PLAYER_4 = FourCC('AC04');130export const ABIL_SECURITY_TARGET_PLAYER_5 = FourCC('AC05');131export const ABIL_SECURITY_TARGET_PLAYER_6 = FourCC('AC06');132export const ABIL_SECURITY_TARGET_PLAYER_7 = FourCC('AC07');133export const ABIL_SECURITY_TARGET_PLAYER_8 = FourCC('AC08');134export const ABIL_SECURITY_TARGET_PLAYER_9 = FourCC('AC09');135export const ABIL_SECURITY_TARGET_PLAYER_10 = FourCC('AC10');136export const ABIL_SECURITY_TARGET_PLAYER_11 = FourCC('AC11');137export const ABIL_SECURITY_TARGET_PLAYER_12 = FourCC('AC12');138export const ABIL_ASKELLON_BROADSIDE_LEFT = FourCC('A01U');139export const ABIL_ASKELLON_BROADSIDE_RIGHT = FourCC('A01V');140export const ABIL_ACTIVATE_SCAN_CREW = FourCC('A023');141export const ABIL_ACTIVATE_SCAN_ALIENS = FourCC('A024');142export const ABIL_ID_SECURITY_TARGETING = FourCC('A03A');143export const ABIL_ID_LOCKDOWN = FourCC('A03B');144export const ABIL_ITEM_ATTACH_METEOR_CANISTER = FourCC('A02M');145export const ABIL_TEXTURE_CHANGER = FourCC('A03J')146export const ABIL_SECURITY_TARGET_ALL = [147 ABIL_SECURITY_TARGET_PLAYER_1,148 ABIL_SECURITY_TARGET_PLAYER_2,149 ABIL_SECURITY_TARGET_PLAYER_3,150 ABIL_SECURITY_TARGET_PLAYER_4,151 ABIL_SECURITY_TARGET_PLAYER_5,152 ABIL_SECURITY_TARGET_PLAYER_6,153 ABIL_SECURITY_TARGET_PLAYER_7,154 ABIL_SECURITY_TARGET_PLAYER_8,155 ABIL_SECURITY_TARGET_PLAYER_9,156 ABIL_SECURITY_TARGET_PLAYER_10,157 ABIL_SECURITY_TARGET_PLAYER_11,158 ABIL_SECURITY_TARGET_PLAYER_12,159];160export const ABIL_DUMMY_FLAMESTRIKE = FourCC('A03E');161export const ABIL_ID_REACTOR_PLATING = FourCC('A03F');162export const ABIL_ID_GENERATOR_PLATING = FourCC('A03G');163export const ABIL_DROP_MINERALS = FourCC('A01Y');164export const ABIL_SHIP_AFTERBURNER = FourCC('A000');165export const TECH_OUT_OF_COMBAT = FourCC('R00Q');166export const ABIL_CULTIST_INFO = FourCC('A02I');167export const ABIL_APPLY_MADNESS = FourCC('A02J');168export const ABIL_ALTAR_IS_BUILT = FourCC('A02L');169export const ABIL_DISARM_USER = FourCC('Abun');170export const ABIL_CULTIST_CEREMONIAL_DAGGER = FourCC('A02K');171export const ABIL_REPAIR_NEOKATANA = FourCC('A02N');172export const ABIL_NEOKATANA_PASSIVE = FourCC('A026');173export const ABIL_EGG_HATCH_NEUTRAL = FourCC('A02O');174export const ABIL_ALIEN_CREATE_TUMOR = FourCC('A02P');175export const ABIL_CULTIST_GIFT_MADNESS = FourCC('A02Q');176export const ABIL_CULTIST_DARK_THRALL = FourCC('A034');177export const ABIL_CULTIST_CONVOKE_CARRION = FourCC('A035');178export const ABIL_CULTIST_T1_PERNICIOUS_POWER = FourCC('A03Y');179export const ABIL_CULTIST_T1_GLUTTONY = FourCC('A03Z');180export const ABIL_CULTIST_T1_GRAVE_GIFT = FourCC('A03X');181export const ABIL_CULTIST_T2_DELICIOUS_DECAY = FourCC('A040');182export const ABIL_MOVESPEED_BONUS_30 = FourCC('A02Y');183export const ABIL_LIFE_REGEN_BONUS_25 = FourCC('A02Y');184export const ABIL_MAX_LIFE_BONUS_200 = FourCC('A02X');185export const ABIL_ITEM_REMOTE_BOMB = FourCC('A02Z');186export const ABIL_ALIEN_WEBSHOT = FourCC('A02F');187export const ABIL_ALIEN_BROODNEST = FourCC('A02E');188export const ABIL_ALIEN_DEFILER_INFESTATION = FourCC('A030');189export const ABIL_ALIEN_WEBWALK = FourCC('A02G');...
FourOhFour.jsx
Source:FourOhFour.jsx
1import { useRef, useEffect } from 'react';2import styled from 'styled-components';3import PropTypes from 'prop-types';4import { deviceWidthQuery, color, zIndexNumber } from '@jbkr/style-service';5import { Copy } from '../../core/Copy/Copy';6import { Button } from '../../core/Button/Button';7import { ScreenTitlePrimary } from '../Common/ScreenTitlePrimary';8const videoCommonAttributes = {9 'autoPlay': true,10 'muted': true,11 'loop': true,12 'playsInline': true,13 'tabIndex': '-1',14 'aria-hidden': true,15};16const BackgroundOverlay = styled.div`17 position: absolute;18 top: 0;19 left: 0;20 width: 100%;21 height: 100%;22 z-index: ${zIndexNumber().fourOhFourBackgroundOverlay};23 ${deviceWidthQuery.not({ 'width': 'l' })} {24 background-image:25 linear-gradient(26 to bottom,27 ${color({28 'kind': 'Neutral',29 'tone': 'Finch',30 'level': 35,31 'alpha': .75,32 'format': 'string'33 })} 0,34 ${color({35 'kind': 'Neutral',36 'tone': 'Finch',37 'level': 37,38 'alpha': .85,39 'format': 'string'40 })} 15rem,41 ${color({42 'kind': 'Neutral',43 'tone': 'Finch',44 'level': 37,45 'alpha': 1,46 'format': 'string'47 })} 90%48 );49 }50 ${deviceWidthQuery.only({ 'width': 'l' })} {51 background-image:52 radial-gradient(53 ellipse at top right,54 ${color({55 'kind': 'Neutral',56 'tone': 'Finch',57 'level': 35,58 'alpha': 1,59 'format': 'string'60 })} 0%,61 ${color({62 'kind': 'Neutral',63 'tone': 'Finch',64 'level': 35,65 'alpha': .8,66 'format': 'string'67 })} 25%,68 ${color({69 'kind': 'Neutral',70 'tone': 'Finch',71 'level': 35,72 'alpha': 0,73 'format': 'string'74 })} 70%75 ),76 linear-gradient(77 to bottom,78 ${color({79 'kind': 'Neutral',80 'tone': 'Finch',81 'level': 35,82 'alpha': .6,83 'format': 'string'84 })} 0,85 ${color({86 'kind': 'Neutral',87 'tone': 'Finch',88 'level': 36,89 'alpha': .8,90 'format': 'string'91 })} 35%,92 ${color({93 'kind': 'Neutral',94 'tone': 'Finch',95 'level': 37,96 'alpha': .9,97 'format': 'string'98 })} 70%,99 ${color({100 'kind': 'Neutral',101 'tone': 'Finch',102 'level': 37,103 'alpha': 1,104 'format': 'string'105 })} 99%106 );107 }108`;109const FourOhFourContainer = styled.div`110 ${deviceWidthQuery.not({ 'width': 'l' })} {111 margin-top: 23rem;112 }113 ${deviceWidthQuery.only({ 'width': 'l' })} {114 position: relative;115 width: 100%;116 max-width: 180rem;117 margin: 14rem auto 0;118 }119`;120const MainContentContainer = styled.main.attrs(() => {121 return {122 'id': 'main-content',123 };124})``;125const FourOhFourHeader = styled.header`126 ${deviceWidthQuery.not({ 'width': 'l' })} {127 padding: 0 2rem 8rem 2rem;128 }129 ${deviceWidthQuery.only({ 'width': 'l' })} {130 width: calc(100% - 4rem);131 max-width: 150rem;132 margin: 0 auto;133 padding: 15rem 0 0 0;134 text-align: left;135 }136`;137const FourOhFourBody = styled.div`138 width: 100%;139 min-height: calc(100vh - 71rem);140 transform: translateY(6rem);141 opacity: 0;142 overflow: hidden;143 transition: all 1.5s .5s;144 &.animation-state--final {145 transform: translateY(0);146 opacity: 1;147 }148 ${deviceWidthQuery.not({ 'width': 's' })} {149 height: 75rem;150 }151 ${deviceWidthQuery.only({ 'width': 'l' })} {152 z-index: ${zIndexNumber().fourOhFourContainer};153 }154`;155const VideoLargeDevice = styled.video.attrs(() => videoCommonAttributes)`156 ${deviceWidthQuery.not({ 'width': 'l' })} {157 display: none;158 }159 ${deviceWidthQuery.only({ 'width': 'l' })} {160 position: absolute;161 top: 0;162 left: 0;163 width: 100%;164 border-radius: .375rem;165 object-position: center top;166 object-fit: cover;167 z-index: ${zIndexNumber().fourOhFourBackgroundVideo};168 }169 @media (prefers-reduced-motion: reduce) {170 display: none;171 }172`;173const VideoNotLargeDevice = styled.video.attrs(() => videoCommonAttributes)`174 ${deviceWidthQuery.not({ 'width': 'l' })} {175 position: absolute;176 top: 0;177 left: 0;178 width: 100%;179 height: 100%;180 object-position: center top;181 object-fit: cover;182 z-index: ${zIndexNumber().fourOhFourBackgroundVideo};183 }184 ${deviceWidthQuery.only({ 'width': 'l' })} {185 display: none;186 }187 ${deviceWidthQuery.only({ 'width': 's' })} {188 display: none;189 }190 @media (prefers-reduced-motion: reduce) {191 display: none;192 }193`;194const ImageLargeDevice = styled.div`195 ${deviceWidthQuery.not({ 'width': 'l' })} {196 display: none;197 }198 ${deviceWidthQuery.only({ 'width': 'l' })} {199 position: absolute;200 top: 0;201 left: 0;202 width: 100%;203 height: 100%;204 z-index: ${zIndexNumber().fourOhFourBackgroundImage};205 ${206 ({ $imageURL }) => `background-image: url('${$imageURL}');`207 }208 background-size: cover;209 background-repeat: no-repeat;210 }211 @media (prefers-reduced-motion: no-preference) {212 display: none;213 }214`;215const ImageNotLargeDevice = styled.div`216 ${deviceWidthQuery.not({ 'width': 'l' })} {217 position: absolute;218 top: 0;219 left: 0;220 width: 100%;221 height: 100%;222 z-index: ${zIndexNumber().fourOhFourBackgroundImage};223 ${224 ({ $imageURL }) => `background-image: url('${$imageURL}');`225 }226 background-size: cover;227 background-repeat: no-repeat;228 }229 ${deviceWidthQuery.only({ 'width': 'l' })} {230 display: none;231 }232 @media (prefers-reduced-motion: no-preference) {233 display: none;234 }235`;236// ============237const ContentConstrainer = styled.div`238 position: relative;239 margin-top: 0;240 z-index: ${zIndexNumber().fourOhFourContent};241 ${deviceWidthQuery.not({ 'width': 's' })} {242 margin-top: 40rem;243 }244`;245const ContentBackground = styled.div`246 background-color: ${color({247 'kind': 'Neutral',248 'tone': 'Finch',249 'level': 39,250 'alpha': 1,251 'format': 'string'252 })};253 @media (min-width: 648px) {254 width: 75%;255 margin: 0 25% 0 0;256 border-radius: 0 .375rem .375rem 0;257 }258 @media (min-width: 896px) {259 width: 50%;260 margin: 0 50% 0 0;261 border-radius: 0 .375rem .375rem 0;262 }263`;264const ContentContainer = styled.div`265 ${deviceWidthQuery.only({ 'width': 's' })} {266 padding: 2rem;267 }268 ${deviceWidthQuery.not({ 'width': 's' })} {269 width: calc(100% - 2rem);270 max-width: 75rem;271 padding: 5rem 3rem 5rem 2rem;272 }273 ${deviceWidthQuery.only({ 'width': 'l' })} {274 padding: 5rem 3rem 5rem 0;275 margin: 0 0 0 auto;276 }277`;278// ============279const LinksContainer = styled.div`280 padding-top: 2rem;281 a > span {282 padding-left: 0;283 padding-right: 0;284 transition: all .5s;285 }286 a:focus > span {287 padding-left: 1.875rem;288 padding-right: 1.875rem;289 }290`;291export const FourOhFour = ({292 title,293 media,294 text,295 links,296}) => {297 const fourOhFourBodyRef = useRef();298 useEffect(() => {299 fourOhFourBodyRef.current.classList.add('animation-state--final');300 });301 return (302 <FourOhFourContainer>303 <MainContentContainer>304 <FourOhFourHeader>305 <ScreenTitlePrimary306 titleVisible={title}307 />308 </FourOhFourHeader>309 <FourOhFourBody310 ref={fourOhFourBodyRef}311 >312 <VideoLargeDevice313 poster={media.imageLarge.url}314 >315 <source src={media.videoLarge.url} type="video/mp4" />316 </VideoLargeDevice>317 <VideoNotLargeDevice318 poster={media.imageSmall.url}319 >320 <source src={media.videoSmall.url} type="video/mp4" />321 </VideoNotLargeDevice>322 <ImageLargeDevice323 $imageURL={media.imageLarge.url}324 />325 <ImageNotLargeDevice326 $imageURL={media.imageSmall.url}327 />328 <BackgroundOverlay />329 <ContentConstrainer>330 <ContentBackground>331 <ContentContainer>332 <Copy333 kind="four-oh-four--secondary-header"334 >335 {text.headerSecondary}336 </Copy>337 <Copy338 kind="four-oh-four--paragraph"339 >340 {text.paragraph}341 </Copy>342 <LinksContainer>343 {344 links.map((link) =>345 <Button346 text={link.anchorText}347 url={link.url}348 iconAfter="arrow-right"349 size="standard"350 surfaceStyle="transparent"351 contextColor="onDark"352 key={link.key}353 />354 )355 }356 </LinksContainer>357 </ContentContainer>358 </ContentBackground>359 </ContentConstrainer>360 </FourOhFourBody>361 </MainContentContainer>362 </FourOhFourContainer>363 );...
binary-search-tree.spec.js
Source:binary-search-tree.spec.js
1var Bst = require('./binary-search-tree');2function recordAllData(bst) {3 var out = [];4 bst.each(function (data) { out.push(data); });5 return out;6}7describe('BinarySearchTree', function() {8 it('data is retained', function() {9 expect(new Bst(4).data).toEqual(4);10 });11 it('inserting less', function() {12 var four;13 four = new Bst(4);14 four.insert(2);15 expect(four.data).toEqual(4);16 expect(four.left.data).toEqual(2);17 });18 it('inserting same', function() {19 var four;20 four = new Bst(4);21 four.insert(4);22 expect(four.data).toEqual(4);23 expect(four.left.data).toEqual(4);24 });25 it('inserting right', function() {26 var four;27 four = new Bst(4);28 four.insert(5);29 expect(four.data).toEqual(4);30 expect(four.right.data).toEqual(5);31 });32 it('complex tree', function() {33 var four;34 four = new Bst(4);35 four.insert(2);36 four.insert(6);37 four.insert(1);38 four.insert(3);39 four.insert(7);40 four.insert(5);41 expect(four.data).toEqual(4);42 expect(four.left.data).toEqual(2);43 expect(four.left.left.data).toEqual(1);44 expect(four.left.right.data).toEqual(3);45 expect(four.right.data).toEqual(6);46 expect(four.right.left.data).toEqual(5);47 expect(four.right.right.data).toEqual(7);48 });49 it('iterating one element', function() {50 expect(recordAllData(new Bst(4))).toEqual([4]);51 });52 it('iterating over smaller element', function() {53 var four;54 four = new Bst(4);55 four.insert(2);56 expect(recordAllData(four)).toEqual([2, 4]);57 });58 it('iterating over larger element', function() {59 var four;60 four = new Bst(4);61 four.insert(5);62 expect(recordAllData(four)).toEqual([4, 5]);63 });64 it('iterating over complex tree', function() {65 var four;66 four = new Bst(4);67 four.insert(2);68 four.insert(1);69 four.insert(3);70 four.insert(6);71 four.insert(7);72 four.insert(5);73 expect(recordAllData(four)).toEqual([1, 2, 3, 4, 5, 6, 7]);74 });...
Using AI Code Generation
1import React from 'react';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { linkTo } from '@storybook/addon-links';5import { Button, Welcome } from '@storybook/react/demo';6import { withInfo } from '@storybook/addon-info';7import { withNotes } from '@storybook/addon-notes';8import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';9import { withOptions } from '@storybook/addon-options';10import { configure, addDecorator } from '@storybook/react';11import { setOptions } from '@storybook/addon-options';12setOptions({13});14addDecorator(withKnobs);15addDecorator(withNotes);16addDecorator(withInfo);17storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);18storiesOf('Button', module)19 .add('with text', () => (20 <Button onClick={action('clicked')}>{text('Label', 'Hello Button')}</Button>21 .add('with some emoji', () => (22 <Button onClick={action('clicked')}>23 .add('with some emoji and info', () => (24 <Button onClick={action('clicked')}>25 ), {26 info: {27 },28 });29import { configure } from '@storybook/react';30configure(require.context('../src', true, /\.stories\.js$/), module);31import '@storybook/addon-actions/register';32import '@storybook/addon
Using AI Code Generation
1import { configure, addDecorator } from '@storybook/react';2import { withInfo } from '@storybook/addon-info';3import { withKnobs } from '@storybook/addon-knobs';4import { withA11y } from '@storybook/addon-a11y';5import { withOptions } from '@storybook/addon-options';6addDecorator(7 withOptions({
Using AI Code Generation
1import { configure, addDecorator } from '@storybook/react';2import { withInfo } from '@storybook/addon-info';3import { withKnobs } from '@storybook/addon-knobs/react';4import { withOptions } from '@storybook/addon-options';5import { setOptions } from '@storybook/addon-options';6import { withA11y } from '@storybook/addon-a11y';7import { withViewport } from '@storybook/addon-viewport';8import { withNotes } from '@storybook/addon-notes';9import { withConsole } from '@storybook/addon-console';10import { withBackgrounds } from '@storybook/addon-backgrounds';11import { withLinks } from '@storybook/addon-links';12import { withTests } from '@storybook/addon-jest';13setOptions({
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { withInfo } from '@storybook/addon-info';3import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';4import { withNotes } from '@storybook/addon-notes';5import { action } from '@storybook/addon-actions';6import { withReadme } from 'storybook-readme';7import { withOptions } from '@storybook/addon-options';8import { withViewport } from '@storybook/addon-viewport';9import { withA11y } from '@storybook/addon-a11y';10storiesOf('Test', module)11 .addDecorator(withKnobs)12 .addDecorator(withInfo)13 .addDecorator(withNotes)14 .addDecorator(withReadme)15 .addDecorator(withOptions)16 .addDecorator(withViewport)17 .addDecorator(withA11y)18 .add('Test', () => <div>Test</div>);19import { configure, addDecorator } from '@storybook/react';20import { withInfo } from '@storybook/addon-info';21import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';22import { withNotes } from '@storybook/addon-notes';23import { action } from '@storybook/addon-actions';24import { withReadme } from 'storybook-readme';25import { withOptions } from '@storybook/addon-options';26import { withViewport } from '@storybook/addon-viewport';27import { withA11y } from '@storybook/addon-a11y';28addDecorator(withInfo);29addDecorator(withKnobs);30addDecorator(withNotes);31addDecorator(withReadme);32addDecorator(withOptions);33addDecorator(withViewport);34addDecorator(withA11y);35configure(require.context('../src', true, /\.stories\.js$/), module);
Using AI Code Generation
1import { addDecorator, configure } from '@storybook/react';2import { withKnobs } from '@storybook/addon-knobs';3import { withOptions } from '@storybook/addon-options';4import { withInfo } from '@storybook/addon-info';5addDecorator(6 withInfo({7 styles: stylesheet => {8 stylesheet.infoBody = {9 };10 stylesheet.infoStory = {11 };12 return stylesheet;13 }14 })15);16addDecorator(withKnobs);17addDecorator(18 withOptions({19 })20);21function loadStories() {22 require('../src/stories');23}24configure(loadStories, module);25const path = require('path');26module.exports = {27 module: {28 {29 test: /\.(ts|tsx)$/,30 {31 loader: require.resolve('awesome-typescript-loader')32 },33 {34 loader: require.resolve('react-docgen-typescript-loader')35 }36 },37 {38 {39 },40 {41 },42 {43 }44 }45 },46 resolve: {47 alias: {48 '@': path.resolve(__dirname, '../src')49 }50 },51};52const path = require('path');53module.exports = {54 module: {55 {56 test: /\.(ts|tsx)$/,57 {58 loader: require.resolve('awesome-typescript-loader')59 },60 {61 loader: require.resolve('react-docgen-typescript-loader')62 }63 },64 {65 {
Using AI Code Generation
1import { configure } from '@storybook/react';2function loadStories() {3 require('../src/stories/index.js');4}5configure(loadStories, module);6import { configure } from '@storybook/react';7function loadStories() {8 require('../src/stories/index.js');9}10configure(loadStories, module);11import { configure } from '@storybook/react';12function loadStories() {13 require('../src/stories/index.js');14}15configure(loadStories, module);16import { configure } from '@storybook/react';17function loadStories() {18 require('../src/stories/index.js');19}20configure(loadStories, module);21import { configure } from '@storybook/react';22function loadStories() {23 require('../src/stories/index.js');24}25configure(loadStories, module);26import { configure } from '@storybook/react';27function loadStories() {28 require('../src/stories/index.js');29}30configure(loadStories, module);31import { configure } from '@storybook/react';32function loadStories() {33 require('../src/stories/index.js');34}35configure(loadStories, module);36import { configure } from '@storybook/react';37function loadStories() {38 require('../src/stories/index.js');39}40configure(loadStories, module);41import { configure } from '@storybook/react';
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';3import { withDocs } from 'storybook-readme';4import { action } from '@storybook/addon-actions';5import { linkTo } from '@storybook/addon-links';6import Button from './Button';7import MyButton from './MyButton';8import README from './README.md';9storiesOf('Button', module)10 .addDecorator(withKnobs)11 .addDecorator(withDocs(README))12 .add('with text', () => (13 <Button onClick={action('clicked')}>{text('Label', 'Hello Button')}</Button>14 .add('with some emoji', () => (15 <Button onClick={action('clicked')}>{text('Label', '😀 😎 👍 💯')}</Button>16 .add('with some emoji and action', () => (17 <Button onClick={action('clicked')}>{text('Label', '😀 😎 👍 💯')}</Button>18 .add('with some emoji and linkTo', () => (19 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '😀 😎 👍 💯')}</Button>20 .add('with some emoji and linkTo', () => (21 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '😀 😎 👍 💯')}</Button>22 .add('with some emoji and linkTo', () => (23 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '😀 😎 👍 💯')}</Button>24 .add('with some emoji and linkTo', () => (25 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '😀 😎 👍 💯')}</Button>26 .add('with some emoji and linkTo', () => (27 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '😀 😎 👍 💯')}</Button>28 .add('with some emoji and linkTo', () => (29 <Button onClick={linkTo('Button', 'with some emoji')}>{text('Label', '
Using AI Code Generation
1import React from 'react';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { linkTo } from '@storybook/addon-links';5import { Button, Welcome } from '@storybook/react/demo';6storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);7storiesOf('Button', module)8 .add('with text', () => (9 <Button onClick={action('clicked')}>Hello Button</Button>10 .add('with some emoji', () => (11 <Button onClick={action('clicked')}>12 ));13import React from 'react';14import { storiesOf } from '@storybook/react';15import { action } from '@storybook/addon-actions';16import { linkTo } from '@storybook/addon-links';17import { Button, Welcome } from '@storybook/react/demo';18storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);19storiesOf('Button', module)20 .add('with text', () => (21 <Button onClick={action('clicked')}>Hello Button</Button>22 .add('with some emoji', () => (23 <Button onClick={action('clicked')}>
Using AI Code Generation
1import { storiesOf } from '@storybook/react';2import App from '../App';3storiesOf('App', module).add('default', () => <App />);4Method 1: storiesOf()5storiesOf() is the first method to use storybook-root. It will create a storybook for a single component. It takes two arguments:6Method 2: addDecorator()7Method 3: addParameters()8Method 4: add()9add() is the fourth method to use storybook-root. It is used to add a story to the storybook. It takes two arguments:
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!!