How to use assertions method in Sure

Best Python code snippet using sure_python

chai-enzyme_vx.x.x.js

Source:chai-enzyme_vx.x.x.js Github

copy

Full Screen

1// flow-typed signature: 59afcc8c3d371521197a9a9e46da9d7a2// flow-typed version: <<STUB>>/chai-enzyme_v1.0.0-beta.1/flow_v0.76.03/**4 * This is an autogenerated libdef stub for:5 *6 * 'chai-enzyme'7 *8 * Fill this stub out by replacing all the `any` types.9 *10 * Once filled out, we encourage you to share your work with the11 * community by sending a pull request to:12 * https://github.com/flowtype/flow-typed13 */14declare module 'chai-enzyme' {15 declare module.exports: any;16}17/**18 * We include stubs for each file inside this npm package in case you need to19 * require those files directly. Feel free to delete any files that aren't20 * needed.21 */22declare module 'chai-enzyme/build/assertions/checked' {23 declare module.exports: any;24}25declare module 'chai-enzyme/build/assertions/className' {26 declare module.exports: any;27}28declare module 'chai-enzyme/build/assertions/contain' {29 declare module.exports: any;30}31declare module 'chai-enzyme/build/assertions/containMatchingElement' {32 declare module.exports: any;33}34declare module 'chai-enzyme/build/assertions/descendants' {35 declare module.exports: any;36}37declare module 'chai-enzyme/build/assertions/disabled' {38 declare module.exports: any;39}40declare module 'chai-enzyme/build/assertions/empty' {41 declare module.exports: any;42}43declare module 'chai-enzyme/build/assertions/exist' {44 declare module.exports: any;45}46declare module 'chai-enzyme/build/assertions/generic' {47 declare module.exports: any;48}49declare module 'chai-enzyme/build/assertions/html' {50 declare module.exports: any;51}52declare module 'chai-enzyme/build/assertions/id' {53 declare module.exports: any;54}55declare module 'chai-enzyme/build/assertions/match' {56 declare module.exports: any;57}58declare module 'chai-enzyme/build/assertions/props' {59 declare module.exports: any;60}61declare module 'chai-enzyme/build/assertions/ref' {62 declare module.exports: any;63}64declare module 'chai-enzyme/build/assertions/selected' {65 declare module.exports: any;66}67declare module 'chai-enzyme/build/assertions/tagName' {68 declare module.exports: any;69}70declare module 'chai-enzyme/build/assertions/text' {71 declare module.exports: any;72}73declare module 'chai-enzyme/build/assertions/type' {74 declare module.exports: any;75}76declare module 'chai-enzyme/build/assertions/value' {77 declare module.exports: any;78}79declare module 'chai-enzyme/build/chains/exactly' {80 declare module.exports: any;81}82declare module 'chai-enzyme/build/ChaiWrapper' {83 declare module.exports: any;84}85declare module 'chai-enzyme/build/CheerioTestWrapper' {86 declare module.exports: any;87}88declare module 'chai-enzyme/build/debug' {89 declare module.exports: any;90}91declare module 'chai-enzyme/build/index' {92 declare module.exports: any;93}94declare module 'chai-enzyme/build/reactNodeToString' {95 declare module.exports: any;96}97declare module 'chai-enzyme/build/ReactTestWrapper' {98 declare module.exports: any;99}100declare module 'chai-enzyme/build/ShallowTestWrapper' {101 declare module.exports: any;102}103declare module 'chai-enzyme/build/TestWrapper' {104 declare module.exports: any;105}106declare module 'chai-enzyme/build/wrap' {107 declare module.exports: any;108}109declare module 'chai-enzyme/src/assertions/checked' {110 declare module.exports: any;111}112declare module 'chai-enzyme/src/assertions/className' {113 declare module.exports: any;114}115declare module 'chai-enzyme/src/assertions/contain' {116 declare module.exports: any;117}118declare module 'chai-enzyme/src/assertions/containMatchingElement' {119 declare module.exports: any;120}121declare module 'chai-enzyme/src/assertions/descendants' {122 declare module.exports: any;123}124declare module 'chai-enzyme/src/assertions/disabled' {125 declare module.exports: any;126}127declare module 'chai-enzyme/src/assertions/empty' {128 declare module.exports: any;129}130declare module 'chai-enzyme/src/assertions/exist' {131 declare module.exports: any;132}133declare module 'chai-enzyme/src/assertions/generic' {134 declare module.exports: any;135}136declare module 'chai-enzyme/src/assertions/html' {137 declare module.exports: any;138}139declare module 'chai-enzyme/src/assertions/id' {140 declare module.exports: any;141}142declare module 'chai-enzyme/src/assertions/match' {143 declare module.exports: any;144}145declare module 'chai-enzyme/src/assertions/props' {146 declare module.exports: any;147}148declare module 'chai-enzyme/src/assertions/ref' {149 declare module.exports: any;150}151declare module 'chai-enzyme/src/assertions/selected' {152 declare module.exports: any;153}154declare module 'chai-enzyme/src/assertions/tagName' {155 declare module.exports: any;156}157declare module 'chai-enzyme/src/assertions/text' {158 declare module.exports: any;159}160declare module 'chai-enzyme/src/assertions/type' {161 declare module.exports: any;162}163declare module 'chai-enzyme/src/assertions/value' {164 declare module.exports: any;165}166declare module 'chai-enzyme/src/chains/exactly' {167 declare module.exports: any;168}169declare module 'chai-enzyme/src/ChaiWrapper' {170 declare module.exports: any;171}172declare module 'chai-enzyme/src/CheerioTestWrapper' {173 declare module.exports: any;174}175declare module 'chai-enzyme/src/debug' {176 declare module.exports: any;177}178declare module 'chai-enzyme/src/index' {179 declare module.exports: any;180}181declare module 'chai-enzyme/src/reactNodeToString' {182 declare module.exports: any;183}184declare module 'chai-enzyme/src/ReactTestWrapper' {185 declare module.exports: any;186}187declare module 'chai-enzyme/src/ShallowTestWrapper' {188 declare module.exports: any;189}190declare module 'chai-enzyme/src/TestWrapper' {191 declare module.exports: any;192}193declare module 'chai-enzyme/src/wrap' {194 declare module.exports: any;195}196declare module 'chai-enzyme/test/attr.test' {197 declare module.exports: any;198}199declare module 'chai-enzyme/test/blank.test' {200 declare module.exports: any;201}202declare module 'chai-enzyme/test/checked.test' {203 declare module.exports: any;204}205declare module 'chai-enzyme/test/className.test' {206 declare module.exports: any;207}208declare module 'chai-enzyme/test/contain.test' {209 declare module.exports: any;210}211declare module 'chai-enzyme/test/containMatchingElement.test' {212 declare module.exports: any;213}214declare module 'chai-enzyme/test/data.test' {215 declare module.exports: any;216}217declare module 'chai-enzyme/test/descendants.test' {218 declare module.exports: any;219}220declare module 'chai-enzyme/test/disabled.test' {221 declare module.exports: any;222}223declare module 'chai-enzyme/test/empty.test' {224 declare module.exports: any;225}226declare module 'chai-enzyme/test/exactly.test' {227 declare module.exports: any;228}229declare module 'chai-enzyme/test/exist.test' {230 declare module.exports: any;231}232declare module 'chai-enzyme/test/html.test' {233 declare module.exports: any;234}235declare module 'chai-enzyme/test/id.test' {236 declare module.exports: any;237}238declare module 'chai-enzyme/test/inspect.test' {239 declare module.exports: any;240}241declare module 'chai-enzyme/test/match.test' {242 declare module.exports: any;243}244declare module 'chai-enzyme/test/null.test' {245 declare module.exports: any;246}247declare module 'chai-enzyme/test/present.test' {248 declare module.exports: any;249}250declare module 'chai-enzyme/test/prop.test' {251 declare module.exports: any;252}253declare module 'chai-enzyme/test/props.test' {254 declare module.exports: any;255}256declare module 'chai-enzyme/test/ref.test' {257 declare module.exports: any;258}259declare module 'chai-enzyme/test/selected.test' {260 declare module.exports: any;261}262declare module 'chai-enzyme/test/state.test' {263 declare module.exports: any;264}265declare module 'chai-enzyme/test/style.test' {266 declare module.exports: any;267}268declare module 'chai-enzyme/test/support/createTest' {269 declare module.exports: any;270}271declare module 'chai-enzyme/test/support/helper' {272 declare module.exports: any;273}274declare module 'chai-enzyme/test/tagName.test' {275 declare module.exports: any;276}277declare module 'chai-enzyme/test/text.test' {278 declare module.exports: any;279}280declare module 'chai-enzyme/test/type.test' {281 declare module.exports: any;282}283declare module 'chai-enzyme/test/value.test' {284 declare module.exports: any;285}286// Filename aliases287declare module 'chai-enzyme/build/assertions/checked.js' {288 declare module.exports: $Exports<'chai-enzyme/build/assertions/checked'>;289}290declare module 'chai-enzyme/build/assertions/className.js' {291 declare module.exports: $Exports<'chai-enzyme/build/assertions/className'>;292}293declare module 'chai-enzyme/build/assertions/contain.js' {294 declare module.exports: $Exports<'chai-enzyme/build/assertions/contain'>;295}296declare module 'chai-enzyme/build/assertions/containMatchingElement.js' {297 declare module.exports: $Exports<'chai-enzyme/build/assertions/containMatchingElement'>;298}299declare module 'chai-enzyme/build/assertions/descendants.js' {300 declare module.exports: $Exports<'chai-enzyme/build/assertions/descendants'>;301}302declare module 'chai-enzyme/build/assertions/disabled.js' {303 declare module.exports: $Exports<'chai-enzyme/build/assertions/disabled'>;304}305declare module 'chai-enzyme/build/assertions/empty.js' {306 declare module.exports: $Exports<'chai-enzyme/build/assertions/empty'>;307}308declare module 'chai-enzyme/build/assertions/exist.js' {309 declare module.exports: $Exports<'chai-enzyme/build/assertions/exist'>;310}311declare module 'chai-enzyme/build/assertions/generic.js' {312 declare module.exports: $Exports<'chai-enzyme/build/assertions/generic'>;313}314declare module 'chai-enzyme/build/assertions/html.js' {315 declare module.exports: $Exports<'chai-enzyme/build/assertions/html'>;316}317declare module 'chai-enzyme/build/assertions/id.js' {318 declare module.exports: $Exports<'chai-enzyme/build/assertions/id'>;319}320declare module 'chai-enzyme/build/assertions/match.js' {321 declare module.exports: $Exports<'chai-enzyme/build/assertions/match'>;322}323declare module 'chai-enzyme/build/assertions/props.js' {324 declare module.exports: $Exports<'chai-enzyme/build/assertions/props'>;325}326declare module 'chai-enzyme/build/assertions/ref.js' {327 declare module.exports: $Exports<'chai-enzyme/build/assertions/ref'>;328}329declare module 'chai-enzyme/build/assertions/selected.js' {330 declare module.exports: $Exports<'chai-enzyme/build/assertions/selected'>;331}332declare module 'chai-enzyme/build/assertions/tagName.js' {333 declare module.exports: $Exports<'chai-enzyme/build/assertions/tagName'>;334}335declare module 'chai-enzyme/build/assertions/text.js' {336 declare module.exports: $Exports<'chai-enzyme/build/assertions/text'>;337}338declare module 'chai-enzyme/build/assertions/type.js' {339 declare module.exports: $Exports<'chai-enzyme/build/assertions/type'>;340}341declare module 'chai-enzyme/build/assertions/value.js' {342 declare module.exports: $Exports<'chai-enzyme/build/assertions/value'>;343}344declare module 'chai-enzyme/build/chains/exactly.js' {345 declare module.exports: $Exports<'chai-enzyme/build/chains/exactly'>;346}347declare module 'chai-enzyme/build/ChaiWrapper.js' {348 declare module.exports: $Exports<'chai-enzyme/build/ChaiWrapper'>;349}350declare module 'chai-enzyme/build/CheerioTestWrapper.js' {351 declare module.exports: $Exports<'chai-enzyme/build/CheerioTestWrapper'>;352}353declare module 'chai-enzyme/build/debug.js' {354 declare module.exports: $Exports<'chai-enzyme/build/debug'>;355}356declare module 'chai-enzyme/build/index.js' {357 declare module.exports: $Exports<'chai-enzyme/build/index'>;358}359declare module 'chai-enzyme/build/reactNodeToString.js' {360 declare module.exports: $Exports<'chai-enzyme/build/reactNodeToString'>;361}362declare module 'chai-enzyme/build/ReactTestWrapper.js' {363 declare module.exports: $Exports<'chai-enzyme/build/ReactTestWrapper'>;364}365declare module 'chai-enzyme/build/ShallowTestWrapper.js' {366 declare module.exports: $Exports<'chai-enzyme/build/ShallowTestWrapper'>;367}368declare module 'chai-enzyme/build/TestWrapper.js' {369 declare module.exports: $Exports<'chai-enzyme/build/TestWrapper'>;370}371declare module 'chai-enzyme/build/wrap.js' {372 declare module.exports: $Exports<'chai-enzyme/build/wrap'>;373}374declare module 'chai-enzyme/src/assertions/checked.js' {375 declare module.exports: $Exports<'chai-enzyme/src/assertions/checked'>;376}377declare module 'chai-enzyme/src/assertions/className.js' {378 declare module.exports: $Exports<'chai-enzyme/src/assertions/className'>;379}380declare module 'chai-enzyme/src/assertions/contain.js' {381 declare module.exports: $Exports<'chai-enzyme/src/assertions/contain'>;382}383declare module 'chai-enzyme/src/assertions/containMatchingElement.js' {384 declare module.exports: $Exports<'chai-enzyme/src/assertions/containMatchingElement'>;385}386declare module 'chai-enzyme/src/assertions/descendants.js' {387 declare module.exports: $Exports<'chai-enzyme/src/assertions/descendants'>;388}389declare module 'chai-enzyme/src/assertions/disabled.js' {390 declare module.exports: $Exports<'chai-enzyme/src/assertions/disabled'>;391}392declare module 'chai-enzyme/src/assertions/empty.js' {393 declare module.exports: $Exports<'chai-enzyme/src/assertions/empty'>;394}395declare module 'chai-enzyme/src/assertions/exist.js' {396 declare module.exports: $Exports<'chai-enzyme/src/assertions/exist'>;397}398declare module 'chai-enzyme/src/assertions/generic.js' {399 declare module.exports: $Exports<'chai-enzyme/src/assertions/generic'>;400}401declare module 'chai-enzyme/src/assertions/html.js' {402 declare module.exports: $Exports<'chai-enzyme/src/assertions/html'>;403}404declare module 'chai-enzyme/src/assertions/id.js' {405 declare module.exports: $Exports<'chai-enzyme/src/assertions/id'>;406}407declare module 'chai-enzyme/src/assertions/match.js' {408 declare module.exports: $Exports<'chai-enzyme/src/assertions/match'>;409}410declare module 'chai-enzyme/src/assertions/props.js' {411 declare module.exports: $Exports<'chai-enzyme/src/assertions/props'>;412}413declare module 'chai-enzyme/src/assertions/ref.js' {414 declare module.exports: $Exports<'chai-enzyme/src/assertions/ref'>;415}416declare module 'chai-enzyme/src/assertions/selected.js' {417 declare module.exports: $Exports<'chai-enzyme/src/assertions/selected'>;418}419declare module 'chai-enzyme/src/assertions/tagName.js' {420 declare module.exports: $Exports<'chai-enzyme/src/assertions/tagName'>;421}422declare module 'chai-enzyme/src/assertions/text.js' {423 declare module.exports: $Exports<'chai-enzyme/src/assertions/text'>;424}425declare module 'chai-enzyme/src/assertions/type.js' {426 declare module.exports: $Exports<'chai-enzyme/src/assertions/type'>;427}428declare module 'chai-enzyme/src/assertions/value.js' {429 declare module.exports: $Exports<'chai-enzyme/src/assertions/value'>;430}431declare module 'chai-enzyme/src/chains/exactly.js' {432 declare module.exports: $Exports<'chai-enzyme/src/chains/exactly'>;433}434declare module 'chai-enzyme/src/ChaiWrapper.js' {435 declare module.exports: $Exports<'chai-enzyme/src/ChaiWrapper'>;436}437declare module 'chai-enzyme/src/CheerioTestWrapper.js' {438 declare module.exports: $Exports<'chai-enzyme/src/CheerioTestWrapper'>;439}440declare module 'chai-enzyme/src/debug.js' {441 declare module.exports: $Exports<'chai-enzyme/src/debug'>;442}443declare module 'chai-enzyme/src/index.js' {444 declare module.exports: $Exports<'chai-enzyme/src/index'>;445}446declare module 'chai-enzyme/src/reactNodeToString.js' {447 declare module.exports: $Exports<'chai-enzyme/src/reactNodeToString'>;448}449declare module 'chai-enzyme/src/ReactTestWrapper.js' {450 declare module.exports: $Exports<'chai-enzyme/src/ReactTestWrapper'>;451}452declare module 'chai-enzyme/src/ShallowTestWrapper.js' {453 declare module.exports: $Exports<'chai-enzyme/src/ShallowTestWrapper'>;454}455declare module 'chai-enzyme/src/TestWrapper.js' {456 declare module.exports: $Exports<'chai-enzyme/src/TestWrapper'>;457}458declare module 'chai-enzyme/src/wrap.js' {459 declare module.exports: $Exports<'chai-enzyme/src/wrap'>;460}461declare module 'chai-enzyme/test/attr.test.js' {462 declare module.exports: $Exports<'chai-enzyme/test/attr.test'>;463}464declare module 'chai-enzyme/test/blank.test.js' {465 declare module.exports: $Exports<'chai-enzyme/test/blank.test'>;466}467declare module 'chai-enzyme/test/checked.test.js' {468 declare module.exports: $Exports<'chai-enzyme/test/checked.test'>;469}470declare module 'chai-enzyme/test/className.test.js' {471 declare module.exports: $Exports<'chai-enzyme/test/className.test'>;472}473declare module 'chai-enzyme/test/contain.test.js' {474 declare module.exports: $Exports<'chai-enzyme/test/contain.test'>;475}476declare module 'chai-enzyme/test/containMatchingElement.test.js' {477 declare module.exports: $Exports<'chai-enzyme/test/containMatchingElement.test'>;478}479declare module 'chai-enzyme/test/data.test.js' {480 declare module.exports: $Exports<'chai-enzyme/test/data.test'>;481}482declare module 'chai-enzyme/test/descendants.test.js' {483 declare module.exports: $Exports<'chai-enzyme/test/descendants.test'>;484}485declare module 'chai-enzyme/test/disabled.test.js' {486 declare module.exports: $Exports<'chai-enzyme/test/disabled.test'>;487}488declare module 'chai-enzyme/test/empty.test.js' {489 declare module.exports: $Exports<'chai-enzyme/test/empty.test'>;490}491declare module 'chai-enzyme/test/exactly.test.js' {492 declare module.exports: $Exports<'chai-enzyme/test/exactly.test'>;493}494declare module 'chai-enzyme/test/exist.test.js' {495 declare module.exports: $Exports<'chai-enzyme/test/exist.test'>;496}497declare module 'chai-enzyme/test/html.test.js' {498 declare module.exports: $Exports<'chai-enzyme/test/html.test'>;499}500declare module 'chai-enzyme/test/id.test.js' {501 declare module.exports: $Exports<'chai-enzyme/test/id.test'>;502}503declare module 'chai-enzyme/test/inspect.test.js' {504 declare module.exports: $Exports<'chai-enzyme/test/inspect.test'>;505}506declare module 'chai-enzyme/test/match.test.js' {507 declare module.exports: $Exports<'chai-enzyme/test/match.test'>;508}509declare module 'chai-enzyme/test/null.test.js' {510 declare module.exports: $Exports<'chai-enzyme/test/null.test'>;511}512declare module 'chai-enzyme/test/present.test.js' {513 declare module.exports: $Exports<'chai-enzyme/test/present.test'>;514}515declare module 'chai-enzyme/test/prop.test.js' {516 declare module.exports: $Exports<'chai-enzyme/test/prop.test'>;517}518declare module 'chai-enzyme/test/props.test.js' {519 declare module.exports: $Exports<'chai-enzyme/test/props.test'>;520}521declare module 'chai-enzyme/test/ref.test.js' {522 declare module.exports: $Exports<'chai-enzyme/test/ref.test'>;523}524declare module 'chai-enzyme/test/selected.test.js' {525 declare module.exports: $Exports<'chai-enzyme/test/selected.test'>;526}527declare module 'chai-enzyme/test/state.test.js' {528 declare module.exports: $Exports<'chai-enzyme/test/state.test'>;529}530declare module 'chai-enzyme/test/style.test.js' {531 declare module.exports: $Exports<'chai-enzyme/test/style.test'>;532}533declare module 'chai-enzyme/test/support/createTest.js' {534 declare module.exports: $Exports<'chai-enzyme/test/support/createTest'>;535}536declare module 'chai-enzyme/test/support/helper.js' {537 declare module.exports: $Exports<'chai-enzyme/test/support/helper'>;538}539declare module 'chai-enzyme/test/tagName.test.js' {540 declare module.exports: $Exports<'chai-enzyme/test/tagName.test'>;541}542declare module 'chai-enzyme/test/text.test.js' {543 declare module.exports: $Exports<'chai-enzyme/test/text.test'>;544}545declare module 'chai-enzyme/test/type.test.js' {546 declare module.exports: $Exports<'chai-enzyme/test/type.test'>;547}548declare module 'chai-enzyme/test/value.test.js' {549 declare module.exports: $Exports<'chai-enzyme/test/value.test'>;...

