How to use round method in storybook-root

Best JavaScript code snippet using storybook-root

calculate-round.test.ts

Source:calculate-round.test.ts Github

copy

Full Screen

1import "jest-extended";2import { calculateRound, isNewRound } from "@packages/core-kernel/src/utils/round-calculator";3import { Errors, Managers } from "@packages/crypto";4import { devnet } from "@packages/crypto/src/networks";5describe("Round Calculator", () => {6 describe("calculateRound", () => {7 describe("static delegate count", () => {8 it("should calculate the round when nextRound is the same", () => {9 for (let i = 0, height = 51; i < 1000; i++, height += 51) {10 const { round, nextRound } = calculateRound(height - 1);11 expect(round).toBe(i + 1);12 expect(nextRound).toBe(i + 1);13 }14 });15 it("should calculate the round when nextRound is not the same", () => {16 for (let i = 0, height = 51; i < 1000; i++, height += 51) {17 const { round, nextRound } = calculateRound(height);18 expect(round).toBe(i + 1);19 expect(nextRound).toBe(i + 2);20 }21 });22 it("should calculate the correct round", () => {23 const activeDelegates = 51;24 for (let i = 0; i < 1000; i++) {25 const { round, nextRound } = calculateRound(i + 1);26 expect(round).toBe(Math.floor(i / activeDelegates) + 1);27 expect(nextRound).toBe(Math.floor((i + 1) / activeDelegates) + 1);28 }29 });30 it("should calculate correct round for each height in round", () => {31 const milestones = [{ height: 1, activeDelegates: 4 }];32 const config = { ...devnet, milestones };33 Managers.configManager.setConfig(config);34 const testVector = [35 // Round 136 { height: 1, round: 1, roundHeight: 1, nextRound: 1, activeDelegates: 4 },37 { height: 2, round: 1, roundHeight: 1, nextRound: 1, activeDelegates: 4 },38 { height: 3, round: 1, roundHeight: 1, nextRound: 1, activeDelegates: 4 },39 { height: 4, round: 1, roundHeight: 1, nextRound: 2, activeDelegates: 4 },40 // Round 241 { height: 5, round: 2, roundHeight: 5, nextRound: 2, activeDelegates: 4 },42 { height: 6, round: 2, roundHeight: 5, nextRound: 2, activeDelegates: 4 },43 { height: 7, round: 2, roundHeight: 5, nextRound: 2, activeDelegates: 4 },44 { height: 8, round: 2, roundHeight: 5, nextRound: 3, activeDelegates: 4 },45 // Round 346 { height: 9, round: 3, roundHeight: 9, nextRound: 3, activeDelegates: 4 },47 { height: 10, round: 3, roundHeight: 9, nextRound: 3, activeDelegates: 4 },48 { height: 11, round: 3, roundHeight: 9, nextRound: 3, activeDelegates: 4 },49 { height: 12, round: 3, roundHeight: 9, nextRound: 4, activeDelegates: 4 },50 ];51 testVector.forEach((item) => {52 const result = calculateRound(item.height);53 expect(result.round).toBe(item.round);54 expect(result.roundHeight).toBe(item.roundHeight);55 expect(isNewRound(result.roundHeight)).toBeTrue();56 expect(result.nextRound).toBe(item.nextRound);57 expect(result.maxDelegates).toBe(item.activeDelegates);58 });59 });60 });61 describe("dynamic delegate count", () => {62 it("should calculate the correct with dynamic delegate count", () => {63 const milestones = [64 { height: 1, activeDelegates: 2 },65 { height: 3, activeDelegates: 3 },66 { height: 9, activeDelegates: 1 },67 { height: 12, activeDelegates: 3 },68 ];69 const testVector = [70 // Round 1 - milestone71 { height: 1, round: 1, roundHeight: 1, nextRound: 1, activeDelegates: 2 },72 { height: 2, round: 1, roundHeight: 1, nextRound: 2, activeDelegates: 2 },73 // Round 2 - milestone change74 { height: 3, round: 2, roundHeight: 3, nextRound: 2, activeDelegates: 3 },75 { height: 4, round: 2, roundHeight: 3, nextRound: 2, activeDelegates: 3 },76 { height: 5, round: 2, roundHeight: 3, nextRound: 3, activeDelegates: 3 },77 // Round 378 { height: 6, round: 3, roundHeight: 6, nextRound: 3, activeDelegates: 3 },79 { height: 7, round: 3, roundHeight: 6, nextRound: 3, activeDelegates: 3 },80 { height: 8, round: 3, roundHeight: 6, nextRound: 4, activeDelegates: 3 },81 // Round 4 - 6 - milestone change82 { height: 9, round: 4, roundHeight: 9, nextRound: 5, activeDelegates: 1 },83 { height: 10, round: 5, roundHeight: 10, nextRound: 6, activeDelegates: 1 },84 { height: 11, round: 6, roundHeight: 11, nextRound: 7, activeDelegates: 1 },85 // Round 7 - milestone change86 { height: 12, round: 7, roundHeight: 12, nextRound: 7, activeDelegates: 3 },87 { height: 13, round: 7, roundHeight: 12, nextRound: 7, activeDelegates: 3 },88 { height: 14, round: 7, roundHeight: 12, nextRound: 8, activeDelegates: 3 },89 // Round 890 { height: 15, round: 8, roundHeight: 15, nextRound: 8, activeDelegates: 3 },91 ];92 const config = { ...devnet, milestones };93 Managers.configManager.setConfig(config);94 testVector.forEach(({ height, round, roundHeight, nextRound, activeDelegates }) => {95 const result = calculateRound(height);96 expect(result.round).toBe(round);97 expect(result.roundHeight).toBe(roundHeight);98 expect(isNewRound(result.roundHeight)).toBeTrue();99 expect(result.nextRound).toBe(nextRound);100 expect(result.maxDelegates).toBe(activeDelegates);101 });102 });103 it("should throw if active delegates is not changed on new round", () => {104 const milestones = [105 { height: 1, activeDelegates: 3 },106 { height: 3, activeDelegates: 4 }, // Next milestone should be 4107 ];108 // @ts-ignore109 Managers.configManager.validateMilestones = jest.fn();110 const config = { ...devnet, milestones };111 Managers.configManager.setConfig(config);112 calculateRound(1);113 calculateRound(2);114 expect(() => calculateRound(3)).toThrowError(Errors.InvalidMilestoneConfigurationError);115 });116 });117 });...

Full Screen

Full Screen

math-round.js

Source:math-round.js Github

copy

Full Screen

...29function testRound(expect, input) {30 // Make source code different on each invocation to make31 // sure it gets optimized each time.32 var doRound = new Function('input',33 '"' + (test_id++) + '";return Math.round(input)');34 assertEquals(expect, doRound(input));35 assertEquals(expect, doRound(input));36 assertEquals(expect, doRound(input));37 %OptimizeFunctionOnNextCall(doRound);38 assertEquals(expect, doRound(input));39}40testRound(0, 0);41testRound(-0, -0);42testRound(Infinity, Infinity);43testRound(-Infinity, -Infinity);44testRound(NaN, NaN);45// Regression test for a bug where a negative zero coming from Math.round46// was not properly handled by other operations.47function roundsum(i, n) {48 var ret = Math.round(n);49 while (--i > 0) {50 ret += Math.round(n);51 }52 return ret;53}54assertEquals(-0, roundsum(1, -0));55%OptimizeFunctionOnNextCall(roundsum);56// The optimized function will deopt. Run it with enough iterations to try57// to optimize via OSR (triggering the bug).58assertEquals(-0, roundsum(100000, -0));59testRound(1, 0.5);60testRound(1, 0.7);61testRound(1, 1);62testRound(1, 1.1);63testRound(1, 1.49999);64testRound(-0, -0.5);...

Full Screen

Full Screen

data.ts

Source:data.ts Github

copy

Full Screen

1export const mapData: any = [2 {3 name: '北京',4 value: Math.round(Math.random() * 1000),5 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],6 },7 {8 name: '天津',9 value: Math.round(Math.random() * 1000),10 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],11 },12 {13 name: '上海',14 value: Math.round(Math.random() * 1000),15 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],16 },17 {18 name: '重庆',19 value: Math.round(Math.random() * 1000),20 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],21 },22 {23 name: '河北',24 value: Math.round(Math.random() * 1000),25 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],26 },27 {28 name: '河南',29 value: Math.round(Math.random() * 1000),30 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],31 },32 {33 name: '云南',34 value: Math.round(Math.random() * 1000),35 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],36 },37 {38 name: '辽宁',39 value: Math.round(Math.random() * 1000),40 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],41 },42 {43 name: '黑龙江',44 value: Math.round(Math.random() * 1000),45 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],46 },47 {48 name: '湖南',49 value: Math.round(Math.random() * 1000),50 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],51 },52 {53 name: '安徽',54 value: Math.round(Math.random() * 1000),55 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],56 },57 {58 name: '山东',59 value: Math.round(Math.random() * 1000),60 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],61 },62 {63 name: '新疆',64 value: Math.round(Math.random() * 1000),65 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],66 },67 {68 name: '江苏',69 value: Math.round(Math.random() * 1000),70 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],71 },72 {73 name: '浙江',74 value: Math.round(Math.random() * 1000),75 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],76 },77 {78 name: '江西',79 value: Math.round(Math.random() * 1000),80 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],81 },82 {83 name: '湖北',84 value: Math.round(Math.random() * 1000),85 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],86 },87 {88 name: '广西',89 value: Math.round(Math.random() * 1000),90 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],91 },92 {93 name: '甘肃',94 value: Math.round(Math.random() * 1000),95 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],96 },97 {98 name: '山西',99 value: Math.round(Math.random() * 1000),100 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],101 },102 {103 name: '内蒙古',104 value: Math.round(Math.random() * 1000),105 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],106 },107 {108 name: '陕西',109 value: Math.round(Math.random() * 1000),110 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],111 },112 {113 name: '吉林',114 value: Math.round(Math.random() * 1000),115 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],116 },117 {118 name: '福建',119 value: Math.round(Math.random() * 1000),120 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],121 },122 {123 name: '贵州',124 value: Math.round(Math.random() * 1000),125 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],126 },127 {128 name: '广东',129 value: Math.round(Math.random() * 1000),130 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],131 },132 {133 name: '青海',134 value: Math.round(Math.random() * 1000),135 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],136 },137 {138 name: '西藏',139 value: Math.round(Math.random() * 1000),140 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],141 },142 {143 name: '四川',144 value: Math.round(Math.random() * 1000),145 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],146 },147 {148 name: '宁夏',149 value: Math.round(Math.random() * 1000),150 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],151 },152 {153 name: '海南',154 value: Math.round(Math.random() * 1000),155 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],156 },157 {158 name: '台湾',159 value: Math.round(Math.random() * 1000),160 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],161 },162 {163 name: '香港',164 value: Math.round(Math.random() * 1000),165 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],166 },167 {168 name: '澳门',169 value: Math.round(Math.random() * 1000),170 tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)],171 },172];173export const getLineData = (() => {174 const category: any[] = [];175 let dottedBase = +new Date();176 const lineData: any[] = [];177 const barData: any[] = [];178 for (let i = 0; i < 20; i++) {179 const date = new Date((dottedBase += 1000 * 3600 * 24));180 category.push([date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'));181 const b = Math.random() * 200;182 const d = Math.random() * 200;183 barData.push(b);184 lineData.push(d + b);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root';2import { round } from 'storybook-root';3import { round } from 'storybook-root';4import { round } from 'storybook-root';5import { round } from 'storybook-root';6import { round } from 'storybook-root';7import { round } from 'storybook-root';8import { round } from 'storybook-root';9import { round } from 'storybook-root';10import { round } from 'storybook-root';11import { round } from 'storybook-root';12import { round } from 'storybook-root';13import { round } from 'storybook-root';14import { round } from 'storybook-root';15import { round } from 'storybook-root';16import { round } from 'storybook-root';17import { round } from 'storybook-root';18import { round } from 'storybook-root';19import { round } from 'storybook-root';20import { round } from 'storybook-root';21import { round } from 'storybook-root';22import { round } from 'storybook-root';23import { round } from 'storybook-root';24import { round } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root';2import { round } from 'storybook-root';3import { round } from 'storybook-root';4import { round } from 'storybook-root';5import { round } from 'storybook-root';6import { round } from 'storybook-root';7import { round } from 'storybook-root';8import { round } from 'storybook-root';9import { round } from 'storybook-root';10import { round } from 'storybook-root';11import { round } from 'storybook-root';12import { round } from 'storybook-root';13import { round } from 'storybook-root';14import { round } from 'storybook-root';15import { round } from 'storybook-root';16import { round } from 'storybook-root';17import { round } from 'storybook-root';18import { round } from 'storybook-root';19import { round } from 'storybook-root';20import { round } from 'storybook-root';21import { round } from 'storybook-root';22import { round } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root-decorator';2import { round } from 'storybook-root-decorator';3import { round } from 'storybook-root-decorator';4import { round } from 'storybook-root-decorator';5import { round } from 'storybook-root-decorator';6import { round } from 'storybook-root-decorator';7import { round } from 'storybook-root-decorator';8import { round } from 'storybook-root-decorator';9import { round } from 'storybook-root-decorator';10import { round } from 'storybook-root-decorator';11import { round } from 'storybook-root-decorator';12import { round } from 'storybook-root-decorator';13import { round } from 'storybook-root-decorator';14import { round } from 'storybook-root-decorator';15import { round } from 'storybook-root-decorator';16import { round } from 'storybook-root-decorator';17import { round } from 'storybook-root-decorator';18import { round } from '

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root';2import { round } from 'storybook-root';3import { round } from 'storybook-root';4import { round } from 'storybook-root';5import { round } from 'storybook-root';6import { round } from 'storybook-root';7import { round } from 'storybook-root';8import { round } from 'storybook-root';9import { round } from 'storybook-root';10import { round } from 'storybook-root';11import { round } from 'storybook-root';12import { round } from 'storybook-root';13import { round } from 'storybook-root';14import { round } from 'storybook-root';15import { round } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root-decorator';2const App = () => {3 const [count, setCount] = useState(0);4 const [count2, setCount2] = useState(0);5 const [count3, setCount3] = useState(0);6 const [count4, setCount4] = useState(0);7 const [count5, setCount5] = useState(0);8 const [count6, setCount6] = useState(0);9 const [count7, setCount7] = useState(0);10 const [count8, setCount8] = useState(0);11 const [count9, setCount9] = useState(0);12 const [count10, setCount10] = useState(0);13 const [count11, setCount11] = useState(0);14 const [count12, setCount12] = useState(0);15 const [count13, setCount13] = useState(0);16 const [count14, setCount14] = useState(0);17 const [count15, setCount15] = useState(0);18 const [count16, setCount16] = useState(0);19 const [count17, setCount17] = useState(0);20 const [count18, setCount18] = useState(0);21 const [count19, setCount19] = useState(0);22 const [count20, setCount20] = useState(0);23 const [count21, setCount21] = useState(0);24 const [count22, setCount22] = useState(0);25 const [count23, setCount23] = useState(0);26 const [count24, setCount24] = useState(0);27 const [count25, setCount25] = useState(0);28 const [count26, setCount26] = useState(0);29 const [count27, setCount27] = useState(0);30 const [count28, setCount28] = useState(0);

Full Screen

Using AI Code Generation

copy

Full Screen

1import root from 'storybook-root'2import root from 'storybook-root'3import root from 'storybook-root'4import root from 'storybook-root'5import root from 'storybook-root'6import root from 'storybook-root'7import root from 'storybook-root'8import root from 'storybook-root'9import root from 'storybook-root'10import root from 'storybook-root'11import root from 'storybook-root'12import root from 'storybook-root'

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root';2console.log('round', round(10.5, 0));3import { round } from 'storybook-root';4console.log('round', round(10.5, 0));5import { round } from 'storybook-root';6console.log('round', round(10.5, 0));7import { round } from 'storybook-root';8console.log('round', round(10.5, 0));9import { round } from 'storybook-root';10console.log('round', round(10.5, 0));11import { round } from 'storybook-root';12console.log('round', round(10.5, 0));13import { round } from 'storybook-root';14console.log('round', round(10.5, 0));15import { round } from 'storybook-root';16console.log('round', round(10.5, 0));17import { round } from 'storybook-root';18console.log('round', round(10.5, 0));19import { round } from 'storybook-root';20console.log('round', round(10.5, 0));21import { round } from 'storybook-root';22console.log('round', round(10.5, 0));23import { round } from 'storybook-root';24console.log('round', round(10.5, 0));25import { round } from 'storybook-root';26console.log('round', round(10.5, 0));27import { round } from 'storybook-root';28console.log('round', round(10.5, 0));29import { round } from 'storybook-root';30console.log('round', round(10.5, 0));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { round } from 'storybook-root'2const result = round(1.01)3export function round(number) {4 return Math.round(number)5}6{7}8{9 "dependencies": {10 }11}12 const result = round(1.01)

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