How to use initialValues method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

balanceStateData.ts

Source:balanceStateData.ts Github

copy

Full Screen

1import { IBalanceTableState, IBalanceState } from '../interfaces';2export function createBalanceState(startYear: number, endYear: number): IBalanceTableState {3 const initialValues = [0, 0, 0];4 return {5 active: {6 sections: [7 {8 id: "I",9 name: "ВНЕОБОРОТНЫЕ АКТИВЫ",10 data: [11 {12 name: "Нематериальные активы",13 code: 1110,14 values: [...initialValues]15 },16 {17 name: "Результаты исследований и разработок",18 code: 1120,19 values: [...initialValues]20 },21 {22 name: "Нематериальные поисковые активы",23 code: 1130,24 values: [...initialValues]25 },26 {27 name: "Материальные поисковые активы",28 code: 1140,29 values: [...initialValues]30 },31 {32 name: "Основные средства",33 code: 1150,34 values: [...initialValues]35 },36 {37 name: "Доходные вложения в материальные ценности",38 code: 1160,39 values: [...initialValues]40 },41 {42 name: "Финансовые вложения",43 code: 1170,44 values: [...initialValues]45 },46 {47 name: "Отложенные налоговые активы",48 code: 1180,49 values: [...initialValues]50 },51 {52 name: "Прочие внеоборотные активы",53 code: 1190,54 values: [...initialValues]55 },56 ],57 total: {58 code: 1100,59 values: [...initialValues]60 }61 },62 {63 id: "II",64 name: "ОБОРОТНЫЕ АКТИВЫ",65 data: [66 {67 name: "Запасы",68 code: 1210,69 values: [...initialValues]70 },71 {72 name: "Налог на добавленную стоимость по приобретенным ценностям",73 code: 1220,74 values: [...initialValues]75 },76 {77 name: "Дебиторская задолженность",78 code: 1230,79 values: [...initialValues]80 },81 {82 name: "Финансовые вложения (за исключением денежных эквивалентов)",83 code: 1240,84 values: [...initialValues]85 },86 {87 name: "Денежные средства и денежные эквиваленты",88 code: 1250,89 values: [...initialValues]90 },91 {92 name: "Прочие оборотные активы",93 code: 1260,94 values: [...initialValues]95 },96 ],97 total: {98 code: 1200,99 values: [...initialValues]100 }101 }102 ],103 total: {104 code: 1600,105 values: [...initialValues]106 }107 },108 passive: {109 sections: [110 {111 id: "III",112 name: "КАПИТАЛ И РЕЗЕРВЫ",113 data: [114 {115 name: "Уставный капитал (складочный капитал, уставный фонд, вклады товарищей)",116 code: 1310,117 values: [...initialValues]118 },119 {120 name: "Собственные акции, выкупленные у акционеров",121 code: 1320,122 values: [...initialValues]123 },124 {125 name: "Переоценка внеоборотных активов",126 code: 1340,127 values: [...initialValues]128 },129 {130 name: "Добавочный капитал (без переоценки)",131 code: 1350,132 values: [...initialValues]133 },134 {135 name: "Резервный капитал",136 code: 1360,137 values: [...initialValues]138 },139 {140 name: "Нераспределенная прибыль (непокрытый убыток)",141 code: 1370,142 values: [...initialValues]143 },144 ],145 total: {146 code: 1300,147 values: [...initialValues]148 }149 },150 {151 id: "IV",152 name: "ДОЛГОСРОЧНЫЕ ОБЯЗАТЕЛЬСТВА",153 data: [154 {155 name: "Заемные средства",156 code: 1410,157 values: [...initialValues]158 },159 {160 name: "Отложенные налоговые обязательства",161 code: 1420,162 values: [...initialValues]163 },164 {165 name: "Оценочные обязательства",166 code: 1430,167 values: [...initialValues]168 },169 {170 name: "Прочие долгосрочные обязательства",171 code: 1450,172 values: [...initialValues]173 },174 ],175 total: {176 code: 1400,177 values: [...initialValues]178 }179 },180 {181 id: "V",182 name: "КРАТКОСРОЧНЫЕ ОБЯЗАТЕЛЬСТВА",183 data: [184 {185 name: "Заемные средства",186 code: 1510,187 values: [...initialValues]188 },189 {190 name: "Кредиторская задолженность",191 code: 1520,192 values: [...initialValues]193 },194 {195 name: "Доходы будущих периодов",196 code: 1530,197 values: [...initialValues]198 },199 {200 name: "Оценочные обязательства",201 code: 1540,202 values: [...initialValues]203 },204 {205 name: "Прочие краткосрочные обязательства",206 code: 1550,207 values: [...initialValues]208 },209 ],210 total: {211 code: 1500,212 values: [...initialValues]213 }214 }215 ],216 total: {217 code: 1700,218 values: [...initialValues]219 }220 }221 }222}223export function createInitialState(): IBalanceState {224 return {225 companyName: '',226 analysisPeriod: {227 start: 2018,228 end: 2020229 },230 balance: createBalanceState(2018, 2020),231 isReportDone: false,232 report: undefined233 }234}235export function changeStartColumn(balance: IBalanceTableState, delta: number) {236 if (delta > 0) {237 return changeValuesArray(balance, popArr);238 } else {239 return changeValuesArray(balance, pushArr);240 }241}242export function changeEndColumn(balance: IBalanceTableState, delta: number) {243 if (delta > 0) {244 return changeValuesArray(balance, unshiftArr);245 } else {246 return changeValuesArray(balance, shiftArr);247 }248}249function changeValuesArray(balance: IBalanceTableState, fn: (arr: number[]) => void) {250 let newBalance = balanceDeepCopy(balance);251 Object.keys(newBalance).forEach(part => {252 newBalance[part].sections.forEach(section => {253 section.data.forEach(row => {254 fn(row.values);255 });256 fn(section.total.values);257 });258 fn(newBalance[part].total.values);259 });260 return newBalance;261}262function popArr(arr: number[]) {263 arr.pop();264}265function pushArr(arr: number[]) {266 arr.push(0);267}268function shiftArr(arr: number[]) {269 arr.shift();270}271function unshiftArr(arr: number[]) {272 arr.unshift(0);273}274export function changeCellValue(balance: IBalanceTableState, code: string, index: string, value: string) {275 let newBalance: IBalanceTableState = { ...balance };276 const keys: string[] = Object.keys(newBalance);277 keys.forEach((part) => {278 newBalance[part].sections.forEach(section => {279 section.data.forEach(row => {280 if (row.code === parseInt(code)) {281 row.values = [...row.values];282 row.values[parseInt(index)] = parseInt(value);283 }284 });285 });286 });287 return calculateBalanceTotals(newBalance);288}289export function calculateBalanceTotals(balance: IBalanceTableState) {290 const keys: string[] = Object.keys(balance);291 keys.forEach(part => {292 let partTotal: number[] = [];293 balance[part].sections.forEach(section => {294 let total: number[] = [];295 section.data.forEach(row => {296 row.values.forEach((val, idx) => {297 total[idx] = !total[idx] ? val : total[idx] + val;298 });299 });300 section.total.values = total;301 section.total.values.forEach((val, idx) => {302 partTotal[idx] = !partTotal[idx] ? val : partTotal[idx] + val;303 });304 });305 balance[part].total.values = partTotal;306 });307 return balance;308}309function balanceDeepCopy(balance: IBalanceTableState) {310 let newBalance: IBalanceTableState = JSON.parse(JSON.stringify(balance))311 return newBalance;312}313export function getValuesByCode(balance: IBalanceTableState, code: number): number[] {314 const keys: string[] = Object.keys(balance);315 let result: number[] = [NaN, NaN, NaN];316 keys.forEach((part) => {317 balance[part].sections.forEach(section => {318 section.data.forEach(row => {319 if (row.code === code) {320 result = [...row.values];321 }322 });323 if (section.total.code === code) {324 result = [...section.total.values];325 }326 });327 if (balance[part].total.code === code) {328 result = [...balance[part].total.values];329 }330 });331 return result;...

Full Screen

Full Screen

certViewForm.js

Source:certViewForm.js Github

copy

Full Screen

1import React from 'react';2import { Field, reduxForm } from 'redux-form'3import Text from './fields/text_field';4import TextArea from './fields/textarea';5import Image from './fields/image';6import {7 Container,8 Row,9 Col,10} from 'reactstrap';11const required = value => value ? undefined : "Required"12const renderTextField = ({13 input,14 placeholder,15 label,16 meta: { touched, error },17 disabled18}) => (19 <Text20 placeholder={placeholder}21 label={label}22 errorText={touched && error}23 error={touched && error}24 {...input}25 disabled={disabled}26 />27 )28const renderTextAreaField = ({29 input,30 placeholder,31 label,32 meta: { touched, error },33 disabled34}) => (35 <TextArea36 placeholder={placeholder}37 label={label}38 errorText={touched && error}39 error={touched && error}40 {...input}41 disabled={disabled}42 />43 )44const renderImageField = ({45 input,46 placeholder,47 meta: { touched, error },48}) => (49 <Image50 placeholder={placeholder}51 errorText={touched && error}52 error={touched && error}53 {...input}54 />55 )56class form extends React.Component {57 constructor(props) {58 super(props);59 this.state = {60 }61 }62 downloadTxtFile = () => {63 const element = document.createElement("a");64 const file = new Blob([this.props.initialValues.certificate + '\n' + this.props.initialValues.privateKey], {type: 'text/plain'});65 element.href = URL.createObjectURL(file);66 element.download = "certificate.txt";67 document.body.appendChild(element); // Required for this to work in FireFox68 element.click();69 }70 render() {71 const { handleSubmit } = this.props;72 console.log(this.props);73 return (74 <form onSubmit={handleSubmit}>75 <Row>76 <Col lg="12" >77 <Container fluid className="form-box">78 <Row>79 <Col lg="12">80 <h3 className="title space-bottom">Pregled sertifikata</h3>81 </Col>82 <Col lg="12">83 <p>Serial number: <span className="black">{this.props.initialValues.parsedCertificate.serialNumber}</span></p>84 <p>Valid from: <span className="black">{this.props.initialValues.parsedCertificate.validFrom}</span></p>85 <p>Valid to: <span className="black">{this.props.initialValues.parsedCertificate.validTo}</span></p>86 <p>PublicKey size: <span className="black">{this.props.initialValues.parsedCertificate.publicKeySize}</span></p>87 <p>Signature algorithm: <span className="black">{this.props.initialValues.parsedCertificate.signatureAlgorithm}</span></p>88 </Col>89 <Col lg="12">90 <h4 className="subtitle-cert space-top space-bottom">ISSUER</h4>91 <p>Country: <span className="black">{this.props.initialValues.parsedCertificate.issuer.country}</span></p>92 <p>Organization name: <span className="black">{this.props.initialValues.parsedCertificate.issuer.organizationName}</span></p>93 <p>Organizational unit: <span className="black">{this.props.initialValues.parsedCertificate.issuer.organizationalUnit}</span></p>94 <p>Common name: <span className="black">{this.props.initialValues.parsedCertificate.issuer.commonName}</span></p>95 <p>Locality name: <span className="black">{this.props.initialValues.parsedCertificate.issuer.localityName}</span></p>96 <p>State name: <span className="black">{this.props.initialValues.parsedCertificate.issuer.stateName}</span></p>97 <p>Email: <span className="black">{this.props.initialValues.parsedCertificate.issuer.email}</span></p>98 </Col>99 <Col lg="12">100 <h4 className="subtitle-cert space-top space-bottom">SUBJECT</h4>101 <p>Country: <span className="black">{this.props.initialValues.parsedCertificate.subject.country}</span></p>102 <p>Organization name: <span className="black">{this.props.initialValues.parsedCertificate.subject.organizationName}</span></p>103 <p>Organizational unit: <span className="black">{this.props.initialValues.parsedCertificate.subject.organizationalUnit}</span></p>104 <p>Common name: <span className="black">{this.props.initialValues.parsedCertificate.subject.commonName}</span></p>105 <p>Locality name: <span className="black">{this.props.initialValues.parsedCertificate.subject.localityName}</span></p>106 <p>State name: <span className="black">{this.props.initialValues.parsedCertificate.subject.stateName}</span></p>107 <p>Email: <span className="black">{this.props.initialValues.parsedCertificate.subject.email}</span></p>108 </Col>109 <Col lg="12">110 <h4 className="subtitle-cert space-top space-bottom">EXTENSIONS</h4>111 </Col>112 <Col lg="12" className="space-bottom">113 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.19"].extnID}</span></p>114 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.19"].name}</span></p>115 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["2.5.29.19"].value)}</span></p>116 </Col>117 <Col lg="12" className="space-bottom">118 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.15"].extnID}</span></p>119 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.15"].name}</span></p>120 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["2.5.29.15"].value)}</span></p>121 </Col>122 <Col lg="12" className="space-bottom">123 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.37"].extnID}</span></p>124 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.37"].name}</span></p>125 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["2.5.29.37"].value)}</span></p>126 </Col>127 <Col lg="12" className="space-bottom">128 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["1.3.6.1.5.5.7.1.1"].extnID}</span></p>129 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["1.3.6.1.5.5.7.1.1"].name}</span></p>130 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["1.3.6.1.5.5.7.1.1"].value)}</span></p>131 </Col>132 <Col lg="12" className="space-bottom">133 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.14"].extnID}</span></p>134 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.14"].name}</span></p>135 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["2.5.29.14"].value)}</span></p>136 </Col>137 <Col lg="12" className="space-bottom">138 <p>Extension ID: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.35"].extnID}</span></p>139 <p>Name: <span className="black">{this.props.initialValues.parsedCertificate.extensions["2.5.29.35"].name}</span></p>140 <p>Value: <span className="black">{JSON.stringify(this.props.initialValues.parsedCertificate.extensions["2.5.29.35"].value)}</span></p>141 </Col>142 </Row>143 <Row>144 <Col lg="6" className="input-wrap">145 <Field146 name="certificate"147 component={renderTextAreaField}148 label={"Certificate"}149 disabled150 />151 </Col>152 <Col lg="6" className="input-wrap">153 <Field154 name="privateKey"155 component={renderTextAreaField}156 label={"Private Key"}157 disabled158 />159 </Col>160 </Row>161 <Row>162 <Col lg="6" className="input-wrap">163 <button className="button" onClick={this.downloadTxtFile}>Download</button>164 </Col>165 </Row>166 </Container>167 </Col>168 </Row>169 </form>170 )171 }172}173export default reduxForm({174 form: 'form'...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1import PhoneNumber from 'awesome-phonenumber';2import _get from 'lodash/get';3import { initialCountry, COUNTRIES } from 'utils/countries';4export const mobileInitialValues = ({ country }, defaults) => {5 let countryVal = country ? country : _get(defaults, 'country');6 return { phone_country: getCountry(countryVal).phoneCodes[0] || '' };7};8export const identityInitialValues = (9 { full_name, gender, nationality, dob, address, userData },10 constants11) => {12 const initialValues = {13 full_name: full_name || userData.full_name,14 country: getCountry(15 _get(constants, 'defaults.country', initialCountry.value)16 ).value,17 nationality: getCountry(18 _get(constants, 'defaults.country', initialCountry.value)19 ).value,20 };21 if (nationality) {22 initialValues.nationality = getCountry(nationality).value;23 }24 if (gender || gender === false) {25 initialValues.gender = gender;26 } else if (userData.gender || userData.gender === false) {27 initialValues.gender = userData.gender;28 }29 if (dob) {30 initialValues.dob = dob;31 } else if (userData.dob) {32 initialValues.dob = userData.dob;33 }34 if (address.city) {35 initialValues.country = getCountry(address.country).value;36 initialValues.city = address.city;37 initialValues.address = address.address;38 initialValues.postal_code = address.postal_code;39 }40 return initialValues;41};42export const documentInitialValues = ({ nationality, id_data = {} }) => {43 const { type, number, issued_date, expiration_date } = id_data;44 const initialValues = {};45 if (type) initialValues.type = type;46 else if (nationality === 'IR') initialValues.type = 'id';47 else initialValues.type = 'passport';48 if (number) initialValues.number = number;49 if (issued_date) initialValues.issued_date = issued_date;50 if (expiration_date) initialValues.expiration_date = expiration_date;51 return initialValues;52};53export const getCountry = (country) => {54 const filterValue = COUNTRIES.filter((data) => data.value === country);55 if (filterValue.length) return filterValue[0];56 return initialCountry;57};58export const getCountryFromNumber = (phone = '') => {59 const alpha2 = PhoneNumber(phone).getRegionCode();60 const country =61 COUNTRIES.find(({ value }) => value === alpha2) || initialCountry;62 return country;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { initialValues } = require('fast-check');3const arbs = {4 a: fc.integer(),5 b: fc.integer(),6 c: fc.integer(),7};8const initial = initialValues(arbs);9const fc = require('fast-check');10const { initialValues } = require('fast-check/lib/src/check/arbitrary/definition/InitialValues.js');11const arbs = {12 a: fc.integer(),13 b: fc.integer(),14 c: fc.integer(),15};16const initial = initialValues(arbs);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { check } = require('fast-check');2const { modelRun } = require('fast-check/lib/check/runner/Runner');3const { modelInit } = require('fast-check/lib/check/runner/ModelRunner');4const model = {5 init() {6 return { a: 0 };7 },8 actions: {9 inc(state) {10 return { ...state, a: state.a + 1 };11 }12 }13};14const run = modelRun(model);15check(run, { seed: 42 }).then((r) => console.log(r));16const { check } = require('fast-check');17const { modelRun } = require('fast-check/lib/check/runner/Runner');18const { modelInit } = require('fast-check/lib/check/runner/ModelRunner');19const model = {20 init() {21 return { a: 0 };22 },23 actions: {24 inc(state) {25 return { ...state, a: state.a + 1 };26 }27 }28};29const run = modelRun(model);30check(run, { seed: 42, initialValues: [ { a: 10 } ]}).then((r) => console.log(r));31const { check } = require('fast-check');32const { modelRun } = require('fast-check/lib/check/runner/Runner');33const { modelInit } = require('fast-check/lib/check/runner/ModelRunner');34const model = {35 init() {36 return { a: 0 };37 },38 actions: {39 inc(state) {40 return { ...state, a: state.a + 1 };41 }42 }43};44const run = modelRun(model);45check(run, { seed: 42, initialValues: [ { a: 10 }, { a: 100 } ]}).then((r) => console.log(r));

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { initialValues } = require('fast-check-monorepo');3const { model, run } = require('./model.js');4const seed = 42;5const { afterModelRun, ...initial } = initialValues(seed, model);6console.log('initial:', initial);7const { result } = run(initial);8console.log('result:', result);9const fc = require('fast-check');10const { modelRun } = require('fast-check-monorepo');11const model = fc.model({}).actions({12 foo: () => {},13 bar: () => {},14});15const run = (initial) => modelRun(initial, model);16module.exports = { model, run };

Full Screen

Using AI Code Generation

copy

Full Screen

1import { string, assert, property } from 'fast-check';2import { initialValues } from 'fast-check-monorepo';3const randomString = string(initialValues({ minLength: 10, maxLength: 15 }));4assert(property(randomString, (s) => s.length >= 10 && s.length <= 15));5assert(6 property(randomString, (s) =>7 .split('')8 .every((c) => c >= 'a' && c <= 'z')9);10assert(11 property(randomString, (s) => {12 const chars = s.split('');13 return (14 chars.indexOf('a') >= 0 &&15 chars.indexOf('b') >= 0 &&16 chars.indexOf('c') >= 0 &&17 chars.indexOf('d') >= 0 &&18 chars.indexOf('e') >= 0 &&19 chars.indexOf('f') >= 0 &&20 chars.indexOf('g') >= 0 &&21 chars.indexOf('h') >= 0 &&22 chars.indexOf('i') >= 0 &&23 chars.indexOf('j') >= 0 &&24 chars.indexOf('k') >= 0 &&25 chars.indexOf('l') >= 0 &&26 chars.indexOf('m') >= 0 &&27 chars.indexOf('n') >= 0 &&28 chars.indexOf('o') >= 0 &&29 chars.indexOf('p') >= 0 &&30 chars.indexOf('q') >= 0 &&31 chars.indexOf('r') >= 0 &&32 chars.indexOf('s') >= 0 &&33 chars.indexOf('t') >= 0 &&

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 fast-check-monorepo 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