Best JavaScript code snippet using stryker-parent
retrieve-dropdown-api.js
Source:retrieve-dropdown-api.js
...25 totalOptions = newData;26 };27 const setStaticDropdown = (data, fieldName) => {28 const prefilteredMdmOptions = organizeStaticPrefilterMDMData(data);29 setDefaultOptions(prefilteredMdmOptions, fieldName, false);30 };31 for (const fieldName of dropDownFields) {32 let options = [];33 switch (fieldName) {34 case "parameterCode":35 if (mats) {36 await dmApi.getAllMatsParameterCodes().then((response) => {37 options = response.data.map((option) => {38 return {39 code: option["matsMethodParamCode"],40 name: option["matsMethodParamCodeDescription"],41 };42 });43 setDefaultOptions(options, "supplementalMATSParameterCode");44 });45 } else if (equipmentControl) {46 await dmApi47 .getAllControlEquipmentParameterCodes()48 .then((response) => {49 options = response.data.map((option) => {50 return {51 code: option["controlEquipParamCode"],52 name: option["controlEquipParamDescription"],53 };54 });55 setDefaultOptions(options, "parameterCode");56 });57 } else {58 await dmApi.getAllParameterCodes().then((response) => {59 options = response.data.map((option) => {60 return {61 code: option["parameterCode"],62 name: option["parameterCodeDescription"],63 };64 });65 setDefaultOptions(options, fieldName);66 });67 }68 break;69 case "monitoringMethodCode":70 if (mats) {71 await dmApi.getAllMatsMethodCodes().then((response) => {72 options = response.data.map((option) => {73 return {74 code: option["matsMethodCode"],75 name: option["matsMethodCodeDescription"],76 };77 });78 setDefaultOptions(options, "supplementalMATSMonitoringMethodCode");79 });80 } else {81 await dmApi.getAllMethodCodes().then((response) => {82 options = response.data.map((option) => {83 return {84 code: option["methodCode"],85 name: option["methodCodeDescription"],86 };87 });88 setDefaultOptions(options, fieldName);89 });90 }91 break;92 case "substituteDataCode":93 await dmApi.getAllSubstituteDataCodes().then((response) => {94 options = response.data.map((option) => {95 return {96 code: option["subDataCode"],97 name: option["subDataCodeDescription"],98 };99 });100 setDefaultOptions(options, fieldName);101 });102 break;103 case "bypassApproachCode":104 await dmApi.getAllBypassApproachCodes().then((response) => {105 options = response.data.map((option) => {106 return {107 code: option["bypassApproachCode"],108 name: option["bypassApproachCodeDescription"],109 };110 });111 setDefaultOptions(options, fieldName);112 });113 break;114 //Analyzer Range115 case "analyzerRangeCode":116 await dmApi.getAllRangeCodes().then((response) => {117 options = response.data.map((option) => {118 return {119 code: option["analyzerRangeCode"],120 name: option["analyzerRangeCodeDescription"],121 };122 });123 setDefaultOptions(options, fieldName);124 });125 break;126 // System Fuel Flows127 case "maximumFuelFlowRateSourceCode":128 await dmApi.getAllMaxRateSourceCodes().then((response) => {129 options = response.data.map((option) => {130 return {131 code: option["maxRateSourceCode"],132 name: option["maxRateSourceCodeDescription"],133 };134 });135 setDefaultOptions(options, fieldName);136 });137 break;138 case "defaultUnitsOfMeasureCode":139 case "spanUnitsOfMeasureCode":140 case "maximumLoadUnitsOfMeasureCode":141 case "systemFuelFlowUOMCode":142 case "unitsOfStandard":143 await dmApi.getAllUnitsOfMeasureCodes().then((response) => {144 options = response.data.map((option) => {145 return {146 code: option["unitsOfMeasureCode"],147 name: option["unitsOfMeasureCodeDescription"],148 };149 });150 setDefaultOptions(options, fieldName);151 });152 break;153 case "fuelType":154 await dmApi.getAllFuelTypes().then((response) => {155 options = response.data.map((option) => {156 return {157 code: option["fuelTypeCode"],158 name: option["fuelTypeDescription"],159 };160 });161 setDefaultOptions(options, "fuelCode");162 });163 break;164 case "fuelCode":165 await dmApi.getAllFuelCodes().then((response) => {166 options = response.data.map((option) => {167 return {168 code: option["fuelCode"],169 name: option["fuelCodeDescription"],170 };171 });172 setDefaultOptions(options, fieldName);173 });174 break;175 case "indicatorCode":176 await dmApi.getAllFuelIndicatorCodes().then((response) => {177 options = response.data.map((option) => {178 return {179 code: option["fuelIndicatorCode"],180 name: option["fuelIndicatorCodeDescription"],181 };182 });183 setDefaultOptions(options, fieldName);184 });185 break;186 case "demGCV":187 await dmApi.getAllDemonstrationMethodCodes().then((response) => {188 options = response.data.map((option) => {189 return {190 code: option["demMethodCode"],191 name: option["demMethodCodeDescription"],192 };193 });194 setDefaultOptions(options, fieldName);195 });196 break;197 case "demSO2":198 await dmApi.getAllDemonstrationMethodCodes().then((response) => {199 options = response.data.map((option) => {200 return {201 code: option["demMethodCode"],202 name: option["demMethodCodeDescription"],203 };204 });205 setDefaultOptions(options, fieldName);206 });207 break;208 case "systemTypeCode":209 await dmApi.getAllSystemTypeCodes().then((response) => {210 options = response.data.map((option) => {211 return {212 code: option["systemTypeCode"],213 name: option["systemTypeCodeDescription"],214 };215 });216 setDefaultOptions(options, fieldName);217 });218 break;219 case "systemDesignationCode":220 await dmApi.getAllSystemDesignationCodes().then((response) => {221 options = response.data.map((option) => {222 return {223 code: option["systemDesignationCode"],224 name: option["systemDesignationCodeDescription"],225 };226 });227 setDefaultOptions(options, fieldName);228 });229 break;230 case "sampleAcquisitionMethodCode":231 await dmApi.getAllAcquisitionMethodCodes().then((response) => {232 options = response.data.map((option) => {233 return {234 code: option["acquisitionMethodCode"],235 name: option["acquisitionMethodCodeDescription"],236 };237 });238 setDefaultOptions(options, fieldName);239 });240 break;241 case "componentTypeCode":242 await dmApi.getAllComponentTypeCodes().then((response) => {243 options = response.data.map((option) => {244 return {245 code: option["componentTypeCode"],246 name: option["componentTypeCodeDescription"],247 };248 });249 setDefaultOptions(options, fieldName);250 });251 break;252 case "basisCode":253 await dmApi.getAllBasisCodes().then((response) => {254 options = response.data.map((option) => {255 return {256 code: option["basisCode"],257 name: option["basisCodeDescription"],258 };259 });260 setDefaultOptions(options, fieldName);261 });262 break;263 // for spans264 case "spanScaleCode":265 await dmApi.getAllSpanScaleCodes().then((response) => {266 options = response.data.map((option) => {267 return {268 code: option["spanScaleCode"],269 name: option["spanScaleCodeDescription"],270 };271 });272 setDefaultOptions(options, fieldName);273 });274 break;275 case "spanMethodCode":276 await dmApi.getAllSpanMethodCodes().then((response) => {277 options = response.data.map((option) => {278 return {279 code: option["spanMethodCode"],280 name: option["spanMethodCodeDescription"],281 };282 });283 setDefaultOptions(options, fieldName);284 });285 break;286 case "normalLevelCode":287 case "secondLevelCode":288 case "operatingLevelCode":289 await dmApi.getAllOperatingLevelCodes().then((response) => {290 options = response.data.map((option) => {291 return {292 code: option["operatingLevelCode"],293 name: option["operatingLevelCodeDescription"],294 };295 });296 setDefaultOptions(options, fieldName);297 });298 break;299 // for defaults300 case "operatingConditionCode":301 await dmApi.getAllOperatingConditionCodes().then((response) => {302 options = response.data.map((option) => {303 return {304 code: option["operatingConditionCode"],305 name: option["operatingConditionCodeDescription"],306 };307 });308 setDefaultOptions(options, fieldName);309 });310 break;311 case "defaultSourceCode":312 await dmApi.getAllDefaultSourceCodes().then((response) => {313 options = response.data.map((option) => {314 return {315 code: option["defaultSourceCode"],316 name: option["defaultSourceCodeDescription"],317 };318 });319 setDefaultOptions(options, fieldName);320 });321 break;322 case "defaultPurposeCode":323 await dmApi.getAllDefaultPurposeCodes().then((response) => {324 options = response.data.map((option) => {325 return {326 code: option["defaultPurposeCode"],327 name: option["defaultPurposeCodeDescription"],328 };329 });330 setDefaultOptions(options, fieldName);331 });332 break;333 case "formulaCode":334 await dmApi.getAllFormulaCodes().then((response) => {335 options = response.data.map((option) => {336 return {337 code: option["equationCode"],338 name: option["equationCodeDescription"],339 };340 });341 setDefaultOptions(options, fieldName);342 });343 break;344 case "wafMethodCode":345 await dmApi.getAllRectangularDuctsCodes().then((response) => {346 options = response.data.map((option) => {347 return {348 code: option["wafMethodCode"],349 name: option["wafMethodCodeDescription"],350 };351 });352 setDefaultOptions(options, fieldName);353 });354 break;355 case "controlCode":356 await dmApi.getAllControlTechnologies().then((response) => {357 options = response.data.map((option) => {358 return {359 code: option["controlCode"],360 name: option["controlDescription"],361 };362 });363 setDefaultOptions(options, fieldName);364 });365 break;366 case "qualificationTypeCode":367 await dmApi.getAllQualificationTypeCodes().then((response) => {368 options = response.data.map((option) => {369 return {370 code: option["qualTypeCode"],371 name: option["qualTypeCodeDescription"],372 };373 });374 setDefaultOptions(options, fieldName);375 });376 break;377 case "qualificationYear":378 case "yr1QualificationDataYear":379 case "yr2QualificationDataYear":380 case "yr3QualificationDataYear":381 case "qualificationDataYear":382 dataYearOptions().then((years) => {383 options = years.map((year) => {384 return {385 code: year.toString(),386 name: year.toString(),387 };388 });389 setDefaultOptions(options, fieldName);390 });391 break;392 case "yr1QualificationDataTypeCode":393 case "yr2QualificationDataTypeCode":394 case "yr3QualificationDataTypeCode":395 await dmApi.getAllQualificationDataTypeCodes().then((response) => {396 options = response.data.map((option) => {397 return {398 code: option["qualDataTypeCode"],399 name: option["qualDataTypeCodeDescription"],400 };401 });402 setDefaultOptions(options, fieldName);403 });404 break;405 case "qualificationTestType":406 await dmApi.getAllQualificationLEETestTypeCodes().then((response) => {407 options = response.data.map((option) => {408 return {409 code: option["qualLeeTestTypeCode"],410 name: option["qualLeeTestTypeDescription"],411 };412 });413 setDefaultOptions(options, fieldName);414 });415 break;416 case "materialCode":417 await dmApi.getAllMaterialCodes().then((response) => {418 options = response.data.map((option) => {419 return {420 code: option["materialCode"],421 name: option["materialCodeDescription"],422 };423 });424 setDefaultOptions(options, fieldName);425 });426 break;427 case "shapeCode":428 await dmApi.getAllShapeCodes().then((response) => {429 options = response.data.map((option) => {430 return {431 code: option["shapeCode"],432 name: option["shapeCodeDescription"],433 };434 });435 setDefaultOptions(options, fieldName);436 });437 break;438 case "prefilteredMatsMethods":439 let noDupesMatsMethodCodes = [];440 // returns all the parameter codes441 await dmApi.getPrefilteredMatsMethods().then((response) => {442 const viewData = response.data;443 // Get parameter codes444 noDupesMatsMethodCodes = viewData.map((code) => {445 return code["supplementalMATSParameterCode"];446 });447 // Filter out the duplicates448 noDupesMatsMethodCodes = [...new Set(noDupesMatsMethodCodes)];449 const prefilteredMdmOptions = organizePrefilterMDMData(450 noDupesMatsMethodCodes,451 "supplementalMATSParameterCode",452 response.data453 );454 // Afterwards, we should have an array that has all the possible formula codes for each parameter code455 setDefaultOptions(prefilteredMdmOptions, fieldName);456 });457 break;458 case "prefilteredMethods":459 let noDupesMethodCodes = [];460 // returns all the parameter codes461 await dmApi.getPrefilteredMethods().then((response) => {462 const viewData = response.data;463 // Get parameter codes464 noDupesMethodCodes = viewData.map((code) => {465 return code["parameterCode"];466 });467 // Filter out the duplicates468 noDupesMethodCodes = [...new Set(noDupesMethodCodes)];469 const prefilteredMdmOptions = organizePrefilterMDMData(470 noDupesMethodCodes,471 "parameterCode",472 response.data473 );474 // Afterwards, we should have an array that has all the possible formula codes for each parameter code475 setDefaultOptions(prefilteredMdmOptions, fieldName);476 });477 break;478 case "prefilteredFormulas":479 let noDupesFormulaCodes = [];480 // returns all the parameter codes481 await dmApi.getPrefilteredFormulas().then((response) => {482 const viewData = response.data;483 // Get parameter codes484 noDupesFormulaCodes = viewData.map((code) => {485 return code["parameterCode"];486 });487 // Filter out the duplicates488 noDupesFormulaCodes = [...new Set(noDupesFormulaCodes)];489 const prefilteredMdmOptions = organizePrefilterMDMData(490 noDupesFormulaCodes,491 "parameterCode",492 response.data493 );494 // Afterwards, we should have an array that has all the possible formula codes for each parameter code495 setDefaultOptions(prefilteredMdmOptions, fieldName);496 });497 break;498 case "prefilteredSpans":499 let noDupesSpanCodes = [];500 await dmApi.getPrefilteredSpans().then((response) => {501 noDupesSpanCodes = response.data.map((code) => {502 return code["componentTypeCode"];503 });504 noDupesSpanCodes = [...new Set(noDupesSpanCodes)];505 const prefilteredMdmOptions = organizePrefilterMDMData(506 noDupesSpanCodes,507 "componentTypeCode",508 response.data509 );510 setDefaultOptions(prefilteredMdmOptions, fieldName);511 });512 break;513 case "prefilteredDefaults":514 let noDupesDefaultCodes = [];515 await dmApi.getPrefilteredDefaults().then((response) => {516 noDupesDefaultCodes = response.data.map((code) => {517 return code["parameterCode"];518 });519 noDupesDefaultCodes = [...new Set(noDupesDefaultCodes)];520 const prefilteredMdmOptions = organizePrefilterMDMData(521 noDupesDefaultCodes,522 "parameterCode",523 response.data524 );525 setDefaultOptions(prefilteredMdmOptions, fieldName);526 });527 break;528 case "prefilteredLoads":529 await dmApi.getPrefilteredLoads().then((response) => {530 setStaticDropdown(response.data, fieldName);531 });532 break;533 case "prefilteredUnitFuels":534 await dmApi.getPrefilteredUnitFuels().then((response) => {535 setStaticDropdown(response.data, fieldName);536 });537 break;538 case "prefilteredUnitControls":539 let noDupesFormCodesControls = [];540 await dmApi.getPrefilteredUnitControls().then((response) => {541 noDupesFormCodesControls = response.data.map((code) => {542 return code["controlEquipParamCode"];543 });544 options = response.data.map((option) => {545 return {546 parameterCode: option["controlEquipParamCode"],547 controlCode: option["controlCode"],548 };549 });550 noDupesFormCodesControls = [...new Set(noDupesFormCodesControls)];551 const prefilteredMdmOptions = organizePrefilterMDMData(552 noDupesFormCodesControls,553 "parameterCode",554 options555 );556 setDefaultOptions(prefilteredMdmOptions, fieldName);557 });558 break;559 case "prefilteredLEEQualifications":560 await dmApi.prefilteredLEEQualifications().then((response) => {561 setStaticDropdown(response.data, fieldName);562 });563 break;564 case "prefilteredSystemFuelFlows":565 await dmApi.getPrefilteredSystemFuelFlows().then((response) => {566 setStaticDropdown(response.data, fieldName);567 });568 break;569 case "prefilteredSystemsComponents":570 let noDupesSysComps = [];571 await dmApi.getPrefilteredSystemComponents().then((response) => {572 noDupesSysComps = response.data.map((code) => {573 return code["componentTypeCode"];574 });575 noDupesSysComps = [...new Set(noDupesSysComps)];576 const prefilteredMdmOptions = organizePrefilterMDMData(577 noDupesSysComps,578 "componentTypeCode",579 response.data580 );581 setDefaultOptions(prefilteredMdmOptions, fieldName);582 });583 break;584 //// QA & cert585 // case "testResultCode":586 // await dmApi.getAllTestResultCodes().then((response) => {587 // options = response.data.map((option) => {588 // return {589 // code: option["testResultCode"],590 // name: option["testResultCodeDescription"],591 // };592 // });593 // setDefaultOptions(options, fieldName);594 // });595 // break;596 // case "testReasonCode":597 // await dmApi.getAllTestReasonCodes().then((response) => {598 // options = response.data.map((option) => {599 // return {600 // code: option["testReasonCode"],601 // name: option["testReasonCodeDescription"],602 // };603 // });604 // setDefaultOptions(options, fieldName);605 // });606 // break;607 // case "testTypeCode":608 // await dmApi.getAllTestTypeCodes().then((response) => {609 // options = response.data.map((option) => {610 // return {611 // code: option["testTypeCode"],612 // name: option["testTypeCodeDescription"],613 // };614 // });615 // options = options.filter((option) =>616 // selectedTestCode.testTypeCodes.includes(option.code)617 // );618 // setDefaultOptions(options, fieldName);619 // });620 // break;621 // case "gasLevelCode":622 // await dmApi.getAllGasLevelCodes().then((response) => {623 // options = response.data.map((option) => {624 // return {625 // code: option["gasLevelCode"],626 // name: option["gasLevelDescription"],627 // };628 // });629 // setDefaultOptions(options, fieldName);630 // });631 // break;632 // case "gasTypeCode":633 // await dmApi.getAllGasTypeCodes().then((response) => {634 // options = response.data.map((option) => {635 // return {636 // code: option["gasTypeCode"],637 // name: option["gasTypeDescription"],638 // };639 // });640 // setDefaultOptions(options, fieldName);641 // });642 // break;643 // case "prefilteredTestSummaries":644 // let noDupesTestCodes = [];645 // await dmApi.getPrefilteredTestSummaries().then((response) => {646 // noDupesTestCodes = response.data.map((code) => {647 // return code["testTypeCode"];648 // });649 // noDupesTestCodes = [...new Set(noDupesTestCodes)];650 // const prefilteredMdmOptions = organizePrefilterMDMData(651 // noDupesTestCodes,652 // "testTypeCode",653 // response.data654 // );655 // setDefaultOptions(prefilteredMdmOptions, fieldName);656 // });657 // break;658 // case "rataFrequencyCode":659 // await dmApi.getAllRataFreqCodes().then((response) => {660 // options = response.data.map((option) => {661 // return {662 // code: option["rataFrequencyCode"],663 // name: option["rataFrequencyCodeDescription"],664 // };665 // });666 // setDefaultOptions(options, fieldName);667 // });668 // break;669 // case "apsCode":670 // await dmApi.getAllApsCodes().then((response) => {671 // options = response.data.map((option) => {672 // return {673 // code: option["apsCode"],674 // name: option["apsCodeDescription"],675 // };676 // });677 // setDefaultOptions(options, fieldName);678 // });679 // break;680 // case "runStatusCode":681 // await dmApi.getAllRunStatusCodes().then((response) => {682 // options = response.data.map((option) => {683 // return {684 // code: option["runStatusCode"],685 // name: option["runStatusCodeDescription"],686 // };687 // });688 // setDefaultOptions(options, fieldName);689 // });690 // break;691 // case "referenceMethodCode":692 // case "co2OrO2ReferenceMethodCode":693 // await dmApi.getAllReferenceMethodCodes().then((response) => {694 // options = response.data.map((option) => {695 // return {696 // code: option["referenceMethodCode"],697 // name: option["referenceMethodCodeDescription"],698 // };699 // });700 // setDefaultOptions(options, fieldName);701 // });702 // break;703 default:704 break;705 }706 }707 return totalOptions;708};709const organizeStaticPrefilterMDMData = (response) => {710 const setOfCodeNames = {};711 // creates an array based on the property name of the mdm coming in712 for (const codeName in response[0]) {713 setOfCodeNames[codeName] = [];714 }...
test.ts
Source:test.ts
...31import { resetDefaultOptions } from '../_lib/test'32describe('setDefaultOptions', () => {33 afterEach(resetDefaultOptions)34 it('changes the internal `defaultOptions` object', () => {35 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4, locale: eo })36 assert.deepStrictEqual(getInternalDefaultOptions(), {37 weekStartsOn: 1,38 firstWeekContainsDate: 4,39 locale: eo,40 })41 })42 it('merges with previous `defaultOptions` calls', () => {43 setDefaultOptions({ weekStartsOn: 1 })44 setDefaultOptions({ firstWeekContainsDate: 4 })45 setDefaultOptions({ locale: eo })46 assert.deepStrictEqual(getInternalDefaultOptions(), {47 weekStartsOn: 1,48 firstWeekContainsDate: 4,49 locale: eo,50 })51 })52 it('setting an option to `undefined` deletes it', () => {53 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })54 setDefaultOptions({ weekStartsOn: undefined })55 assert.deepStrictEqual(getInternalDefaultOptions(), {56 firstWeekContainsDate: 4,57 })58 })59 it('does not mutate the argument', () => {60 const argument: DefaultOptions = { weekStartsOn: 1 }61 setDefaultOptions(argument)62 assert.deepStrictEqual(argument, { weekStartsOn: 1 })63 })64 describe('locale', () => {65 it('format', () => {66 // For reference: not setting any options67 assert.deepStrictEqual(68 format(new Date(2014, 0, 1), 'PPPpp'),69 'January 1st, 2014 at 12:00:00 AM'70 )71 setDefaultOptions({ locale: eo })72 assert.deepStrictEqual(73 format(new Date(2014, 0, 1), 'PPPpp'),74 '2014-januaro-01 00:00:00'75 )76 // Manually set `locale` take priority over `defaultOptions.locale`77 assert.deepStrictEqual(78 format(new Date(2014, 0, 1), 'PPPpp', { locale: enUS }),79 'January 1st, 2014 at 12:00:00 AM'80 )81 })82 it('formatDistance', () => {83 // For reference: not setting any options84 assert.deepStrictEqual(85 formatDistance(new Date(2014, 0, 1), new Date(2015, 0, 1)),86 'about 1 year'87 )88 setDefaultOptions({ locale: eo })89 assert.deepStrictEqual(90 formatDistance(new Date(2014, 0, 1), new Date(2015, 0, 1)),91 'proksimume 1 jaro'92 )93 // Manually set `locale` take priority over `defaultOptions.locale`94 assert.deepStrictEqual(95 formatDistance(new Date(2014, 0, 1), new Date(2015, 0, 1), {96 locale: enUS,97 }),98 'about 1 year'99 )100 })101 it('formatDistanceStrict', () => {102 // For reference: not setting any options103 assert.deepStrictEqual(104 formatDistanceStrict(new Date(2014, 0, 1), new Date(2015, 0, 1)),105 '1 year'106 )107 setDefaultOptions({ locale: eo })108 assert.deepStrictEqual(109 formatDistanceStrict(new Date(2014, 0, 1), new Date(2015, 0, 1)),110 '1 jaro'111 )112 // Manually set `locale` take priority over `defaultOptions.locale`113 assert.deepStrictEqual(114 formatDistanceStrict(new Date(2014, 0, 1), new Date(2015, 0, 1), {115 locale: enUS,116 }),117 '1 year'118 )119 })120 it('formatDuration', () => {121 // For reference: not setting any options122 assert.deepStrictEqual(formatDuration({ years: 1 }), '1 year')123 setDefaultOptions({ locale: eo })124 assert.deepStrictEqual(formatDuration({ years: 1 }), '1 jaro')125 // Manually set `locale` take priority over `defaultOptions.locale`126 assert.deepStrictEqual(127 formatDuration({ years: 1 }, { locale: enUS }),128 '1 year'129 )130 })131 it('formatRelative', () => {132 // For reference: not setting any options133 assert.deepStrictEqual(134 formatRelative(new Date(2014, 0, 1), new Date(2014, 0, 2)),135 'yesterday at 12:00 AM'136 )137 setDefaultOptions({ locale: eo })138 assert.deepStrictEqual(139 formatRelative(new Date(2014, 0, 1), new Date(2014, 0, 2)),140 'hieraÅ je 00:00'141 )142 // Manually set `locale` take priority over `defaultOptions.locale`143 assert.deepStrictEqual(144 formatRelative(new Date(2014, 0, 1), new Date(2014, 0, 2), {145 locale: enUS,146 }),147 'yesterday at 12:00 AM'148 )149 })150 it('isMatch', () => {151 // For reference: not setting any options152 assert(isMatch('January 1st, 2014 at 12:00:00 AM', 'PPPpp'))153 setDefaultOptions({ locale: eo })154 assert(isMatch('2014-januaro-01 00:00:00', 'PPPpp'))155 // Manually set `locale` take priority over `defaultOptions.locale`156 assert(157 isMatch('January 1st, 2014 at 12:00:00 AM', 'PPPpp', { locale: enUS })158 )159 })160 it('parse', () => {161 // For reference: not setting any options162 assert.deepStrictEqual(163 parse('January 1st, 2014 at 12:00:00 AM', 'PPPpp', new Date()),164 new Date(2014, 0, 1)165 )166 setDefaultOptions({ locale: eo })167 assert.deepStrictEqual(168 parse('2014-januaro-01 00:00:00', 'PPPpp', new Date()),169 new Date(2014, 0, 1)170 )171 // Manually set `locale` take priority over `defaultOptions.locale`172 assert.deepStrictEqual(173 parse('January 1st, 2014 at 12:00:00 AM', 'PPPpp', new Date(), {174 locale: enUS,175 }),176 new Date(2014, 0, 1)177 )178 })179 })180 describe('weekStartsOn', () => {181 it('differenceInCalendarWeeks', () => {182 // For reference: not setting any options183 assert.strictEqual(184 differenceInCalendarWeeks(185 new Date(2014, 6 /* Jul */, 8, 18, 0),186 new Date(2014, 5 /* Jun */, 29, 6, 0)187 ),188 1189 )190 setDefaultOptions({ weekStartsOn: 1 })191 assert.strictEqual(192 differenceInCalendarWeeks(193 new Date(2014, 6 /* Jul */, 8, 18, 0),194 new Date(2014, 5 /* Jun */, 29, 6, 0)195 ),196 2197 )198 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`199 assert.strictEqual(200 differenceInCalendarWeeks(201 new Date(2014, 6 /* Jul */, 8, 18, 0),202 new Date(2014, 5 /* Jun */, 29, 6, 0),203 {204 weekStartsOn: 0,205 }206 ),207 1208 )209 })210 it('eachWeekOfInterval', () => {211 // For reference: not setting any options212 assert.deepStrictEqual(213 eachWeekOfInterval({214 start: new Date(2014, 9 /* Oct */, 6),215 end: new Date(2014, 10 /* Nov */, 23),216 }),217 [218 new Date(2014, 9 /* Oct */, 5),219 new Date(2014, 9 /* Oct */, 12),220 new Date(2014, 9 /* Oct */, 19),221 new Date(2014, 9 /* Oct */, 26),222 new Date(2014, 10 /* Nov */, 2),223 new Date(2014, 10 /* Nov */, 9),224 new Date(2014, 10 /* Nov */, 16),225 new Date(2014, 10 /* Nov */, 23),226 ]227 )228 setDefaultOptions({ weekStartsOn: 1 })229 assert.deepStrictEqual(230 eachWeekOfInterval({231 start: new Date(2014, 9 /* Oct */, 6, 6, 35),232 end: new Date(2014, 10 /* Nov */, 25, 22, 15),233 }),234 [235 new Date(2014, 9 /* Oct */, 6),236 new Date(2014, 9 /* Oct */, 13),237 new Date(2014, 9 /* Oct */, 20),238 new Date(2014, 9 /* Oct */, 27),239 new Date(2014, 10 /* Nov */, 3),240 new Date(2014, 10 /* Nov */, 10),241 new Date(2014, 10 /* Nov */, 17),242 new Date(2014, 10 /* Nov */, 24),243 ]244 )245 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`246 assert.deepStrictEqual(247 eachWeekOfInterval(248 {249 start: new Date(2014, 9 /* Oct */, 6),250 end: new Date(2014, 10 /* Nov */, 23),251 },252 {253 weekStartsOn: 0,254 }255 ),256 [257 new Date(2014, 9 /* Oct */, 5),258 new Date(2014, 9 /* Oct */, 12),259 new Date(2014, 9 /* Oct */, 19),260 new Date(2014, 9 /* Oct */, 26),261 new Date(2014, 10 /* Nov */, 2),262 new Date(2014, 10 /* Nov */, 9),263 new Date(2014, 10 /* Nov */, 16),264 new Date(2014, 10 /* Nov */, 23),265 ]266 )267 })268 it('endOfWeek', () => {269 // For reference: not setting any options270 assert.deepStrictEqual(271 endOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),272 new Date(2014, 8 /* Sep */, 6, 23, 59, 59, 999)273 )274 setDefaultOptions({ weekStartsOn: 1 })275 assert.deepStrictEqual(276 endOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),277 new Date(2014, 8 /* Sep */, 7, 23, 59, 59, 999)278 )279 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`280 assert.deepStrictEqual(281 endOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {282 weekStartsOn: 0,283 }),284 new Date(2014, 8 /* Sep */, 6, 23, 59, 59, 999)285 )286 })287 it('getWeekOfMonth', () => {288 // For reference: not setting any options289 assert.strictEqual(getWeekOfMonth(new Date(2017, 10 /* Nov */, 15)), 3)290 setDefaultOptions({ weekStartsOn: 1 })291 assert.strictEqual(getWeekOfMonth(new Date(2017, 9 /* Oct */, 31)), 6)292 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`293 assert.strictEqual(294 getWeekOfMonth(new Date(2017, 10 /* Nov */, 15), {295 weekStartsOn: 0,296 }),297 3298 )299 })300 it('getWeeksInMonth', () => {301 // For reference: not setting any options302 assert.strictEqual(303 getWeeksInMonth(new Date(2015, 1 /* Feb */, 8, 18, 0)),304 4305 )306 setDefaultOptions({ weekStartsOn: 1 })307 assert.strictEqual(308 getWeeksInMonth(new Date(2015, 1 /* Feb */, 8, 18, 0)),309 5310 )311 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`312 assert.strictEqual(313 getWeeksInMonth(new Date(2015, 1 /* Feb */, 8, 18, 0), {314 weekStartsOn: 0,315 }),316 4317 )318 })319 it('isSameWeek', () => {320 // For reference: not setting any options321 assert.strictEqual(322 isSameWeek(323 new Date(2014, 7 /* Aug */, 31),324 new Date(2014, 8 /* Sep */, 4)325 ),326 true327 )328 setDefaultOptions({ weekStartsOn: 1 })329 assert.strictEqual(330 isSameWeek(331 new Date(2014, 7 /* Aug */, 31),332 new Date(2014, 8 /* Sep */, 4)333 ),334 false335 )336 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`337 assert.strictEqual(338 isSameWeek(339 new Date(2014, 7 /* Aug */, 31),340 new Date(2014, 8 /* Sep */, 4),341 {342 weekStartsOn: 0,343 }344 ),345 true346 )347 })348 it('lastDayOfWeek', () => {349 // For reference: not setting any options350 assert.deepStrictEqual(351 lastDayOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),352 new Date(2014, 8 /* Sep */, 6)353 )354 setDefaultOptions({ weekStartsOn: 1 })355 assert.deepStrictEqual(356 lastDayOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),357 new Date(2014, 8 /* Sep */, 7)358 )359 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`360 assert.deepStrictEqual(361 lastDayOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {362 weekStartsOn: 0,363 }),364 new Date(2014, 8 /* Sep */, 6)365 )366 })367 it('setDay', () => {368 // For reference: not setting any options369 assert.deepStrictEqual(370 setDay(new Date(2014, 8 /* Sep */, 1), 0),371 new Date(2014, 7 /* Aug */, 31)372 )373 setDefaultOptions({ weekStartsOn: 1 })374 assert.deepStrictEqual(375 setDay(new Date(2014, 8 /* Sep */, 1), 0),376 new Date(2014, 8 /* Sep */, 7)377 )378 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`379 assert.deepStrictEqual(380 setDay(new Date(2014, 8 /* Sep */, 1), 0, {381 weekStartsOn: 0,382 }),383 new Date(2014, 7 /* Aug */, 31)384 )385 })386 it('startOfWeek', () => {387 // For reference: not setting any options388 assert.deepStrictEqual(389 startOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),390 new Date(2014, 7 /* Aug */, 31)391 )392 setDefaultOptions({ weekStartsOn: 1 })393 assert.deepStrictEqual(394 startOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0)),395 new Date(2014, 8 /* Sep */, 1)396 )397 // Manually set `weekStartsOn` take priority over `defaultOptions.weekStartsOn`398 assert.deepStrictEqual(399 startOfWeek(new Date(2014, 8 /* Sep */, 2, 11, 55, 0), {400 weekStartsOn: 0,401 }),402 new Date(2014, 7 /* Aug */, 31)403 )404 })405 })406 describe('firstWeekContainsDate', () => {407 it('format', () => {408 // For reference: not setting any options409 assert.strictEqual(410 format(new Date(1986, 3 /* Apr */, 6), 'w wo ww'),411 '15 15th 15'412 )413 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })414 assert.strictEqual(415 format(new Date(1986, 3 /* Apr */, 6), 'w wo ww'),416 '14 14th 14'417 )418 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`419 assert.strictEqual(420 format(new Date(1986, 3 /* Apr */, 6), 'w wo ww', {421 weekStartsOn: 0,422 firstWeekContainsDate: 1,423 }),424 '15 15th 15'425 )426 })427 it('getWeek', () => {428 // For reference: not setting any options429 assert.strictEqual(getWeek(new Date(2005, 0 /* Jan */, 2)), 2)430 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })431 assert.strictEqual(getWeek(new Date(2005, 0 /* Jan */, 2)), 53)432 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`433 assert.strictEqual(434 getWeek(new Date(2005, 0 /* Jan */, 2), {435 weekStartsOn: 0,436 firstWeekContainsDate: 1,437 }),438 2439 )440 })441 it('getWeekYear', () => {442 // For reference: not setting any options443 assert.strictEqual(getWeekYear(new Date(2004, 11 /* Dec */, 26)), 2005)444 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })445 assert.strictEqual(getWeekYear(new Date(2004, 11 /* Dec */, 26)), 2004)446 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`447 assert.strictEqual(448 getWeekYear(new Date(2004, 11 /* Dec */, 26), {449 weekStartsOn: 0,450 firstWeekContainsDate: 1,451 }),452 2005453 )454 })455 it('parse', () => {456 const referenceDate = new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 900)457 // For reference: not setting any options458 assert.deepStrictEqual(459 parse('2018', 'Y', referenceDate),460 new Date(2017, 11 /* Dec */, 31)461 )462 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })463 assert.deepStrictEqual(464 parse('2018', 'Y', referenceDate),465 new Date(2018, 0 /* Jan */, 1)466 )467 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`468 assert.deepStrictEqual(469 parse('2018', 'Y', referenceDate, {470 weekStartsOn: 0,471 firstWeekContainsDate: 1,472 }),473 new Date(2017, 11 /* Dec */, 31)474 )475 })476 it('setWeek', () => {477 // For reference: not setting any options478 assert.deepStrictEqual(479 setWeek(new Date(2005, 0 /* Jan */, 2), 1),480 new Date(2004, 11 /* Dec */, 26)481 )482 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })483 assert.deepStrictEqual(484 setWeek(new Date(2005, 0 /* Jan */, 2), 1),485 new Date(2004, 0 /* Jan */, 4)486 )487 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`488 assert.deepStrictEqual(489 setWeek(new Date(2005, 0 /* Jan */, 2), 1, {490 weekStartsOn: 0,491 firstWeekContainsDate: 1,492 }),493 new Date(2004, 11 /* Dec */, 26)494 )495 })496 it('setWeekYear', () => {497 // For reference: not setting any options498 assert.deepStrictEqual(499 setWeekYear(new Date(2010, 0 /* Jan */, 2), 2004),500 new Date(2004, 0 /* Jan */, 3)501 )502 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })503 assert.deepStrictEqual(504 setWeekYear(new Date(2010, 0 /* Jan */, 2), 2004),505 new Date(2005, 0 /* Jan */, 1)506 )507 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`508 assert.deepStrictEqual(509 setWeekYear(new Date(2010, 0 /* Jan */, 2), 2004, {510 weekStartsOn: 0,511 firstWeekContainsDate: 1,512 }),513 new Date(2004, 0 /* Jan */, 3)514 )515 })516 it('startOfWeekYear', () => {517 // For reference: not setting any options518 assert.deepStrictEqual(519 startOfWeekYear(new Date(2005, 6 /* Jul */, 2)),520 new Date(2004, 11 /* Dec */, 26, 0, 0, 0, 0)521 )522 setDefaultOptions({ weekStartsOn: 1, firstWeekContainsDate: 4 })523 assert.deepStrictEqual(524 startOfWeekYear(new Date(2005, 6 /* Jul */, 2)),525 new Date(2005, 0 /* Jan */, 3, 0, 0, 0, 0)526 )527 // Manually set `firstWeekContainsDate` take priority over `defaultOptions.firstWeekContainsDate`528 assert.deepStrictEqual(529 startOfWeekYear(new Date(2005, 6 /* Jul */, 2), {530 weekStartsOn: 0,531 firstWeekContainsDate: 1,532 }),533 new Date(2004, 11 /* Dec */, 26, 0, 0, 0, 0)534 )535 })536 })...
options_spec.js
Source:options_spec.js
2import assert from 'assert'3import { setDefaultOptions } from './../index.js'4describe('setDefaultOptions', () => {5 it('sets default static option', () => {6 var options = setDefaultOptions({}, [ 'var1', 'var2' ])7 assert.equal(options.mapType, 'pindrop')8 })9 it('sets existing static option', () => {10 var options = setDefaultOptions({ mapType: 'heatmap' }, [ 'var1', 'var2' ])11 assert.equal(options.mapType, 'heatmap')12 })13 it('resets existing static option if not in the list of static options', () => {14 var options = setDefaultOptions({ mapType: 'heatmapzz' }, [ 'var1', 'var2' ])15 assert.equal(options.mapType, 'pindrop')16 })17 it('sets default variable option', () => {18 var options = setDefaultOptions({}, [ 'var1', 'var2' ])19 assert.equal(options.mainVariable, 'var1')20 })21 it('sets multiple default variable option', () => {22 var options = setDefaultOptions({}, [ 'var1', 'var2' ])23 assert.deepEqual(options.filterVariables, [])24 })...
Using AI Code Generation
1const { setDefaultOptions } = require('stryker-parent');2setDefaultOptions({3 mutatorOptions: {4 }5});6module.exports = function(config) {7 config.set({8 mutatorOptions: {9 }10 });11};
Using AI Code Generation
1const stryker = require('stryker-parent');2const stryker = require('stryker-parent');3stryker.setDefaultOptions({4 mochaOptions: {5 }6});7const stryker = require('stryker-parent');8const stryker = require('stryker-parent');9stryker.setDefaultOptions({10 mochaOptions: {11 }12});13const stryker = require('stryker-parent');14const stryker = require('stryker-parent');15stryker.setDefaultOptions({16 mochaOptions: {17 }18});19const stryker = require('stryker-parent');20const stryker = require('stryker-parent');21stryker.setDefaultOptions({22 mochaOptions: {
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.setDefaultOptions({ test: 'test' });3module.exports = function(config) {4 config.set({5 });6};7module.exports = function(config) {8 config.set({9 });10};11module.exports = function(config) {12 config.set({13 });14};15module.exports = function(config) {16 config.set({17 });18};19module.exports = function(config) {20 config.set({21 });22};23module.exports = function(config) {24 config.set({25 });26};27module.exports = function(config) {28 config.set({29 });30};31module.exports = function(config) {32 config.set({33 });34};35module.exports = function(config) {36 config.set({37 });38};39module.exports = function(config) {40 config.set({41 });42};43module.exports = function(config) {44 config.set({45 });46};47module.exports = function(config) {48 config.set({49 });50};
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!!