Full Screen

Full Screen

brain.js

Source:brain.js Github

copy

Full Screen

1/*2 This file contains a small, personalized chunk of "Rensa" - a library that helps you store and reason over concepts and relationships.3*/4define([], function() {5 // A Brain contains assertions about the world.6 function Brain(){7 this.assertions = {};8 }9 // Makes a brain given a list of concepts.10 var makeBrain = function(facts){11 var brain = new Brain();12 for (var i in facts){13 brain.addAssertion(facts[i]);14 }15 return brain;16 };17 // Returns the intersection between two brains.18 Brain.prototype.intersect = function(other){19 myAsserts = this.getAssertions();20 otherAsserts = other.getAssertions();21 intersect = [];22 for (var i in myAsserts){23 for (var j in otherAsserts){24 if (myAsserts[i].equals(otherAsserts[j])){25 intersect.push(myAsserts[i]);26 }27 }28 }29 return intersect;30 };31 // True if two brains are equivalent.32 Brain.prototype.equals = function(other){33 return (this.getAssertions().length == other.getAssertions().length) && (this.intersect(other).length == this.getAssertions().length);34 };35 // Add a new assertion to the assertions list.36 Brain.prototype.addAssertion = function(a){37 if (~this.hasAssertion(a)){38 this.assertions[Object.keys(this.assertions).length] = new Assertion(a);39 return true;40 }41 return false;42 };43 // Check if an assertion is already part of this Brain object's assertions list.44 Brain.prototype.hasAssertion = function(a){45 var assert = new Assertion(a);46 for (var i in this.assertions){47 if (this.assertions[i].equals(assert)){return true;}48 }49 return false;50 };51 // Returns an array containing all assertions.52 Brain.prototype.getAssertions = function(){53 return $.map(this.assertions, function(value, key) { return value });54 };55 // Remove an assertion from the assertions list.56 Brain.prototype.removeAssertion = function(a) {57 var assert = new Assertion(a);58 var removeKeys = [];59 for (var i in this.assertions){60 if (this.assertions[i].equals(assert)){61 removeKeys.push(i);62 }63 }64 for(var r=0;r<removeKeys.length;r++){65 delete this.assertions[r];66 }67 };68 // Remove an assertion by ID.69 Brain.prototype.removeAssertionWithID = function(idn) {70 delete this.assertions[idn];71 };72 // Returns an assertion's ID.73 Brain.prototype.getAssertionID = function(a){74 var assert = new Assertion(a);75 for (var i in this.assertions){76 if (JSON.stringify(this.assertions[i])===JSON.stringify(assert)){return i;}77 }78 return false;79 };80 // Remove an assertion by ID.81 Brain.prototype.getAssertionByID = function(idn) {82 return this.assertions[idn];83 };84 // Edit any attribute of an assertion to have a new value.85 Brain.prototype.editAssertion = function(idn,attr,value) {86 this.assertions[idn][attr] = value;87 };88 // Remove an assertion's property.89 Brain.prototype.removeAssertionProperty = function(idn,propertyName) {90 delete this.assertions[idn][propertyName];91 };92 // Returns list of all assertions IDs with the specified values for attributes.93 Brain.prototype.getAssertionsWith = function(d){94 var l = [];95 var flag;96 for (var i in this.assertions){97 flag = true;98 for (var key in d){99 for(var j=0; j<d[key].length;j++){100 if (this.assertions[i].hasOwnProperty(key)){101 // Not viable for old versions of IE.102 if ((this.assertions[i][key]).indexOf(d[key][j]) == -1){103 flag = false;104 }105 }106 else{107 flag=false;108 }109 }110 }111 if (flag){112 l.push(i);113 }114 }115 return l;116 };117 // Takes in a string concept, and returns a list of all118 // assertions that involve that concept, and how they are related.119 // Example:120 // If concept is "prince" and prince instance_of actor, returns121 // [ [{"l":["prince"], "relation":"instance_of", "r":["actor"]}, "l"] ]122 Brain.prototype.getAssertionsRelatedTo = function(concept){123 var l = [];124 for (var i in this.assertions){125 // For each property in the current assertion,126 for (var property in this.assertions[i]) {127 if (this.assertions[i].hasOwnProperty(property) && this.assertions[i][property]) {128 // If the value of that property is an array with at least one element129 if (this.assertions[i][property] instanceof Array && this.assertions[i][property].length > 0){130 // If the value of the current assertion's property131 // contains concept,132 if (this.assertions[i][property].indexOf(concept) != -1){133 // Add this assertion and the property to the list.134 l.push([this.assertions[i], property]);135 }136 }137 // If the value of that property is a string,138 else if(typeof this.assertions[i][property] === 'string' || this.assertions[i][property] instanceof String){139 // If the value of the current assertion's property140 // is concept,141 if (this.assertions[i][property] == concept){142 // Add this assertion and the property to the list.143 l.push([this.assertions[i], property]);144 }145 }146 else{147 if (isNaN(parseFloat(this.assertions[i][property]))){148 console.log("Warning: type of " + this.assertions[i][property] + " is not string, array, or number.");149 }150 }151 }152 }153 }154 return l;155 }156 // Returns list of all assertion ids that have the specified tag.157 Brain.prototype.getAssertionsWithTag = function(t){158 var l = [];159 for (var i in this.assertions){160 if ("tag" in this.assertions[i]){161 if (this.assertions[i]["tag"] != null){162 // Not viable for old versions of IE.163 var idx = this.assertions[i]["tag"].indexOf(t);164 if (idx != null){165 if (idx > -1) {166 l.push(i);167 }168 }169 }170 }171 }172 return l;173 };174 // For every id in ids, find the list of strings for175 // a given concept. Return an array with all elements of176 // those lists.177 Brain.prototype.getConceptList = function(ids, concept){178 var result = [];179 for(var i in ids){180 for (var x in this.getAssertionByID(ids[i])[concept]){181 result.push(this.getAssertionByID(ids[i])[concept][x]);182 }183 }184 return result;185 }186 // Given an array of strings that represent groups,187 // return a list of the individuals that make up those groups.188 // Example: getIndivs(["woman"]) for Beauty and the Beast returns189 // ["Belle", "Mrs. Potts", "Babette", "The Wardrobe", "Claudette",190 // "Laurette", "Paulette", "Enchantress"] if they are all categorized as a woman.191 Brain.prototype.getIndivs = function(group){192 var indivs = [];193 var flag = true;194 var g;195 if (group.constructor === Array){196 while(flag){197 flag = false;198 tempGroup = [];199 for(g in group){200 var ids = this.getAssertionsWith({"relation":"type_of","r":[group[g]]});201 if (ids.length > 0){202 tempGroup.push.apply(tempGroup, this.getConceptList(ids,"l"));203 flag = true;204 }205 else{206 indivs.push(group[g]);207 }208 }209 group = tempGroup;210 }211 return indivs;212 }213 else{214 console.log("Error: you should be passing in an array of strings to getIndivs().")215 return false;216 }217 };218 // Print all known assertions.219 Brain.prototype.print = function(){220 for (var i in this.assertions){221 // console.log(JSON.stringify(this.assertions[i]));222 }223 };224 // Print all known assertions, prettily.225 Brain.prototype.prettyprint = function(){226 for (var i in this.assertions){227 _prettyprint(this.assertions[i], true);228 }229 };230 var _prettyprint = function(a, printAllProperties){231 var flag=false;232 // console.log(JSON.stringify(a["l"]) +" "+ a["relation"] +" "+ JSON.stringify(a["r"]));233 if (printAllProperties){234 for (var p in a) {235 if (a.hasOwnProperty(p) && p!="l" && p!="relation" && p!="r" && typeof a[p]!=="function") {236 flag=true;237 // console.log("\t"+p+": " + JSON.stringify(a[p]));238 }239 }240 }241 //if (flag){console.log("");}242 return JSON.stringify(a["l"]) +" "+ a["relation"] +" "+ JSON.stringify(a["r"]);243 }244 // Return a clone of a brain.245 Brain.prototype.clone = function(){246 return makeBrain(this.assertions);247 }248 // Assertions are links between two concepts.249 function Assertion(attributes){250 this.l = this.addRequiredProperty("l", attributes);251 this.relation = this.addRequiredProperty("relation", attributes);252 this.r = this.addRequiredProperty("r", attributes);253 // Add all remaining optional properties.254 for (var property in attributes){255 if (attributes.hasOwnProperty(property)) {256 this[property] = this.addOptionalProperty(property,attributes,undefined);257 }258 }259 }260 // Check if another array is equivalent to this one.261 Assertion.prototype.equals = function(other){262 if (other instanceof Assertion){263 for (var property in this) {264 if (this.hasOwnProperty(property)) {265 if (other.hasOwnProperty(property)) {266 if (!(JSON.stringify(other[property]) === JSON.stringify(this[property]))) {267 if (!(arraysEqual(other[property],this[property]))){268 return false;269 }270 }271 }272 else{273 return false;274 }275 }276 }277 }278 return true;279 };280 Assertion.prototype.stringify = function(){281 return JSON.stringify(this);282 };283 Assertion.prototype.clone = function(){284 return JSON.parse(JSON.stringify(this));285 };286 // Helper for Assertion.prototype.equals.287 // Determines if two arrays are equal.288 var arraysEqual=function(a, b) {289 if (a.constructor === Array && b.constructor === Array){290 if (a === b) return true;291 if (a == null || b == null) return false;292 if (a.length != b.length) return false;293 a = a.sort();294 b = b.sort();295 for (var i = 0; i < a.length; ++i) {296 if (a[i] !== b[i]) return false;297 }298 return true;299 }300 return false;301 };302 // Helper function for assigning mandatory attributes.303 Assertion.prototype.addRequiredProperty = function(propertyName,attributesList){304 // Check if assertion has the property.305 if (propertyName in attributesList){306 return attributesList[propertyName];307 }308 // console.log("Warning: no " + propertyName + " property in assertion: \n" + JSON.stringify(attributesList) + "\n");309 return null;310 };311 // Helper function for assigning optional attributes.312 Assertion.prototype.addOptionalProperty = function(propertyName,attributesList,defaultValue){313 // Check if assertion has the property.314 if (propertyName in attributesList){315 return attributesList[propertyName];316 }317 return defaultValue;318 };319 // Checks if an array contains an object.320 var containsObj=function(obj, list) {321 var i;322 for (i = 0; i < list.length; i++) {323 if (JSON.stringify(obj) === JSON.stringify(list[i])) {324 return true;325 }326 }327 return false;328 }329 // Finds the intersection of two arrays.330 // Note: this will not work with objects.331 function intersect(a, b) {332 var t;333 if (b.length > a.length) t = b, b = a, a = t; // indexOf to loop over shorter334 return a335 .filter(function (e) {336 if (b.indexOf(e) !== -1) return true;337 })338 .filter(function (e, i, c) { // extra step to remove duplicates339 return c.indexOf(e) === i;340 });341 };342 return {343 makeBrain : makeBrain,344 arraysEqual : arraysEqual,345 prettyprint : _prettyprint,346 containsObj : containsObj347 }...

Full Screen

Full Screen

step_plot_per_series.js

Source:step_plot_per_series.js Github

copy

Full Screen

1/**2 * @fileoverview Test cases for the option "stepPlot" especially for the scenario where the option is not set for the whole graph but for single series.3 *4 * @author julian.eichstaedt@ch.sauter-bc.com (Fr. Sauter AG)5 */6var StepTestCase = TestCase("step-plot-per-series");7StepTestCase.prototype.setUp = function() {8 document.body.innerHTML = "<div id='graph'></div>";9};10StepTestCase.origFunc = Dygraph.getContext;11StepTestCase.prototype.setUp = function() {12 document.body.innerHTML = "<div id='graph'></div>";13 Dygraph.getContext = function(canvas) {14 return new Proxy(StepTestCase.origFunc(canvas));15 };16};17StepTestCase.prototype.tearDown = function() {18 Dygraph.getContext = StepTestCase.origFunc;19};20StepTestCase.prototype.testMixedModeStepAndLineFilled = function() {21 var opts = {22 width: 480,23 height: 320,24 drawXGrid: false,25 drawYGrid: false,26 drawXAxis: false,27 drawYAxis: false,28 errorBars: false,29 labels: ["X", "Idle", "Used"],30 series: {31 Idle: {stepPlot: false},32 Used: {stepPlot: true}33 },34 fillGraph: true,35 stackedGraph: false,36 includeZero: true37 };38 var data = [39 [1, 70,30],40 [2, 12,88],41 [3, 88,12],42 [4, 63,37],43 [5, 35,65]44 ];45 var graph = document.getElementById("graph");46 var g = new Dygraph(graph, data, opts);47 htx = g.hidden_ctx_;48 var attrs = {}; 49 for (var i = 0; i < data.length - 1; i++) {50 var x1 = data[i][0];51 var x2 = data[i + 1][0];52 var y1 = data[i][1];53 var y2 = data[i + 1][1];54 // First series (line)55 var xy1 = g.toDomCoords(x1, y1);56 var xy2 = g.toDomCoords(x2, y2);57 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);58 y1 = data[i][2];59 y2 = data[i + 1][2];60 // Seconds series (step)61 // Horizontal line62 xy1 = g.toDomCoords(x1, y1);63 xy2 = g.toDomCoords(x2, y1);64 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);65 // Vertical line66 xy1 = g.toDomCoords(x2, y1);67 xy2 = g.toDomCoords(x2, y2);68 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);69 }70};71StepTestCase.prototype.testMixedModeStepAndLineStackedAndFilled = function() {72 var opts = {73 width: 480,74 height: 320,75 drawXGrid: false,76 drawYGrid: false,77 drawXAxis: false,78 drawYAxis: false,79 errorBars: false,80 labels: ["X", "Idle", "Used", "NotUsed", "Active"],81 series: {82 Idle: {stepPlot: false},83 Used: {stepPlot: true},84 NotUsed: {stepPlot: false},85 Active: {stepPlot: true}86 },87 fillGraph: true,88 stackedGraph: true,89 includeZero: true90 };91 var data = [92 [1, 60,30,5,5],93 [2, 12,73,5,10],94 [3, 38,12,30,20],95 [4, 50,17,23,10],96 [5, 35,25,35,5]97 ];98 var graph = document.getElementById("graph");99 var g = new Dygraph(graph, data, opts);100 htx = g.hidden_ctx_;101 var attrs = {}; 102 for (var i = 0; i < data.length - 1; i++) {103 104 var x1 = data[i][0];105 var x2 = data[i + 1][0];106 var y1base = 0;107 var y2base = 0;108 var y1 = data[i][4];109 var y2 = data[i + 1][4];110 // Fourth series (step)111 // Test lines112 // Horizontal line113 var xy1 = g.toDomCoords(x1, y1);114 var xy2 = g.toDomCoords(x2, y1);115 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);116 // Vertical line117 xy1 = g.toDomCoords(x2, y1);118 xy2 = g.toDomCoords(x2, y2);119 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);120 // Test edges of areas (also drawn by dygraphs as lines)121 xy1 = g.toDomCoords(x1, y1);122 xy2 = g.toDomCoords(x2, y1);123 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);124 xy1 = xy2;125 xy2 = g.toDomCoords(x2, y2base);126 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);127 xy1 = xy2;128 xy2 = g.toDomCoords(x1, y1base);129 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);130 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.131 // But a rectangle is completely tested with three of its four edges.132 133 y1base = y1;134 y2base = y1;135 y1 += data[i][3];136 y2 += data[i + 1][3];137 138 // Third series (line)139 // Test lines140 xy1 = g.toDomCoords(x1, y1);141 xy2 = g.toDomCoords(x2, y2);142 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);143 // Test edges of areas (also drawn by dygraphs as lines)144 xy1 = g.toDomCoords(x1, y1);145 xy2 = g.toDomCoords(x2, y2);146 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);147 xy1 = xy2;148 xy2 = g.toDomCoords(x2, y2base);149 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);150 xy1 = xy2;151 xy2 = g.toDomCoords(x1, y1base);152 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);153 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.154 // But a rectangle is completely tested with three of its four edges.155 156 y1base = y1;157 y2base = y2;158 y1 += data[i][2];159 y2 += data[i + 1][2];160 // Second series (step)161 // Test lines162 // Horizontal line163 xy1 = g.toDomCoords(x1, y1);164 xy2 = g.toDomCoords(x2, y1);165 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);166 // Vertical line167 xy1 = g.toDomCoords(x2, y1);168 xy2 = g.toDomCoords(x2, y2);169 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);170 // Test edges of areas (also drawn by dygraphs as lines)171 xy1 = g.toDomCoords(x1, y1);172 xy2 = g.toDomCoords(x2, y1);173 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);174 xy1 = xy2;175 xy2 = g.toDomCoords(x2, y2base);176 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);177 xy1 = xy2;178 xy2 = g.toDomCoords(x1, y1base);179 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);180 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.181 // But a rectangle is completely tested with three of its four edges.182 183 y1base = y1;184 y2base = y1;185 y1 += data[i][1];186 y2 += data[i + 1][1];187 // First series (line)188 // Test lines189 xy1 = g.toDomCoords(x1, y1);190 xy2 = g.toDomCoords(x2, y2);191 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);192 // Test edges of areas (also drawn by dygraphs as lines)193 xy1 = g.toDomCoords(x1, y1);194 xy2 = g.toDomCoords(x2, y2);195 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);196 xy1 = xy2;197 xy2 = g.toDomCoords(x2, y2base);198 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);199 xy1 = xy2;200 xy2 = g.toDomCoords(x1, y1base);201 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);202 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.203 // But a rectangle is completely tested with three of its four edges.204 }205};206StepTestCase.prototype.testMixedModeStepAndLineErrorBars = function() {207 var opts = {208 width: 480,209 height: 320,210 drawXGrid: false,211 drawYGrid: false,212 drawXAxis: false,213 drawYAxis: false,214 errorBars: true,215 sigma: 1,216 labels: ["X", "Data1", "Data2"],217 series: {218 Data1: {stepPlot: true}, 219 Data2: {stepPlot: false} 220 }221 };222 var data = [223 [1, [75, 2], [50, 3]],224 [2, [70, 5], [90, 4]],225 [3, [80, 7], [112, 5]],226 [4, [55, 3], [100, 2]],227 [5, [69, 4], [85, 6]]228 ];229 var graph = document.getElementById("graph");230 var g = new Dygraph(graph, data, opts);231 htx = g.hidden_ctx_;232 var attrs = {}; 233 // Test first series (step)234 for (var i = 0; i < data.length - 1; i++) {235 var x1 = data[i][0];236 var x2 = data[i + 1][0];237 238 var y1_middle = data[i][1][0];239 var y2_middle = data[i + 1][1][0];240 241 var y1_top = y1_middle + data[i][1][1];242 var y2_top = y2_middle + data[i + 1][1][1];243 244 var y1_bottom = y1_middle - data[i][1][1];245 var y2_bottom = y2_middle - data[i + 1][1][1];246 // Bottom line247 var xy1 = g.toDomCoords(x1, y1_bottom);248 var xy2 = g.toDomCoords(x2, y1_bottom);249 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);250 // Top line251 xy1 = g.toDomCoords(x1, y1_top);252 xy2 = g.toDomCoords(x2, y1_top);253 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);254 // Middle line255 xy1 = g.toDomCoords(x1, y1_middle);256 xy2 = g.toDomCoords(x2, y1_middle);257 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);258 259 // Test edges of error bar areas(also drawn by dygraphs as lines)260 xy1 = g.toDomCoords(x1, y1_top);261 xy2 = g.toDomCoords(x2, y1_top);262 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);263 xy1 = xy2;264 xy2 = g.toDomCoords(x2, y1_bottom);265 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);266 xy1 = xy2;267 xy2 = g.toDomCoords(x1, y1_bottom);268 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);269 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.270 // But a rectangle is completely tested with three of its four edges.271 }272 // Test second series (line) 273 for (var i = 0; i < data.length - 1; i++) {274 // bottom line275 var xy1 = g.toDomCoords(data[i][0], (data[i][2][0] - data[i][2][1]));276 var xy2 = g.toDomCoords(data[i + 1][0], (data[i + 1][2][0] - data[i + 1][2][1]));277 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);278 // top line279 xy1 = g.toDomCoords(data[i][0], data[i][2][0] + data[i][2][1]);280 xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][0] + data[i + 1][2][1]);281 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);282 // middle line283 xy1 = g.toDomCoords(data[i][0], data[i][2][0]);284 xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][0]);285 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);286 }287};288StepTestCase.prototype.testMixedModeStepAndLineCustomBars = function() {289 var opts = {290 width: 480,291 height: 320,292 drawXGrid: false,293 drawYGrid: false,294 drawXAxis: false,295 drawYAxis: false,296 customBars: true,297 labels: ["X", "Data1", "Data2"],298 series: {299 Data1: {stepPlot: true}, 300 Data2: {stepPlot: false} 301 }302 };303 var data = [304 [1, [73, 75, 78], [50, 55, 70]],305 [2, [65, 70, 75], [83, 91, 99]],306 [3, [75, 85, 90], [98, 107, 117]],307 [4, [55, 58, 61], [93, 102, 105]],308 [5, [69, 73, 85], [80, 85, 87]]309 ];310 var graph = document.getElementById("graph");311 var g = new Dygraph(graph, data, opts);312 htx = g.hidden_ctx_;313 var attrs = {}; 314 // Test first series (step)315 for (var i = 0; i < data.length - 1; i++) {316 var x1 = data[i][0];317 var x2 = data[i + 1][0];318 319 var y1_middle = data[i][1][1];320 var y2_middle = data[i + 1][1][1];321 322 var y1_top = data[i][1][2];323 var y2_top = data[i + 1][1][2];324 325 var y1_bottom = data[i][1][0];326 var y2_bottom = data[i + 1][1][0];327 328 // Bottom line329 var xy1 = g.toDomCoords(x1, y1_bottom);330 var xy2 = g.toDomCoords(x2, y1_bottom);331 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);332 333 // Top line334 xy1 = g.toDomCoords(x1, y1_top);335 xy2 = g.toDomCoords(x2, y1_top);336 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);337 338 // Middle line339 xy1 = g.toDomCoords(x1, y1_middle);340 xy2 = g.toDomCoords(x2, y1_middle);341 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);342 343 // Test edges of custom bar areas(also drawn by dygraphs as lines)344 xy1 = g.toDomCoords(x1, y1_top);345 xy2 = g.toDomCoords(x2, y1_top);346 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);347 xy1 = xy2;348 xy2 = g.toDomCoords(x2, y1_bottom);349 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);350 xy1 = xy2;351 xy2 = g.toDomCoords(x1, y1_bottom);352 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);353 // The last edge can not be tested via assertLineDrawn since it wasn't drawn as a line but via clossePath.354 // But a rectangle is completely tested with three of its four edges.355 }356 357 // Test second series (line)358 for (var i = 0; i < data.length - 1; i++) {359 // Bottom line360 var xy1 = g.toDomCoords(data[i][0], data[i][2][0]);361 var xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][0]);362 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);363 // Top line364 xy1 = g.toDomCoords(data[i][0], data[i][2][2]);365 xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][2]);366 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);367 // Middle line368 xy1 = g.toDomCoords(data[i][0], data[i][2][1]);369 xy2 = g.toDomCoords(data[i + 1][0], data[i + 1][2][1]);370 CanvasAssertions.assertLineDrawn(htx, xy1, xy2, attrs);371 }...

Full Screen

Full Screen

options.js

Source:options.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", {3 value: true4});5exports.validate = validate;6exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs;7exports.assumptionsNames = void 0;8var _plugin = require("../plugin");9var _removed = require("./removed");10var _optionAssertions = require("./option-assertions");11const ROOT_VALIDATORS = {12 cwd: _optionAssertions.assertString,13 root: _optionAssertions.assertString,14 rootMode: _optionAssertions.assertRootMode,15 configFile: _optionAssertions.assertConfigFileSearch,16 caller: _optionAssertions.assertCallerMetadata,17 filename: _optionAssertions.assertString,18 filenameRelative: _optionAssertions.assertString,19 code: _optionAssertions.assertBoolean,20 ast: _optionAssertions.assertBoolean,21 cloneInputAst: _optionAssertions.assertBoolean,22 envName: _optionAssertions.assertString23};24const BABELRC_VALIDATORS = {25 babelrc: _optionAssertions.assertBoolean,26 babelrcRoots: _optionAssertions.assertBabelrcSearch27};28const NONPRESET_VALIDATORS = {29 extends: _optionAssertions.assertString,30 ignore: _optionAssertions.assertIgnoreList,31 only: _optionAssertions.assertIgnoreList,32 targets: _optionAssertions.assertTargets,33 browserslistConfigFile: _optionAssertions.assertConfigFileSearch,34 browserslistEnv: _optionAssertions.assertString35};36const COMMON_VALIDATORS = {37 inputSourceMap: _optionAssertions.assertInputSourceMap,38 presets: _optionAssertions.assertPluginList,39 plugins: _optionAssertions.assertPluginList,40 passPerPreset: _optionAssertions.assertBoolean,41 assumptions: _optionAssertions.assertAssumptions,42 env: assertEnvSet,43 overrides: assertOverridesList,44 test: _optionAssertions.assertConfigApplicableTest,45 include: _optionAssertions.assertConfigApplicableTest,46 exclude: _optionAssertions.assertConfigApplicableTest,47 retainLines: _optionAssertions.assertBoolean,48 comments: _optionAssertions.assertBoolean,49 shouldPrintComment: _optionAssertions.assertFunction,50 compact: _optionAssertions.assertCompact,51 minified: _optionAssertions.assertBoolean,52 auxiliaryCommentBefore: _optionAssertions.assertString,53 auxiliaryCommentAfter: _optionAssertions.assertString,54 sourceType: _optionAssertions.assertSourceType,55 wrapPluginVisitorMethod: _optionAssertions.assertFunction,56 highlightCode: _optionAssertions.assertBoolean,57 sourceMaps: _optionAssertions.assertSourceMaps,58 sourceMap: _optionAssertions.assertSourceMaps,59 sourceFileName: _optionAssertions.assertString,60 sourceRoot: _optionAssertions.assertString,61 parserOpts: _optionAssertions.assertObject,62 generatorOpts: _optionAssertions.assertObject63};64{65 Object.assign(COMMON_VALIDATORS, {66 getModuleId: _optionAssertions.assertFunction,67 moduleRoot: _optionAssertions.assertString,68 moduleIds: _optionAssertions.assertBoolean,69 moduleId: _optionAssertions.assertString70 });71}72const assumptionsNames = new Set(["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noNewArrows", "objectRestNoSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"]);73exports.assumptionsNames = assumptionsNames;74function getSource(loc) {75 return loc.type === "root" ? loc.source : getSource(loc.parent);76}77function validate(type, opts) {78 return validateNested({79 type: "root",80 source: type81 }, opts);82}83function validateNested(loc, opts) {84 const type = getSource(loc);85 assertNoDuplicateSourcemap(opts);86 Object.keys(opts).forEach(key => {87 const optLoc = {88 type: "option",89 name: key,90 parent: loc91 };92 if (type === "preset" && NONPRESET_VALIDATORS[key]) {93 throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in preset options`);94 }95 if (type !== "arguments" && ROOT_VALIDATORS[key]) {96 throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options`);97 }98 if (type !== "arguments" && type !== "configfile" && BABELRC_VALIDATORS[key]) {99 if (type === "babelrcfile" || type === "extendsfile") {100 throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in .babelrc or "extends"ed files, only in root programmatic options, ` + `or babel.config.js/config file options`);101 }102 throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options, or babel.config.js/config file options`);103 }104 const validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || BABELRC_VALIDATORS[key] || ROOT_VALIDATORS[key] || throwUnknownError;105 validator(optLoc, opts[key]);106 });107 return opts;108}109function throwUnknownError(loc) {110 const key = loc.name;111 if (_removed.default[key]) {112 const {113 message,114 version = 5115 } = _removed.default[key];116 throw new Error(`Using removed Babel ${version} option: ${(0, _optionAssertions.msg)(loc)} - ${message}`);117 } else {118 const unknownOptErr = new Error(`Unknown option: ${(0, _optionAssertions.msg)(loc)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`);119 unknownOptErr.code = "BABEL_UNKNOWN_OPTION";120 throw unknownOptErr;121 }122}123function has(obj, key) {124 return Object.prototype.hasOwnProperty.call(obj, key);125}126function assertNoDuplicateSourcemap(opts) {127 if (has(opts, "sourceMap") && has(opts, "sourceMaps")) {128 throw new Error(".sourceMap is an alias for .sourceMaps, cannot use both");129 }130}131function assertEnvSet(loc, value) {132 if (loc.parent.type === "env") {133 throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside of another .env block`);134 }135 const parent = loc.parent;136 const obj = (0, _optionAssertions.assertObject)(loc, value);137 if (obj) {138 for (const envName of Object.keys(obj)) {139 const env = (0, _optionAssertions.assertObject)((0, _optionAssertions.access)(loc, envName), obj[envName]);140 if (!env) continue;141 const envLoc = {142 type: "env",143 name: envName,144 parent145 };146 validateNested(envLoc, env);147 }148 }149 return obj;150}151function assertOverridesList(loc, value) {152 if (loc.parent.type === "env") {153 throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .env block`);154 }155 if (loc.parent.type === "overrides") {156 throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .overrides block`);157 }158 const parent = loc.parent;159 const arr = (0, _optionAssertions.assertArray)(loc, value);160 if (arr) {161 for (const [index, item] of arr.entries()) {162 const objLoc = (0, _optionAssertions.access)(loc, index);163 const env = (0, _optionAssertions.assertObject)(objLoc, item);164 if (!env) throw new Error(`${(0, _optionAssertions.msg)(objLoc)} must be an object`);165 const overridesLoc = {166 type: "overrides",167 index,168 parent169 };170 validateNested(overridesLoc, env);171 }172 }173 return arr;174}175function checkNoUnwrappedItemOptionPairs(items, index, type, e) {176 if (index === 0) return;177 const lastItem = items[index - 1];178 const thisItem = items[index];179 if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") {180 e.message += `\n- Maybe you meant to use\n` + `"${type}s": [\n ["${lastItem.file.request}", ${JSON.stringify(thisItem.value, undefined, 2)}]\n]\n` + `To be a valid ${type}, its name and options should be wrapped in a pair of brackets`;181 }...

Full Screen

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 Sure 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