How to use fromSelection method in storybook-root

Best JavaScript code snippet using storybook-root

findController.test.ts

Source:findController.test.ts Github

copy

Full Screen

...41 let inputFocused = opts.shouldFocus === FindStartFocusAction.FocusFindInput;42 this._findInputFocused.set(inputFocused);43 }44}45function fromSelection(slc: Selection): number[] {46 return [slc.startLineNumber, slc.startColumn, slc.endLineNumber, slc.endColumn];47}48suite('FindController', async () => {49 let queryState: { [key: string]: any; } = {};50 let clipboardState = '';51 let serviceCollection = new ServiceCollection();52 serviceCollection.set(IStorageService, {53 _serviceBrand: undefined,54 onDidChangeStorage: Event.None,55 onWillSaveState: Event.None,56 get: (key: string) => queryState[key],57 getBoolean: (key: string) => !!queryState[key],58 getNumber: (key: string) => undefined,59 store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },60 remove: () => undefined61 } as any);62 if (platform.isMacintosh) {63 serviceCollection.set(IClipboardService, <any>{64 readFindText: () => clipboardState,65 writeFindText: (value: any) => { clipboardState = value; }66 });67 }68 /* test('stores to the global clipboard buffer on start find action', async () => {69 await withAsyncTestCodeEditor([70 'ABC',71 'ABC',72 'XYZ',73 'ABC'74 ], { serviceCollection: serviceCollection }, async (editor) => {75 clipboardState = '';76 if (!platform.isMacintosh) {77 assert.ok(true);78 return;79 }80 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);81 let startFindAction = new StartFindAction();82 // I select ABC on the first line83 editor.setSelection(new Selection(1, 1, 1, 4));84 // I hit Ctrl+F to show the Find dialog85 startFindAction.run(null, editor);86 assert.deepEqual(findController.getGlobalBufferTerm(), findController.getState().searchString);87 findController.dispose();88 });89 });90 test('reads from the global clipboard buffer on next find action if buffer exists', async () => {91 await withAsyncTestCodeEditor([92 'ABC',93 'ABC',94 'XYZ',95 'ABC'96 ], { serviceCollection: serviceCollection }, async (editor) => {97 clipboardState = 'ABC';98 if (!platform.isMacintosh) {99 assert.ok(true);100 return;101 }102 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);103 let findState = findController.getState();104 let nextMatchFindAction = new NextMatchFindAction();105 nextMatchFindAction.run(null, editor);106 assert.equal(findState.searchString, 'ABC');107 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 1, 1, 4]);108 findController.dispose();109 });110 });111 test('writes to the global clipboard buffer when text changes', async () => {112 await withAsyncTestCodeEditor([113 'ABC',114 'ABC',115 'XYZ',116 'ABC'117 ], { serviceCollection: serviceCollection }, async (editor) => {118 clipboardState = '';119 if (!platform.isMacintosh) {120 assert.ok(true);121 return;122 }123 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);124 let findState = findController.getState();125 findState.change({ searchString: 'ABC' }, true);126 assert.deepEqual(findController.getGlobalBufferTerm(), 'ABC');127 findController.dispose();128 });129 }); */130 test('issue #1857: F3, Find Next, acts like "Find Under Cursor"', async () => {131 await withAsyncTestCodeEditor([132 'ABC',133 'ABC',134 'XYZ',135 'ABC'136 ], { serviceCollection: serviceCollection }, async (editor) => {137 clipboardState = '';138 // The cursor is at the very top, of the file, at the first ABC139 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);140 let findState = findController.getState();141 let startFindAction = new StartFindAction();142 let nextMatchFindAction = new NextMatchFindAction();143 // I hit Ctrl+F to show the Find dialog144 await startFindAction.run(null, editor);145 // I type ABC.146 findState.change({ searchString: 'A' }, true);147 findState.change({ searchString: 'AB' }, true);148 findState.change({ searchString: 'ABC' }, true);149 // The first ABC is highlighted.150 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 1, 1, 4]);151 // I hit Esc to exit the Find dialog.152 findController.closeFindWidget();153 findController.hasFocus = false;154 // The cursor is now at end of the first line, with ABC on that line highlighted.155 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 1, 1, 4]);156 // I hit delete to remove it and change the text to XYZ.157 editor.pushUndoStop();158 editor.executeEdits('test', [EditOperation.delete(new Range(1, 1, 1, 4))]);159 editor.executeEdits('test', [EditOperation.insert(new Position(1, 1), 'XYZ')]);160 editor.pushUndoStop();161 // At this point the text editor looks like this:162 // XYZ163 // ABC164 // XYZ165 // ABC166 assert.equal(editor.getModel()!.getLineContent(1), 'XYZ');167 // The cursor is at end of the first line.168 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 4, 1, 4]);169 // I hit F3 to "Find Next" to find the next occurrence of ABC, but instead it searches for XYZ.170 await nextMatchFindAction.run(null, editor);171 assert.equal(findState.searchString, 'ABC');172 assert.equal(findController.hasFocus, false);173 findController.dispose();174 });175 });176 test('issue #3090: F3 does not loop with two matches on a single line', async () => {177 await withAsyncTestCodeEditor([178 'import nls = require(\'vs/nls\');'179 ], { serviceCollection: serviceCollection }, async (editor) => {180 clipboardState = '';181 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);182 let nextMatchFindAction = new NextMatchFindAction();183 editor.setPosition({184 lineNumber: 1,185 column: 9186 });187 await nextMatchFindAction.run(null, editor);188 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 26, 1, 29]);189 await nextMatchFindAction.run(null, editor);190 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 8, 1, 11]);191 findController.dispose();192 });193 });194 test('issue #6149: Auto-escape highlighted text for search and replace regex mode', async () => {195 await withAsyncTestCodeEditor([196 'var x = (3 * 5)',197 'var y = (3 * 5)',198 'var z = (3 * 5)',199 ], { serviceCollection: serviceCollection }, async (editor) => {200 clipboardState = '';201 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);202 let startFindAction = new StartFindAction();203 let nextMatchFindAction = new NextMatchFindAction();204 editor.setSelection(new Selection(1, 9, 1, 13));205 findController.toggleRegex();206 await startFindAction.run(null, editor);207 await nextMatchFindAction.run(null, editor);208 assert.deepEqual(fromSelection(editor.getSelection()!), [2, 9, 2, 13]);209 await nextMatchFindAction.run(null, editor);210 assert.deepEqual(fromSelection(editor.getSelection()!), [1, 9, 1, 13]);211 findController.dispose();212 });213 });214 test('issue #41027: Don\'t replace find input value on replace action if find input is active', async () => {215 await withAsyncTestCodeEditor([216 'test',217 ], { serviceCollection: serviceCollection }, async (editor) => {218 let testRegexString = 'tes.';219 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);220 let nextMatchFindAction = new NextMatchFindAction();221 let startFindReplaceAction = new StartFindReplaceAction();222 findController.toggleRegex();223 findController.setSearchString(testRegexString);224 await findController.start({225 forceRevealReplace: false,226 seedSearchStringFromSelection: false,227 seedSearchStringFromGlobalClipboard: false,228 shouldFocus: FindStartFocusAction.FocusFindInput,229 shouldAnimate: false,230 updateSearchScope: false,231 loop: true232 });233 await nextMatchFindAction.run(null, editor);234 await startFindReplaceAction.run(null, editor);235 assert.equal(findController.getState().searchString, testRegexString);236 findController.dispose();237 });238 });239 test('issue #9043: Clear search scope when find widget is hidden', async () => {240 await withAsyncTestCodeEditor([241 'var x = (3 * 5)',242 'var y = (3 * 5)',243 'var z = (3 * 5)',244 ], { serviceCollection: serviceCollection }, async (editor) => {245 clipboardState = '';246 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);247 await findController.start({248 forceRevealReplace: false,249 seedSearchStringFromSelection: false,250 seedSearchStringFromGlobalClipboard: false,251 shouldFocus: FindStartFocusAction.NoFocusChange,252 shouldAnimate: false,253 updateSearchScope: false,254 loop: true255 });256 assert.equal(findController.getState().searchScope, null);257 findController.getState().change({258 searchScope: new Range(1, 1, 1, 5)259 }, false);260 assert.deepEqual(findController.getState().searchScope, new Range(1, 1, 1, 5));261 findController.closeFindWidget();262 assert.equal(findController.getState().searchScope, null);263 });264 });265 test('issue #18111: Regex replace with single space replaces with no space', async () => {266 await withAsyncTestCodeEditor([267 'HRESULT OnAmbientPropertyChange(DISPID dispid);'268 ], { serviceCollection: serviceCollection }, async (editor) => {269 clipboardState = '';270 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);271 let startFindAction = new StartFindAction();272 await startFindAction.run(null, editor);273 findController.getState().change({ searchString: '\\b\\s{3}\\b', replaceString: ' ', isRegex: true }, false);274 findController.moveToNextMatch();275 assert.deepEqual(editor.getSelections()!.map(fromSelection), [276 [1, 39, 1, 42]277 ]);278 findController.replace();279 assert.deepEqual(editor.getValue(), 'HRESULT OnAmbientPropertyChange(DISPID dispid);');280 findController.dispose();281 });282 });283 test('issue #24714: Regular expression with ^ in search & replace', async () => {284 await withAsyncTestCodeEditor([285 '',286 'line2',287 'line3'288 ], { serviceCollection: serviceCollection }, async (editor) => {289 clipboardState = '';290 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);291 let startFindAction = new StartFindAction();292 await startFindAction.run(null, editor);293 findController.getState().change({ searchString: '^', replaceString: 'x', isRegex: true }, false);294 findController.moveToNextMatch();295 assert.deepEqual(editor.getSelections()!.map(fromSelection), [296 [2, 1, 2, 1]297 ]);298 findController.replace();299 assert.deepEqual(editor.getValue(), '\nxline2\nline3');300 findController.dispose();301 });302 });303 test('issue #38232: Find Next Selection, regex enabled', async () => {304 await withAsyncTestCodeEditor([305 '([funny]',306 '',307 '([funny]'308 ], { serviceCollection: serviceCollection }, async (editor) => {309 clipboardState = '';310 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);311 let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();312 // toggle regex313 findController.getState().change({ isRegex: true }, false);314 // change selection315 editor.setSelection(new Selection(1, 1, 1, 9));316 // cmd+f3317 await nextSelectionMatchFindAction.run(null, editor);318 assert.deepEqual(editor.getSelections()!.map(fromSelection), [319 [3, 1, 3, 9]320 ]);321 findController.dispose();322 });323 });324 test('issue #38232: Find Next Selection, regex enabled, find widget open', async () => {325 await withAsyncTestCodeEditor([326 '([funny]',327 '',328 '([funny]'329 ], { serviceCollection: serviceCollection }, async (editor) => {330 clipboardState = '';331 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);332 let startFindAction = new StartFindAction();333 let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();334 // cmd+f - open find widget335 await startFindAction.run(null, editor);336 // toggle regex337 findController.getState().change({ isRegex: true }, false);338 // change selection339 editor.setSelection(new Selection(1, 1, 1, 9));340 // cmd+f3341 await nextSelectionMatchFindAction.run(null, editor);342 assert.deepEqual(editor.getSelections()!.map(fromSelection), [343 [3, 1, 3, 9]344 ]);345 findController.dispose();346 });347 });348});349suite('FindController query options persistence', async () => {350 let queryState: { [key: string]: any; } = {};351 queryState['editor.isRegex'] = false;352 queryState['editor.matchCase'] = false;353 queryState['editor.wholeWord'] = false;354 let serviceCollection = new ServiceCollection();355 serviceCollection.set(IStorageService, {356 _serviceBrand: undefined,357 onDidChangeStorage: Event.None,358 onWillSaveState: Event.None,359 get: (key: string) => queryState[key],360 getBoolean: (key: string) => !!queryState[key],361 getNumber: (key: string) => undefined,362 store: (key: string, value: any) => { queryState[key] = value; return Promise.resolve(); },363 remove: () => undefined364 } as any);365 test('matchCase', async () => {366 await withAsyncTestCodeEditor([367 'abc',368 'ABC',369 'XYZ',370 'ABC'371 ], { serviceCollection: serviceCollection }, async (editor) => {372 queryState = { 'editor.isRegex': false, 'editor.matchCase': true, 'editor.wholeWord': false };373 // The cursor is at the very top, of the file, at the first ABC374 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);375 let findState = findController.getState();376 let startFindAction = new StartFindAction();377 // I hit Ctrl+F to show the Find dialog378 await startFindAction.run(null, editor);379 // I type ABC.380 findState.change({ searchString: 'ABC' }, true);381 // The second ABC is highlighted as matchCase is true.382 assert.deepEqual(fromSelection(editor.getSelection()!), [2, 1, 2, 4]);383 findController.dispose();384 });385 });386 queryState = { 'editor.isRegex': false, 'editor.matchCase': false, 'editor.wholeWord': true };387 test('wholeWord', async () => {388 await withAsyncTestCodeEditor([389 'ABC',390 'AB',391 'XYZ',392 'ABC'393 ], { serviceCollection: serviceCollection }, async (editor) => {394 queryState = { 'editor.isRegex': false, 'editor.matchCase': false, 'editor.wholeWord': true };395 // The cursor is at the very top, of the file, at the first ABC396 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);397 let findState = findController.getState();398 let startFindAction = new StartFindAction();399 // I hit Ctrl+F to show the Find dialog400 await startFindAction.run(null, editor);401 // I type AB.402 findState.change({ searchString: 'AB' }, true);403 // The second AB is highlighted as wholeWord is true.404 assert.deepEqual(fromSelection(editor.getSelection()!), [2, 1, 2, 3]);405 findController.dispose();406 });407 });408 test('toggling options is saved', async () => {409 await withAsyncTestCodeEditor([410 'ABC',411 'AB',412 'XYZ',413 'ABC'414 ], { serviceCollection: serviceCollection }, async (editor) => {415 queryState = { 'editor.isRegex': false, 'editor.matchCase': false, 'editor.wholeWord': true };416 // The cursor is at the very top, of the file, at the first ABC417 let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);418 findController.toggleRegex();...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1document.getElementById("submitButton").onclick = function () {2 let temp = getTemp();3 let fromSelection = getFromSelection();4 let toSelection = getToSelection();5 var converter = {6 fromCelsius: temp => temp + 273.15,7 toCelsius: temp => temp - 273.15,8 fromFahrenheit: temp => (temp - 32) * 5 / 9 + 273.15,9 toFahrenheit: temp => (temp - 273.15) * 9 / 5 + 32,10 fromRankine: temp => temp * 5 / 9,11 toRankine: temp => temp * 1.8,12 fromRomer: temp => (temp - 7.5) / 0.52500 + 273.15,13 toRomer: temp => (temp - 273.15) * 21 / 40 + 7.5,14 fromReaumur: temp => temp * 4 / 5 + 273.15,15 toReaumur: temp => (temp - 273.15) * 0.8,16 fromNewton: temp => temp * 100 / 33 + 273.15,17 toNewton: temp => (temp - 273.15) * 0.33000,18 fromDelisle: temp => 373.15 - (temp * 2 / 3),19 toDelisle: temp => (temp - 273.15) * 1.5000 - 100.0020 }21 Object.freeze(converter);22 switch (fromSelection) {23 case 1: {24 temp = converter.fromCelsius(temp);25 switch (toSelection) {26 case 1:27 doofus(temp);28 break;29 case 2:30 temp = converter.toFahrenheit(temp);31 break;32 case 4:33 temp = converter.toRankine(temp);34 break;35 case 5:36 temp = converter.toRomer(temp);37 case 6:38 temp = converter.toReaumur(temp);39 break;40 case 7:41 temp = converter.toNewton(temp);42 break;43 case 8:44 temp = converter.toDelisle(temp);45 break;46 }47 if (toSelection != 1) print(temp, unit);48 }49 break;50 case 2: {51 temp = converter.fromFahrenheit(temp);52 switch (toSelection) {53 case 1:54 temp = converter.toCelsius(temp);55 break;56 case 2:57 doofus(temp);58 break;59 case 4:60 temp = converter.toRankine(temp);61 break;62 case 5:63 temp = converter.toRomer(temp);64 break;65 case 6:66 temp = converter.toReaumur(temp);67 break;68 case 7:69 temp = converter.toNewton(temp);70 break;71 case 8:72 temp = converter.toDelisle(temp);73 break;74 }75 if (toSelection != 2) print(temp, unit);76 }77 break;78 case 3: {79 switch (toSelection) {80 case 1:81 temp = converter.toCelsius(temp);82 break;83 case 2:84 temp = converter.toFahrenheit(temp);85 break;86 case 3:87 doofus(temp);88 break;89 case 4:90 temp = converter.toRankine(temp);91 break;92 case 5:93 temp = converter.toRomer(temp);94 break;95 case 6:96 temp = converter.toReaumur(temp);97 break;98 case 7:99 temp = converter.toNewton(temp);100 break;101 case 8:102 temp = converter.toDelisle(temp);103 break;104 }105 if (toSelection != 3) print(temp, unit);106 }107 break;108 case 4: {109 temp = converter.fromRankine(temp);110 switch (toSelection) {111 case 1:112 temp = converter.toCelsius(temp);113 break;114 case 2:115 temp = converter.toFahrenheit(temp);116 break;117 case 4:118 doofus(temp);119 break;120 case 5:121 temp = converter.toRomer(temp);122 case 6:123 temp = converter.toReaumur(temp);124 break;125 case 7:126 temp = converter.toNewton(temp);127 break;128 case 8:129 temp = converter.toDelisle(temp);130 break;131 }132 if (toSelection != 4) print(temp, unit);133 }134 break;135 case 5: {136 temp = converter.fromRomer(temp);137 switch (toSelection) {138 case 1:139 temp = converter.toCelsius(temp);140 break;141 case 2:142 temp = converter.toFahrenheit(temp);143 break;144 case 4:145 temp = converter.toRankine(temp);146 break;147 case 5:148 doofus(temp);149 break;150 case 6:151 temp = converter.toReaumur(temp);152 break;153 case 7:154 temp = converter.toNewton(temp);155 break;156 case 8:157 temp = converter.toDelisle(temp);158 break;159 }160 if (toSelection != 5) print(temp, unit);161 }162 break;163 case 6: {164 temp = converter.fromReaumur(temp);165 switch (toSelection) {166 case 1:167 temp = converter.toCelsius(temp);168 break;169 case 2:170 temp = converter.toFahrenheit(temp);171 break;172 case 4:173 temp = converter.toRankine(temp);174 break;175 case 5:176 temp = converter.toRomer(temp);177 break;178 case 6:179 doofus(temp);180 break;181 case 7:182 temp = converter.toNewton(temp);183 break;184 case 8:185 temp = converter.toDelisle(temp);186 break;187 }188 if (toSelection != 6) print(temp, unit);189 }190 break;191 case 7: {192 temp = converter.fromNewton(temp);193 switch (toSelection) {194 case 1:195 temp = converter.toCelsius(temp);196 break;197 case 2:198 temp = converter.toFahrenheit(temp);199 break;200 case 4:201 temp = converter.toRankine(temp);202 break;203 case 5:204 temp = converter.toRomer(temp);205 break;206 case 6:207 temp = converter.toReaumur(temp);208 break;209 case 7:210 doofus(temp);211 break;212 case 8:213 temp = converter.toDelisle(temp);214 break;215 }216 if (toSelection != 7) print(temp, unit);217 }218 break;219 case 8: {220 temp = converter.fromDelisle(temp);221 switch (toSelection) {222 case 1:223 temp = converter.toCelsius(temp);224 break;225 case 2:226 temp = converter.toFahrenheit(temp);227 break;228 case 4:229 temp = converter.toRankine(temp);230 break;231 case 5:232 temp = converter.toRomer(temp);233 break;234 case 6:235 temp = converter.toReaumur(temp);236 break;237 case 7:238 temp = converter.toNewton(temp);239 break;240 case 8:241 doofus(temp);242 break;243 }244 if (toSelection != 8) print(temp, unit);245 break;246 }247 }248}249function doofus(temp) {250 document.getElementById("result").innerHTML = `you doofus, i refuse to do that.... okay here it is anyways: ${temp}°${unit}`;251}252function print(temp, unit, selection) {253 switch (selection) {254 case 0:255 document.getElementById("result").innerHTML = "You need to choose "256 break;257 default:258 document.getElementById("result").innerHTML = `${temp}°${unit}`;259 break;260 }261}262function getTemp(temp) {263 temp = document.getElementById("textBox").value;264 return Number(temp);265}266function getFromSelection(fromSelection) {267 if (document.getElementById("fromCelsius").checked) fromSelection = 1;268 else if (document.getElementById("fromFahrenheit").checked) fromSelection = 2;269 else if (document.getElementById("fromKelvin").checked) fromSelection = 3;270 else if (document.getElementById("fromRankine").checked) fromSelection = 4;271 else if (document.getElementById("fromRomer").checked) fromSelection = 5;272 else if (document.getElementById("fromReaumur").checked) fromSelection = 6;273 else if (document.getElementById("fromNewton").checked) fromSelection = 7;274 else fromSelection = 8;275 return Number(fromSelection)276}277function getToSelection(toSelection) {278 if (document.getElementById("toCelsius").checked) {279 unit = "C";280 toSelection = 1;281 }282 else if (document.getElementById("toFahrenheit").checked) {283 unit = "F";284 toSelection = 2;285 }286 else if (document.getElementById("toKelvin").checked) {287 unit = "K";288 toSelection = 3;289 }290 else if (document.getElementById("toRankine").checked) {291 unit = "R";292 toSelection = 4;293 }294 else if (document.getElementById("toRomer").checked) {295 unit = "Rø";296 toSelection = 5;297 }298 else if (document.getElementById("toReaumur").checked) {299 unit = "Ré";300 toSelection = 6;301 }302 else if (document.getElementById("toNewton").checked) {303 unit = "N";304 toSelection = 7;305 }306 else {307 unit = "D";308 toSelection = 8;309 }310 return Number(toSelection);...

Full Screen

Full Screen

BillSearchCriteriaList.js

Source:BillSearchCriteriaList.js Github

copy

Full Screen

1function lookupItem(sourceid, destid) {2 var dest = document.getElementById(destid);3 var source = document.getElementById(sourceid);4 var curValue = source.value.toLowerCase();5 var found = false;6 var index = dest.selectedIndex;7 var numOptions = dest.options.length;8 var pos = 0;9 while ((!found) && (pos < numOptions)) {10 found = (dest.options[pos].text.toLowerCase().indexOf(curValue)==0) ;11 if (found) 12 index = pos;13 pos++;14 }15 if (found) 16 dest.selectedIndex = index;17 }18function addOption(selection, text, value) {19 var newOpt = new Option(text, value);20 selection.add(newOpt);21 var codetext = document.getElementById('txtCodes');22 if (codetext.value.indexOf(newOpt.value) == -1 && selection.id.indexOf('Selected') > 0) {23 codetext.value += newOpt.value + ";";24 }25}26function deleteOption(selection, index) {27 var selLength = selection.length;28 if (selLength > 0) {29 var codetext = document.getElementById('txtCodes');30 if (codetext.value.indexOf(selection.options[index].value) > 0) {31 codetext.value = codetext.value.replace(selection.options[index].value + ';', "");32 }33 selection.remove(index);34 }35}36function moveOptions(fromSelection, toSelection) {37 setErrorMsg("");38 var selLength = document.getElementById(fromSelection).length;39 if (selLength == 0) {40 setErrorMsg("Please select an item to include in your search criteria.");41 return false;42 }43 var maxItems = (fromSelection.indexOf('Subjects') > 0) ? 20 : 50;44 var itemType = (fromSelection.indexOf('Subjects') > 0) ? "subjects" : "actions";45 46 var selectedText = new Array();47 var selectedValues = new Array();48 var selectedCount = 0;49 var codetext = document.getElementById('txtCodes');50 51 if (toSelection.indexOf('Selected') > 0) {52 for (var i = selLength - 1; i >= 0; i--) {53 if (document.getElementById(fromSelection).options[i].selected) {54 selectedCount++;55 if (selectedCount + codetext.value.split(';').length - 1 > maxItems) {56 setErrorMsg("A maximum of " + maxItems + itemType + " may be included in your search criteria.");57 return false;58 }59 }60 }61 }62 selectedCount = 0;63 64 // Find the selected Options in reverse order65 // and delete them from the 'from' Select.66 for (i = selLength - 1; i >= 0; i--) {67 if (document.getElementById(fromSelection).options[i].selected) {68 selectedText[selectedCount] = document.getElementById(fromSelection).options[i].text;69 selectedValues[selectedCount] = document.getElementById(fromSelection).options[i].value;70 deleteOption(document.getElementById(fromSelection), i);71 selectedCount++; 72 }73 }74 // Add the selected text/values in reverse order.75 // This will add the Options to the 'to' Select76 // in the same order as they were in the 'from' Select.77 for (i = selectedCount - 1; i >= 0; i--) {78 addOption(document.getElementById(toSelection), selectedText[i], selectedValues[i]);79 }80}81function listbox_keydown(evt, source, dest)82{ 83 var e = evt ? evt : window.event;84 var list = document.getElementById(dest);85 if (list.selectedIndex >= 0 && e.keyCode == 46)86 {87 moveOptions(dest, source);88 }89 if (list.selectedIndex >= 0 && e.keyCode == 13)90 {91 moveOptions(dest, source);92 } 93}94function setErrorMsg(msg)95{96 var vs = document.getElementById('validationSummary');97 vs.innerHTML = msg.length > 0 ? "<font color='red'>*</font> " + msg: "";98 vs.style.display = "inline";...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fromSelection } = require("@storybook/addon-storyshots-puppeteer/dist/api");2const puppeteer = require("puppeteer");3const path = require("path");4const fs = require("fs");5const Pixelmatch = require("pixelmatch");6 {7 },8 {9 },10];11const test = async () => {12 const browser = await puppeteer.launch();13 const page = await browser.newPage();14 await page.goto(storybookUrl);15 await page.waitForSelector("#root");16 await page.waitFor(2000);17 for (const { name, url } of stories) {18 await page.goto(`${storybookUrl}/iframe.html?id=${url}`);19 await page.waitForSelector("#root");20 await page.waitFor(2000);21 const story = await fromSelection(page);22 await page.goto(`${testUrl}/${url}`);23 await page.waitForSelector("#root");24 await page.waitFor(2000);25 const test = await fromSelection(page);26 const img1 = await story.screenshot();27 const img2 = await test.screenshot();28 const diff = await new Promise((resolve, reject) => {29 const { width, height } = img1;30 const diff = new PNG({ width, height });31 Pixelmatch(img1.data, img2.data, diff.data, width, height, { threshold: 0.1 }, (err, result) => {32 if (err) {33 reject(err);34 }35 resolve(diff);36 });37 });38 const diffName = path.resolve(__dirname, `./diff/${name}.png`);39 await new Promise((resolve, reject) => {40 diff.pack().pipe(fs.createWriteStream(diffName)).on("finish", resolve).on("error", reject);41 });42 }43 await browser.close();44};45test();46{47 "scripts": {48 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const selection = fromSelection(window.getSelection());2const range = fromRange(window.getSelection().getRangeAt(0));3const node = fromNode(window.getSelection().anchorNode);4const selection = fromSelection(window.getSelection());5const range = fromRange(window.getSelection().getRangeAt(0));6const node = fromNode(window.getSelection().anchorNode);7const selection = fromSelection(window.getSelection());8const range = fromRange(window.getSelection().getRangeAt(0));9const node = fromNode(window.getSelection().anchorNode);10const selection = fromSelection(window.getSelection());11const range = fromRange(window.getSelection().getRangeAt(0));12const node = fromNode(window.getSelection().anchorNode);13const selection = fromSelection(window.getSelection());14const range = fromRange(window.getSelection().getRangeAt(0));15const node = fromNode(window.getSelection().anchorNode);16const selection = fromSelection(window.getSelection());

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fromSelection } = require("@storybook/addon-docs/blocks");2 import { fromSelection } from '@storybook/addon-docs/blocks';3 const codeString = 'code';4 export default fromSelection(codeString);5`;6export default fromSelection(codeString);7import { Meta } from "@storybook/addon-docs/blocks";8import Test from "./test";9import { storiesOf } from "@storybook/react";10import Test from "./test";11storiesOf("Docs|test", module).add("test", () => <Test />);12import { storiesOf } from "@storybook/react";13import Test from "./test";14storiesOf("Docs|test", module).add("test", () => <Test />);15import { storiesOf } from "@storybook/react";16import Test from "./test";17storiesOf("Docs|test", module).add("test", () => <Test />);18import { storiesOf } from "@storybook/react";19import Test from "./test";20storiesOf("Docs|test", module).add("test", () => <Test />);21import { Meta } from "@storybook/addon-docs/blocks";22import Test from "./test";23import { storiesOf } from "@storybook/react";24import Test from "./test";25storiesOf("Docs|test", module).add("test", () => <Test />);26import { storiesOf } from "@storybook/react";27import Test from "./test";28storiesOf("Docs|test", module).add("test", () => <Test />);29import { storiesOf } from "@storybook/react";30import Test from "./test";31storiesOf("Docs|test", module).add("test", () => <Test />);32import { storiesOf } from "@storybook/react";33import Test from "./test";34storiesOf("Docs|test", module).add("test", () => <Test />);

Full Screen

Using AI Code Generation

copy

Full Screen

1var selection = document.getSelection();2var root = document.querySelector("storybook-root");3root.fromSelection(selection);4var story = root.querySelector("story");5story.select();6var paragraph = story.querySelector("paragraph");7paragraph.select();8var sentence = paragraph.querySelector("sentence");9sentence.select();10var word = sentence.querySelector("word");11word.select();12var character = word.querySelector("character");13character.select();14var letter = character.querySelector("letter");15letter.select();16var glyph = letter.querySelector("glyph");17glyph.select();18var box = glyph.querySelector("box");19box.select();20var path = box.querySelector("path");21path.select();22var point = path.querySelector("point");23point.select();24var coordinate = point.querySelector("coordinate");25coordinate.select();26var x = coordinate.querySelector("x");27x.select();28var y = x.querySelector("y");29y.select();30var z = y.querySelector("z");31z.select();32var w = z.querySelector("w");33w.select();34var v = w.querySelector("v");35v.select();36var u = v.querySelector("u");37u.select();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromSelection } from '@storybook/addon-storyshots-puppeteer';2const story = fromSelection(selection);3describe('Storyshots', () => {4 it('renders selected story', async () => {5 const { image } = await initStoryshotsTest({6 });7 await image(story);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromSelection, select } from "storybook-addon-knobs";2import { storiesOf } from "@storybook/react";3storiesOf("MyComponent", module)4 .add("with knobs", () => {5 const story = fromSelection("MyComponent", "with knobs");6 select("color", ["red", "green", "blue"], "red", story);7 return <MyComponent />;8 })9 .add("with knobs", () => {10 const story = fromSelection("MyComponent", "with knobs");11 select("color", ["red", "green", "blue"], "red", story);12 return <MyComponent />;13 })14 .add("with knobs", () => {15 const story = fromSelection("MyComponent", "with knobs");16 select("color", ["red", "green", "blue"], "red", story);17 return <MyComponent />;18 });19import { select } from "storybook-addon-knobs";20import { storiesOf } from "@storybook/react";21storiesOf("MyComponent", module)22 .add("with knobs", () => {23 select("color", ["red", "green", "blue"], "red");24 return <MyComponent />;25 })26 .add("with knobs", () => {27 select("color", ["red", "green", "blue"], "red");28 return <MyComponent />;29 })30 .add("with knobs", () => {31 select("color", ["red", "green", "blue"], "red");32 return <MyComponent />;33 });34 at Object.select (storybook-addon-knobs/dist/index.js:1:2543)35 at storiesOf.add (test.spec.js:7:5)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromSelection } from '@storybook/addon-storybook-preview';2import '@storybook/addon-storybook-preview/dist/preview.css';3const selectedStory = fromSelection();4const story = document.createElement('storybook-story');5story.story = selectedStory;6document.body.appendChild(story);7import '@storybook/addon-storybook-preview/dist/preview.css';8const story = document.createElement('storybook-story');9story.story = { kind: 'Button', story: 'primary' };10document.body.appendChild(story);

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