Best JavaScript code snippet using storybook-root
regexp.js.uncompressed.js
Source:regexp.js.uncompressed.js
1define("dojox/validate/regexp", ["dojo/_base/lang", "dojo/regexp", "dojox/main"], 2 function(lang, regexp, dojox){3var dxregexp = lang.getObject("validate.regexp", true, dojox);4dxregexp = dojox.validate.regexp = {5 6 ipAddress: function(flags){7 // summary:8 // Builds a RE that matches an IP Address9 // description:10 // Supports 5 formats for IPv4: dotted decimal, dotted hex, dotted octal, decimal and hexadecimal.11 // Supports 2 formats for Ipv6.12 // flags: Object?13 // All flags are boolean with default = true.14 //15 // - flags.allowDottedDecimal Example, 207.142.131.235. No zero padding.16 // - flags.allowDottedHex Example, 0x18.0x11.0x9b.0x28. Case insensitive. Zero padding allowed.17 // - flags.allowDottedOctal Example, 0030.0021.0233.0050. Zero padding allowed.18 // - flags.allowDecimal Example, 3482223595. A decimal number between 0-4294967295.19 // - flags.allowHex Example, 0xCF8E83EB. Hexadecimal number between 0x0-0xFFFFFFFF.20 // Case insensitive. Zero padding allowed.21 // - flags.allowIPv6 IPv6 address written as eight groups of four hexadecimal digits.22 23 // FIXME: ipv6 can be written multiple ways IIRC24 // - flags.allowHybrid IPv6 address written as six groups of four hexadecimal digits25 // - followed by the usual 4 dotted decimal digit notation of IPv4. x:x:x:x:x:x:d.d.d.d26 // assign default values to missing parameters27 flags = (typeof flags == "object") ? flags : {};28 if(typeof flags.allowDottedDecimal != "boolean"){ flags.allowDottedDecimal = true; }29 if(typeof flags.allowDottedHex != "boolean"){ flags.allowDottedHex = true; }30 if(typeof flags.allowDottedOctal != "boolean"){ flags.allowDottedOctal = true; }31 if(typeof flags.allowDecimal != "boolean"){ flags.allowDecimal = true; }32 if(typeof flags.allowHex != "boolean"){ flags.allowHex = true; }33 if(typeof flags.allowIPv6 != "boolean"){ flags.allowIPv6 = true; }34 if(typeof flags.allowHybrid != "boolean"){ flags.allowHybrid = true; }35 // decimal-dotted IP address RE.36 var dottedDecimalRE =37 // Each number is between 0-255. Zero padding is not allowed.38 "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";39 // dotted hex IP address RE. Each number is between 0x0-0xff. Zero padding is allowed, e.g. 0x00.40 var dottedHexRE = "(0[xX]0*[\\da-fA-F]?[\\da-fA-F]\\.){3}0[xX]0*[\\da-fA-F]?[\\da-fA-F]";41 // dotted octal IP address RE. Each number is between 0000-0377.42 // Zero padding is allowed, but each number must have at least 4 characters.43 var dottedOctalRE = "(0+[0-3][0-7][0-7]\\.){3}0+[0-3][0-7][0-7]";44 // decimal IP address RE. A decimal number between 0-4294967295.45 var decimalRE = "(0|[1-9]\\d{0,8}|[1-3]\\d{9}|4[01]\\d{8}|42[0-8]\\d{7}|429[0-3]\\d{6}|" +46 "4294[0-8]\\d{5}|42949[0-5]\\d{4}|429496[0-6]\\d{3}|4294967[01]\\d{2}|42949672[0-8]\\d|429496729[0-5])";47 // hexadecimal IP address RE.48 // A hexadecimal number between 0x0-0xFFFFFFFF. Case insensitive. Zero padding is allowed.49 var hexRE = "0[xX]0*[\\da-fA-F]{1,8}";50 // IPv6 address RE.51 // The format is written as eight groups of four hexadecimal digits, x:x:x:x:x:x:x:x,52 // where x is between 0000-ffff. Zero padding is optional. Case insensitive.53 var ipv6RE = "([\\da-fA-F]{1,4}\\:){7}[\\da-fA-F]{1,4}";54 // IPv6/IPv4 Hybrid address RE.55 // The format is written as six groups of four hexadecimal digits,56 // followed by the 4 dotted decimal IPv4 format. x:x:x:x:x:x:d.d.d.d57 var hybridRE = "([\\da-fA-F]{1,4}\\:){6}" +58 "((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.){3}(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])";59 // Build IP Address RE60 var a = [];61 if(flags.allowDottedDecimal){ a.push(dottedDecimalRE); }62 if(flags.allowDottedHex){ a.push(dottedHexRE); }63 if(flags.allowDottedOctal){ a.push(dottedOctalRE); }64 if(flags.allowDecimal){ a.push(decimalRE); }65 if(flags.allowHex){ a.push(hexRE); }66 if(flags.allowIPv6){ a.push(ipv6RE); }67 if(flags.allowHybrid){ a.push(hybridRE); }68 var ipAddressRE = "";69 if(a.length > 0){70 ipAddressRE = "(" + a.join("|") + ")";71 }72 return ipAddressRE; // String73 },74 host: function(flags){75 // summary:76 // Builds a RE that matches a host77 // description:78 // A host is a named host (A-z0-9_- but not starting with -), a domain name or an IP address, possibly followed by a port number.79 // flags: Object?80 // - flags.allowNamed Allow a named host for local networks. Default is false.81 // - flags.allowIP Allow an IP address for hostname. Default is true.82 // - flags.allowLocal Allow the host to be "localhost". Default is false.83 // - flags.allowPort Allow a port number to be present. Default is true.84 // - flags in regexp.ipAddress can be applied.85 // assign default values to missing parameters86 flags = (typeof flags == "object") ? flags : {};87 if(typeof flags.allowIP != "boolean"){ flags.allowIP = true; }88 if(typeof flags.allowLocal != "boolean"){ flags.allowLocal = false; }89 if(typeof flags.allowPort != "boolean"){ flags.allowPort = true; }90 if(typeof flags.allowNamed != "boolean"){ flags.allowNamed = false; }91 //TODO: support unicode hostnames?92 // Domain name labels can not end with a dash.93 var domainLabelRE = "(?:[\\da-zA-Z](?:[-\\da-zA-Z]{0,61}[\\da-zA-Z])?)";94 var domainNameRE = "(?:[a-zA-Z](?:[-\\da-zA-Z]{0,6}[\\da-zA-Z])?)"; // restricted version to allow backwards compatibility with allowLocal, allowIP95 // port number RE96 var portRE = flags.allowPort ? "(\\:\\d+)?" : "";97 // build host RE98 var hostNameRE = "((?:" + domainLabelRE + "\\.)+" + domainNameRE + "\\.?)";99 if(flags.allowIP){ hostNameRE += "|" + dxregexp.ipAddress(flags); }100 if(flags.allowLocal){ hostNameRE += "|localhost"; }101 if(flags.allowNamed){ hostNameRE += "|^[^-][a-zA-Z0-9_-]*"; }102 return "(" + hostNameRE + ")" + portRE; // String103 },104 url: function(flags){105 // summary:106 // Builds a regular expression that matches a URL107 // flags: Object?108 // - flags.scheme Can be true, false, or [true, false].109 // - This means: required, not allowed, or match either one.110 // - flags in regexp.host can be applied.111 // - flags in regexp.ipAddress can be applied.112 // assign default values to missing parameters113 flags = (typeof flags == "object") ? flags : {};114 if(!("scheme" in flags)){ flags.scheme = [true, false]; }115 // Scheme RE116 var protocolRE = regexp.buildGroupRE(flags.scheme,117 function(q){ if(q){ return "(https?|ftps?)\\://"; } return ""; }118 );119 // Path and query and anchor RE120 var pathRE = "(/(?:[^?#\\s/]+/)*(?:[^?#\\s/]+(?:\\?[^?#\\s/]*)?(?:#[A-Za-z][\\w.:-]*)?)?)?";121 return protocolRE + dxregexp.host(flags) + pathRE;122 },123 emailAddress: function(flags){124 // summary:125 // Builds a regular expression that matches an email address126 // flags: Object?127 // - flags.allowCruft Allow address like `<mailto:foo@yahoo.com>`. Default is false.128 // - flags in regexp.host can be applied.129 // - flags in regexp.ipAddress can be applied.130 // assign default values to missing parameters131 flags = (typeof flags == "object") ? flags : {};132 if (typeof flags.allowCruft != "boolean") { flags.allowCruft = false; }133 flags.allowPort = false; // invalid in email addresses134 // user name RE per rfc5322135 var usernameRE = "([!#-'*+\\-\\/-9=?A-Z^-~]+[.])*[!#-'*+\\-\\/-9=?A-Z^-~]+";136 // build emailAddress RE137 var emailAddressRE = usernameRE + "@" + dxregexp.host(flags);138 // Allow email addresses with cruft139 if ( flags.allowCruft ) {140 emailAddressRE = "<?(mailto\\:)?" + emailAddressRE + ">?";141 }142 return emailAddressRE; // String143 },144 emailAddressList: function(flags){145 // summary:146 // Builds a regular expression that matches a list of email addresses.147 // flags: Object?148 // - flags.listSeparator The character used to separate email addresses. Default is ";", ",", "\n" or " ".149 // - flags in regexp.emailAddress can be applied.150 // - flags in regexp.host can be applied.151 // - flags in regexp.ipAddress can be applied.152 // assign default values to missing parameters153 flags = (typeof flags == "object") ? flags : {};154 if(typeof flags.listSeparator != "string"){ flags.listSeparator = "\\s;,"; }155 // build a RE for an Email Address List156 var emailAddressRE = dxregexp.emailAddress(flags);157 var emailAddressListRE = "(" + emailAddressRE + "\\s*[" + flags.listSeparator + "]\\s*)*" +158 emailAddressRE + "\\s*[" + flags.listSeparator + "]?\\s*";159 return emailAddressListRE; // String160 },161 162 numberFormat: function(flags){163 // summary:164 // Builds a regular expression to match any sort of number based format165 // description:166 // Use this method for phone numbers, social security numbers, zip-codes, etc.167 // The RE can match one format or one of multiple formats.168 //169 // Format:170 //171 // - # Stands for a digit, 0-9.172 // - ? Stands for an optional digit, 0-9 or nothing.173 // - All other characters must appear literally in the expression.174 //175 // example:176 // - "(###) ###-####" - -> (510) 542-9742177 // - "(###) ###-#### x#???" -> (510) 542-9742 x153178 // - "###-##-####" - - -> 506-82-1089 - i.e. social security number179 // - "#####-####" - - -> 98225-1649 - - i.e. zip code180 //181 // flags: Object?182 // - flags.format A string or an Array of strings for multiple formats.183 // assign default values to missing parameters184 flags = (typeof flags == "object") ? flags : {};185 if(typeof flags.format == "undefined"){ flags.format = "###-###-####"; }186 // Converts a number format to RE.187 var digitRE = function(format){188 // escape all special characters, except '?'189 return regexp.escapeString(format, "?")190 // Now replace '?' with Regular Expression191 .replace(/\?/g, "\\d?")192 // replace # with Regular Expression193 .replace(/#/g, "\\d")194 ;195 };196 // build RE for multiple number formats197 return regexp.buildGroupRE(flags.format, digitRE); //String198 },199 200 ca: {201 postalCode: function(){202 // summary:203 // String regular Express to match Canadain Postal Codes204 return "([A-Z][0-9][A-Z] [0-9][A-Z][0-9])";205 },206 province: function(){207 // summary:208 // a regular expression to match Canadian Province Abbreviations209 return "(AB|BC|MB|NB|NL|NS|NT|NU|ON|PE|QC|SK|YT)";210 }211 },212 213 us:{214 state: function(flags){215 // summary:216 // A regular expression to match US state and territory abbreviations217 // flags: Object?218 // - flags.allowTerritories Allow Guam, Puerto Rico, etc. Default is true.219 // - flags.allowMilitary Allow military 'states', e.g. Armed Forces Europe (AE). Default is true.220 // assign default values to missing parameters221 flags = (typeof flags == "object") ? flags : {};222 if(typeof flags.allowTerritories != "boolean"){ flags.allowTerritories = true; }223 if(typeof flags.allowMilitary != "boolean"){ flags.allowMilitary = true; }224 // state RE225 var statesRE =226 "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|" +227 "NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY";228 // territories RE229 var territoriesRE = "AS|FM|GU|MH|MP|PW|PR|VI";230 // military states RE231 var militaryRE = "AA|AE|AP";232 // Build states and territories RE233 if(flags.allowTerritories){ statesRE += "|" + territoriesRE; }234 if(flags.allowMilitary){ statesRE += "|" + militaryRE; }235 return "(" + statesRE + ")"; // String236 }237 }238 239};240return dxregexp;...
enums.js
Source:enums.js
...93 if (arr[i] != 0) return true;94 }95 return false;96 }97 function prepare_flags(tileidx, flagdata, cache)98 {99 if (!isNaN(tileidx))100 tileidx = [tileidx];101 else if (tileidx.value !== undefined)102 return tileidx;103 while (tileidx.length < 2) tileidx.push(0);104 if (cache[[tileidx[0],tileidx[1]]] !== undefined)105 return cache[[tileidx[0],tileidx[1]]];106 for (var flagname in flagdata.flags)107 {108 var flagmask = flagdata.flags[flagname];109 if (isNaN(flagmask))110 tileidx[flagname] = array_nonzero(array_and(tileidx, flagmask));111 else112 tileidx[flagname] = (tileidx[0] & flagmask) != 0;113 }114 for (var i = 0; i < flagdata.exclusive_flags.length; ++i)115 {116 var excl = flagdata.exclusive_flags[i];117 var val;118 if (isNaN(excl.mask))119 val = array_and(tileidx, excl.mask);120 else121 val = [tileidx[0] & excl.mask];122 for (var flagname in excl)123 {124 if (flagname === "mask") continue;125 if (isNaN(excl[flagname]))126 tileidx[flagname] = array_equal(val, excl[flagname]);127 else128 tileidx[flagname] = (val[0] == excl[flagname]);129 }130 }131 tileidx.value = tileidx[0] & flagdata.mask;132 cache[[tileidx[0],tileidx[1]]] = tileidx;133 cache.size++;134 return tileidx;135 }136 /* Hex literals are signed, so values with the highest bit set137 would have to be written in 2-complement; this way is easier to138 read */139 var highbit = 1 << 31;140 // Foreground flags141 // 3 mutually exclusive flags for attitude.142 var fg_flags = { flags: {}, exclusive_flags: [] };143 fg_flags.exclusive_flags.push({144 mask : 0x00030000,145 PET : 0x00010000,146 GD_NEUTRAL : 0x00020000,147 NEUTRAL : 0x00030000,148 });149 fg_flags.flags.S_UNDER = 0x00040000;150 fg_flags.flags.FLYING = 0x00080000;151 // 3 mutually exclusive flags for behaviour.152 fg_flags.exclusive_flags.push({153 mask : 0x00300000,154 STAB : 0x00100000,155 MAY_STAB : 0x00200000,156 FLEEING : 0x00300000,157 });158 fg_flags.flags.NET = 0x00400000;159 fg_flags.flags.POISON = 0x00800000;160 fg_flags.flags.WEB = 0x01000000;161 fg_flags.flags.GLOWING = 0x02000000;162 fg_flags.flags.STICKY_FLAME = 0x04000000;163 fg_flags.flags.BERSERK = 0x08000000;164 fg_flags.flags.INNER_FLAME = 0x10000000;165 fg_flags.flags.CONSTRICTED = 0x20000000;166 fg_flags.flags.SLOWED = [0, 0x080];167 fg_flags.flags.PAIN_MIRROR = [0, 0x100];168 fg_flags.flags.HASTED = [0, 0x200];169 fg_flags.flags.MIGHT = [0, 0x400];170 fg_flags.flags.PETRIFYING = [0, 0x800];171 fg_flags.flags.PETRIFIED = [0, 0x1000];172 fg_flags.flags.BLIND = [0, 0x2000];173 fg_flags.flags.ANIM_WEP = [0, 0x4000];174 fg_flags.flags.SUMMONED = [0, 0x8000];175 fg_flags.flags.PERM_SUMMON = [0, 0x10000];176 fg_flags.flags.DEATHS_DOOR = [0, 0x20000];177 fg_flags.flags.RECALL = [0, 0x40000];178 fg_flags.flags.DRAIN = [0, 0x80000];179 fg_flags.flags.IDEALISED = [0, 0x100000];180 fg_flags.flags.BOUND_SOUL = [0, 0x200000];181 fg_flags.flags.INFESTED = [0, 0x400000];182 // MDAM has 5 possibilities, so uses 3 bits.183 fg_flags.exclusive_flags.push({184 mask : [0x40000000 | highbit, 0x01],185 MDAM_LIGHT : [0x40000000, 0x00],186 MDAM_MOD : [highbit, 0x00],187 MDAM_HEAVY : [0x40000000 | highbit, 0x00],188 MDAM_SEV : [0x00000000, 0x01],189 MDAM_ADEAD : [0x40000000 | highbit, 0x01],190 });191 // Demon difficulty has 5 possibilities, so uses 3 bits.192 fg_flags.exclusive_flags.push({193 mask : [0, 0x0E],194 DEMON_5 : [0, 0x02],195 DEMON_4 : [0, 0x04],196 DEMON_3 : [0, 0x06],197 DEMON_2 : [0, 0x08],198 DEMON_1 : [0, 0x0E],199 });200 // Mimics, 2 bits.201 fg_flags.exclusive_flags.push({202 mask : [0, 0x60],203 MIMIC_INEPT : [0, 0x20],204 MIMIC : [0, 0x40],205 MIMIC_RAVEN : [0, 0x60],206 });207 fg_flags.mask = 0x0000FFFF;208 // Background flags209 var bg_flags = { flags: {}, exclusive_flags: [] };210 bg_flags.flags.RAY = 0x00010000;211 bg_flags.flags.MM_UNSEEN = 0x00020000;212 bg_flags.flags.UNSEEN = 0x00040000;213 bg_flags.exclusive_flags.push({214 mask : 0x00180000,215 CURSOR1 : 0x00180000,216 CURSOR2 : 0x00080000,217 CURSOR3 : 0x00100000,218 });219 bg_flags.flags.TUT_CURSOR = 0x00200000;220 bg_flags.flags.TRAV_EXCL = 0x00400000;221 bg_flags.flags.EXCL_CTR = 0x00800000;222 bg_flags.flags.RAY_OOR = 0x01000000;223 bg_flags.flags.OOR = 0x02000000;224 bg_flags.flags.WATER = 0x04000000;225 bg_flags.flags.NEW_STAIR = 0x08000000;226 // Kraken tentacle overlays.227 bg_flags.flags.KRAKEN_NW = 0x20000000;228 bg_flags.flags.KRAKEN_NE = 0x40000000;229 bg_flags.flags.KRAKEN_SE = highbit;230 bg_flags.flags.KRAKEN_SW = [0, 0x01];231 // Eldritch tentacle overlays.232 bg_flags.flags.ELDRITCH_NW = [0, 0x02];233 bg_flags.flags.ELDRITCH_NE = [0, 0x04];234 bg_flags.flags.ELDRITCH_SE = [0, 0x08];235 bg_flags.flags.ELDRITCH_SW = [0, 0x10];236 bg_flags.flags.LANDING = [0, 0x200];237 bg_flags.flags.RAY_MULTI = [0, 0x400];238 bg_flags.mask = 0x0000FFFF;239 // Since the current flag implementation is really slow we use a trivial240 // cache system for now.241 var fg_cache = { size : 0 };242 exports.prepare_fg_flags = function (tileidx)243 {244 if (fg_cache.size >= 100)245 fg_cache = { size : 0 };246 return prepare_flags(tileidx, fg_flags, fg_cache);247 }248 var bg_cache = { size : 0 };249 exports.prepare_bg_flags = function (tileidx)250 {251 if (bg_cache.size >= 250)252 bg_cache = { size : 0 };253 return prepare_flags(tileidx, bg_flags, bg_cache);254 }255 // Menu flags -- see menu.h256 var mf = {};257 mf.NOSELECT = 0x0001;258 mf.SINGLESELECT = 0x0002;259 mf.MULTISELECT = 0x0004;260 mf.NO_SELECT_QTY = 0x0008;261 mf.ANYPRINTABLE = 0x0010;262 mf.SELECT_BY_PAGE = 0x0020;263 mf.ALWAYS_SHOW_MORE = 0x0040;264 mf.NOWRAP = 0x0080;265 mf.ALLOW_FILTER = 0x0100;266 mf.ALLOW_FORMATTING = 0x0200;267 mf.SHOW_PAGENUMBERS = 0x0400;...
format.ts
Source:format.ts
1import { SamplerFormatKind } from './interfaces';2export enum FormatTypeFlags {3 U8 = 0x01,4 U16,5 U32,6 S8,7 S16,8 S32,9 F16,10 F32,11 // Compressed texture formats.12 BC1 = 0x41,13 BC2,14 BC3,15 BC4_UNORM,16 BC4_SNORM,17 BC5_UNORM,18 BC5_SNORM,19 // Special-case packed texture formats.20 U16_PACKED_5551 = 0x61,21 // Depth/stencil texture formats.22 D24 = 0x81,23 D32F,24 D24S8,25 D32FS8,26}27export enum FormatCompFlags {28 R = 0x01,29 RG = 0x02,30 RGB = 0x03,31 RGBA = 0x04,32 A = 0x05,33}34export function getFormatCompFlagsComponentCount(n: FormatCompFlags): number {35 // The number of components is the flag value. Easy.36 return n;37}38export enum FormatFlags {39 None = 0b00000000,40 Normalized = 0b00000001,41 sRGB = 0b00000010,42 Depth = 0b00000100,43 Stencil = 0b00001000,44 RenderTarget = 0b00010000,45}46export function makeFormat(47 type: FormatTypeFlags,48 comp: FormatCompFlags,49 flags: FormatFlags,50): Format {51 return (type << 16) | (comp << 8) | flags;52}53export enum Format {54 ALPHA = makeFormat(FormatTypeFlags.U8, FormatCompFlags.A, FormatFlags.None),55 F16_R = makeFormat(FormatTypeFlags.F16, FormatCompFlags.R, FormatFlags.None),56 F16_RG = makeFormat(FormatTypeFlags.F16, FormatCompFlags.RG, FormatFlags.None),57 F16_RGB = makeFormat(FormatTypeFlags.F16, FormatCompFlags.RGB, FormatFlags.None),58 F16_RGBA = makeFormat(FormatTypeFlags.F16, FormatCompFlags.RGBA, FormatFlags.None),59 F32_R = makeFormat(FormatTypeFlags.F32, FormatCompFlags.R, FormatFlags.None),60 F32_RG = makeFormat(FormatTypeFlags.F32, FormatCompFlags.RG, FormatFlags.None),61 F32_RGB = makeFormat(FormatTypeFlags.F32, FormatCompFlags.RGB, FormatFlags.None),62 F32_RGBA = makeFormat(FormatTypeFlags.F32, FormatCompFlags.RGBA, FormatFlags.None),63 U8_R = makeFormat(FormatTypeFlags.U8, FormatCompFlags.R, FormatFlags.None),64 U8_R_NORM = makeFormat(FormatTypeFlags.U8, FormatCompFlags.R, FormatFlags.Normalized),65 U8_RG = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RG, FormatFlags.None),66 U8_RG_NORM = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RG, FormatFlags.Normalized),67 U8_RGB = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RGB, FormatFlags.None),68 U8_RGB_NORM = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RGB, FormatFlags.Normalized),69 U8_RGB_SRGB = makeFormat(70 FormatTypeFlags.U8,71 FormatCompFlags.RGB,72 FormatFlags.sRGB | FormatFlags.Normalized,73 ),74 U8_RGBA = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RGBA, FormatFlags.None),75 U8_RGBA_NORM = makeFormat(FormatTypeFlags.U8, FormatCompFlags.RGBA, FormatFlags.Normalized),76 U8_RGBA_SRGB = makeFormat(77 FormatTypeFlags.U8,78 FormatCompFlags.RGBA,79 FormatFlags.sRGB | FormatFlags.Normalized,80 ),81 U16_R = makeFormat(FormatTypeFlags.U16, FormatCompFlags.R, FormatFlags.None),82 U16_R_NORM = makeFormat(FormatTypeFlags.U16, FormatCompFlags.R, FormatFlags.Normalized),83 U16_RG_NORM = makeFormat(FormatTypeFlags.U16, FormatCompFlags.RG, FormatFlags.Normalized),84 U16_RGBA_NORM = makeFormat(FormatTypeFlags.U16, FormatCompFlags.RGBA, FormatFlags.Normalized),85 U16_RGB = makeFormat(FormatTypeFlags.U16, FormatCompFlags.RGB, FormatFlags.None),86 U32_R = makeFormat(FormatTypeFlags.U32, FormatCompFlags.R, FormatFlags.None),87 U32_RG = makeFormat(FormatTypeFlags.U32, FormatCompFlags.RG, FormatFlags.None),88 S8_R = makeFormat(FormatTypeFlags.S8, FormatCompFlags.R, FormatFlags.None),89 S8_R_NORM = makeFormat(FormatTypeFlags.S8, FormatCompFlags.R, FormatFlags.Normalized),90 S8_RG_NORM = makeFormat(FormatTypeFlags.S8, FormatCompFlags.RG, FormatFlags.Normalized),91 S8_RGB_NORM = makeFormat(FormatTypeFlags.S8, FormatCompFlags.RGB, FormatFlags.Normalized),92 S8_RGBA_NORM = makeFormat(FormatTypeFlags.S8, FormatCompFlags.RGBA, FormatFlags.Normalized),93 S16_R = makeFormat(FormatTypeFlags.S16, FormatCompFlags.R, FormatFlags.None),94 S16_RG = makeFormat(FormatTypeFlags.S16, FormatCompFlags.RG, FormatFlags.None),95 S16_RG_NORM = makeFormat(FormatTypeFlags.S16, FormatCompFlags.RG, FormatFlags.Normalized),96 S16_RGB_NORM = makeFormat(FormatTypeFlags.S16, FormatCompFlags.RGB, FormatFlags.Normalized),97 S16_RGBA = makeFormat(FormatTypeFlags.S16, FormatCompFlags.RGBA, FormatFlags.None),98 S16_RGBA_NORM = makeFormat(FormatTypeFlags.S16, FormatCompFlags.RGBA, FormatFlags.Normalized),99 S32_R = makeFormat(FormatTypeFlags.S32, FormatCompFlags.R, FormatFlags.None),100 // Packed texture formats.101 U16_RGBA_5551 = makeFormat(102 FormatTypeFlags.U16_PACKED_5551,103 FormatCompFlags.RGBA,104 FormatFlags.Normalized,105 ),106 // Compressed107 BC1 = makeFormat(FormatTypeFlags.BC1, FormatCompFlags.RGBA, FormatFlags.Normalized),108 BC1_SRGB = makeFormat(109 FormatTypeFlags.BC1,110 FormatCompFlags.RGBA,111 FormatFlags.Normalized | FormatFlags.sRGB,112 ),113 BC2 = makeFormat(FormatTypeFlags.BC2, FormatCompFlags.RGBA, FormatFlags.Normalized),114 BC2_SRGB = makeFormat(115 FormatTypeFlags.BC2,116 FormatCompFlags.RGBA,117 FormatFlags.Normalized | FormatFlags.sRGB,118 ),119 BC3 = makeFormat(FormatTypeFlags.BC3, FormatCompFlags.RGBA, FormatFlags.Normalized),120 BC3_SRGB = makeFormat(121 FormatTypeFlags.BC3,122 FormatCompFlags.RGBA,123 FormatFlags.Normalized | FormatFlags.sRGB,124 ),125 BC4_UNORM = makeFormat(FormatTypeFlags.BC4_UNORM, FormatCompFlags.R, FormatFlags.Normalized),126 BC4_SNORM = makeFormat(FormatTypeFlags.BC4_SNORM, FormatCompFlags.R, FormatFlags.Normalized),127 BC5_UNORM = makeFormat(FormatTypeFlags.BC5_UNORM, FormatCompFlags.RG, FormatFlags.Normalized),128 BC5_SNORM = makeFormat(FormatTypeFlags.BC5_SNORM, FormatCompFlags.RG, FormatFlags.Normalized),129 // Depth/Stencil130 D24 = makeFormat(FormatTypeFlags.D24, FormatCompFlags.R, FormatFlags.Depth),131 D24_S8 = makeFormat(132 FormatTypeFlags.D24S8,133 FormatCompFlags.RG,134 FormatFlags.Depth | FormatFlags.Stencil,135 ),136 D32F = makeFormat(FormatTypeFlags.D32F, FormatCompFlags.R, FormatFlags.Depth),137 D32F_S8 = makeFormat(138 FormatTypeFlags.D32FS8,139 FormatCompFlags.RG,140 FormatFlags.Depth | FormatFlags.Stencil,141 ),142 // Special RT formats for preferred backend support.143 U8_RGB_RT = makeFormat(144 FormatTypeFlags.U8,145 FormatCompFlags.RGB,146 FormatFlags.RenderTarget | FormatFlags.Normalized,147 ),148 U8_RGBA_RT = makeFormat(149 FormatTypeFlags.U8,150 FormatCompFlags.RGBA,151 FormatFlags.RenderTarget | FormatFlags.Normalized,152 ),153 U8_RGBA_RT_SRGB = makeFormat(154 FormatTypeFlags.U8,155 FormatCompFlags.RGBA,156 FormatFlags.RenderTarget | FormatFlags.Normalized | FormatFlags.sRGB,157 ),158}159export function getFormatCompFlags(fmt: Format): FormatCompFlags {160 return (fmt >>> 8) & 0xff;161}162export function getFormatTypeFlags(fmt: Format): FormatTypeFlags {163 return (fmt >>> 16) & 0xff;164}165export function getFormatFlags(fmt: Format): FormatFlags {166 return fmt & 0xff;167}168export function getFormatTypeFlagsByteSize(typeFlags: FormatTypeFlags): 1 | 2 | 4 {169 switch (typeFlags) {170 case FormatTypeFlags.F32:171 case FormatTypeFlags.U32:172 case FormatTypeFlags.S32:173 return 4;174 case FormatTypeFlags.U16:175 case FormatTypeFlags.S16:176 case FormatTypeFlags.F16:177 return 2;178 case FormatTypeFlags.U8:179 case FormatTypeFlags.S8:180 return 1;181 default:182 throw new Error('whoops');183 }184}185/**186 * Gets the byte size for an individual component.187 * e.g. for F32_RGB, this will return "4", since F32 has 4 bytes.188 */189export function getFormatCompByteSize(fmt: Format): 1 | 2 | 4 {190 return getFormatTypeFlagsByteSize(getFormatTypeFlags(fmt));191}192export function getFormatComponentCount(fmt: Format): number {193 return getFormatCompFlagsComponentCount(getFormatCompFlags(fmt));194}195export function getFormatByteSize(fmt: Format): number {196 const typeByteSize = getFormatTypeFlagsByteSize(getFormatTypeFlags(fmt));197 const componentCount = getFormatCompFlagsComponentCount(getFormatCompFlags(fmt));198 return typeByteSize * componentCount;199}200export function setFormatFlags(fmt: Format, flags: FormatFlags): Format {201 return (fmt & 0xffffff00) | flags;202}203export function setFormatComponentCount(fmt: Format, compFlags: FormatCompFlags): Format {204 return (fmt & 0xffff00ff) | (compFlags << 8);205}206export function getFormatSamplerKind(fmt: Format): SamplerFormatKind {207 const flags = getFormatFlags(fmt);208 if (!!(flags & FormatFlags.Depth)) {209 return SamplerFormatKind.Depth;210 }211 if (!!(flags & FormatFlags.Normalized)) {212 return SamplerFormatKind.Float;213 }214 const typeFlags = getFormatTypeFlags(fmt);215 if (typeFlags === FormatTypeFlags.F16 || typeFlags === FormatTypeFlags.F32) {216 return SamplerFormatKind.Float;217 } else if (218 typeFlags === FormatTypeFlags.U8 ||219 typeFlags === FormatTypeFlags.U16 ||220 typeFlags === FormatTypeFlags.U32221 ) {222 return SamplerFormatKind.Uint;223 } else if (224 typeFlags === FormatTypeFlags.S8 ||225 typeFlags === FormatTypeFlags.S16 ||226 typeFlags === FormatTypeFlags.S32227 ) {228 return SamplerFormatKind.Sint;229 } else {230 throw new Error('whoops');231 }...
admin-change-country.js
Source:admin-change-country.js
1const init_admin_change_country = function() {2 const $ = jQuery;3 if(typeof weglot_css !== "undefined"){4 $("#weglot-css-flag-css").text(weglot_css.flag_css);5 }6 function refresh_flag_css() {7 var en_flags = new Array();8 var es_flags = new Array();9 var fr_flags = new Array();10 var ar_flags = new Array();11 var tw_flags = new Array();12 var zh_flags = new Array();13 en_flags[1] = [3570, 7841, 48, 2712];14 en_flags[2] = [3720, 449, 3048, 4440];15 en_flags[3] = [3840, 1281, 2712, 4224];16 en_flags[4] = [3240, 5217, 1224, 2112];17 en_flags[5] = [4050, 3585, 1944, 2496];18 en_flags[6] = [2340, 3457, 2016, 2016];19 es_flags[1] = [4320, 4641, 3144, 3552];20 es_flags[2] = [3750, 353, 2880, 4656];21 es_flags[3] = [4200, 1601, 2568, 3192];22 es_flags[4] = [3990, 5793, 1032, 2232];23 es_flags[5] = [5460, 897, 4104, 3120];24 es_flags[6] = [3810, 7905, 216, 3888];25 es_flags[7] = [3630, 8065, 192, 2376];26 es_flags[8] = [3780, 1473, 2496, 4104];27 es_flags[9] = [6120, 2145, 4680, 2568];28 es_flags[10] = [4440, 3009, 3240, 1176];29 es_flags[11] = [5280, 1825, 3936, 2976];30 es_flags[12] = [4770, 2081, 3624, 1008];31 es_flags[13] = [4080, 3201, 2160, 2544];32 es_flags[14] = [4590, 5761, 3432, 624];33 es_flags[15] = [4350, 2209, 3360, 2688];34 es_flags[16] = [5610, 5249, 3168, 528];35 es_flags[17] = [5070, 1729, 3792, 2952];36 es_flags[18] = [6870, 5953, 96, 3408];37 es_flags[19] = [4020, 5697, 1056, 1224];38 fr_flags[1] = [2760, 736, 2856, 4416];39 fr_flags[2] = [3840, 1280, 2712, 4224];40 fr_flags[3] = [5700, 7201, 5016, 2400];41 fr_flags[4] = [2220, 4160, 1632, 1944];42 ar_flags[1] = [1830, 129, 3096, 5664];43 ar_flags[2] = [5100, 2177, 3840, 2904];44 ar_flags[3] = [4890, 3425, 3648, 2136];45 ar_flags[4] = [1320, 3681, 1896, 4080];46 ar_flags[5] = [1260, 3841, 1824, 1200];47 ar_flags[6] = [1020, 3969, 1608, 312];48 ar_flags[7] = [4800, 4065, 3600, 72];49 ar_flags[8] = [4710, 4865, 3504, 480];50 ar_flags[9] = [6720, 5984, 5112, 3792];51 ar_flags[10] = [4500, 7233, 3288, 1800];52 ar_flags[11] = [720, 7522, 384, 3936];53 ar_flags[12] = [690, 7745, 336, 1104];54 ar_flags[13] = [600, 8225, 120, 1272];55 ar_flags[14] = [660, 5569, 840, 576];56 tw_flags[1] = [3690, 1505, 2592, 3240]; // China57 tw_flags[2] = [3600, 3233, 2112, 48]; // Hong Kong58 zh_flags[1] = [2970, 6369, 3408, 4008]; // Taiwan59 zh_flags[2] = [3600, 3233, 2112, 48]; // Hong Kong60 var enval = $("select.flag-en-type").val();61 var esval = $("select.flag-es-type").val();62 var frval = $("select.flag-fr-type").val();63 var arval = $("select.flag-ar-type").val();64 var twval = $("select.flag-tw-type").val();65 var zhval = $("select.flag-zh-type").val();66 var en_style = enval <= 0 ? "" : ".weglot-flags.en > a:before, .weglot-flags.en > span:before { background-position: -" + en_flags[enval][0] + "px 0 !important; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -" + en_flags[enval][1] + "px 0 !important; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -" + en_flags[enval][2] + "px 0 !important; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -" + en_flags[enval][3] + "px 0 !important; } ";67 var es_style = esval <= 0 ? "" : ".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -" + es_flags[esval][0] + "px 0 !important; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -" + es_flags[esval][1] + "px 0 !important; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -" + es_flags[esval][2] + "px 0 !important; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -" + es_flags[esval][3] + "px 0 !important; } ";68 var fr_style = frval <= 0 ? "" : ".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -" + fr_flags[frval][0] + "px 0 !important; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -" + fr_flags[frval][1] + "px 0 !important; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -" + fr_flags[frval][2] + "px 0 !important; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -" + fr_flags[frval][3] + "px 0 !important; } ";69 var ar_style = arval <= 0 ? "" : ".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -" + ar_flags[arval][0] + "px 0 !important; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -" + ar_flags[arval][1] + "px 0 !important; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -" + ar_flags[arval][2] + "px 0 !important; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -" + ar_flags[arval][3] + "px 0 !important; } ";70 var tw_style = twval <= 0 ? "" : ".weglot-flags.tw > a:before, .weglot-flags.tw > span:before { background-position: -" + tw_flags[twval][0] + "px 0 !important; } .weglot-flags.flag-1.tw > a:before, .weglot-flags.flag-1.tw > span:before { background-position: -" + tw_flags[twval][1] + "px 0 !important; } .weglot-flags.flag-2.tw > a:before, .weglot-flags.flag-2.tw > span:before { background-position: -" + tw_flags[twval][2] + "px 0 !important; } .weglot-flags.flag-3.tw > a:before, .weglot-flags.flag-3.tw > span:before { background-position: -" + tw_flags[twval][3] + "px 0 !important; } ";71 var zh_style = zhval <= 0 ? "" : ".weglot-flags.zh > a:before, .weglot-flags.zh > span:before { background-position: -" + zh_flags[zhval][0] + "px 0 !important; } .weglot-flags.flag-1.zh > a:before, .weglot-flags.flag-1.zh > span:before { background-position: -" + zh_flags[zhval][1] + "px 0 !important; } .weglot-flags.flag-2.zh > a:before, .weglot-flags.flag-2.zh > span:before { background-position: -" + zh_flags[zhval][2] + "px 0 !important; } .weglot-flags.flag-3.zh > a:before, .weglot-flags.flag-3.zh > span:before { background-position: -" + zh_flags[zhval][3] + "px 0 !important; } ";72 $("#flag_css, #weglot-css-flag-css").text(en_style + es_style + fr_style + ar_style + tw_style + zh_style);73 }74 const execute = () => {75 $('.flag-style-openclose').on('click',76 function () {77 $('.flag-style-wrapper').toggle();78 }79 );80 $("select.flag-en-type, select.flag-es-type, select.flag-fr-type, select.flag-ar-type, select.flag-tw-type, select.flag-zh-type").on('change',81 function () {82 refresh_flag_css()83 }84 );85 var flag_css = $("#flag_css").text();86 if (flag_css.trim()) {87 $("#weglot-css-flag-css").text(flag_css);88 }89 };90 document.addEventListener("DOMContentLoaded", () => {91 execute();92 });93};...
tests.js
Source:tests.js
...13 } catch (e) { /**/ }14 return null;15};16module.exports = function runTests(flags, t) {17 t.equal(flags(/a/g), 'g', 'flags(/a/g) !== "g"');18 t.equal(flags(/a/gmi), 'gim', 'flags(/a/gmi) !== "gim"');19 t.equal(flags(new RegExp('a', 'gmi')), 'gim', 'flags(new RegExp("a", "gmi")) !== "gim"');20 t.equal(flags(/a/), '', 'flags(/a/) !== ""');21 t.equal(flags(new RegExp('a')), '', 'flags(new RegExp("a")) !== ""');22 forEach(availableFlags, function (flag) {23 var property = regexProperties[flag];24 t.test(property + ' flag', function (st) {25 st.equal(flags(getRegexLiteral('/a/' + flag)), flag, 'flags(/a/' + flag + ') !== ' + inspect(flag));26 st.equal(flags(new RegExp('a', flag)), flag, 'flags(new RegExp("a", ' + inspect(flag) + ')) !== ' + inspect(flag));27 st.end();28 });29 });30 t.test('sorting', function (st) {31 st.equal(flags(/a/gim), 'gim', 'flags(/a/gim) !== "gim"');32 st.equal(flags(/a/mig), 'gim', 'flags(/a/mig) !== "gim"');33 st.equal(flags(/a/mgi), 'gim', 'flags(/a/mgi) !== "gim"');34 if (has(RegExp.prototype, 'sticky')) {35 st.equal(flags(getRegexLiteral('/a/gyim')), 'gimy', 'flags(/a/gyim) !== "gimy"');36 }37 if (has(RegExp.prototype, 'unicode')) {38 st.equal(flags(getRegexLiteral('/a/ugmi')), 'gimu', 'flags(/a/ugmi) !== "gimu"');39 }40 if (has(RegExp.prototype, 'dotAll')) {41 st.equal(flags(getRegexLiteral('/a/sgmi')), 'gims', 'flags(/a/sgmi) !== "gims"');42 }43 var randomFlags = availableFlags.slice().sort(function () { return Math.random() > 0.5 ? 1 : -1; }).join('');44 st.equal(45 flags(getRegexLiteral('/a/' + randomFlags)),46 sortedFlags,47 'random: flags(/a/' + randomFlags + ') === ' + inspect(sortedFlags)48 );49 st.end();50 });51 t.test('basic examples', function (st) {52 st.equal(flags(/a/g), 'g', '(/a/g).flags !== "g"');53 st.equal(flags(/a/gmi), 'gim', '(/a/gmi).flags !== "gim"');54 st.equal(flags(new RegExp('a', 'gmi')), 'gim', 'new RegExp("a", "gmi").flags !== "gim"');55 st.equal(flags(/a/), '', '(/a/).flags !== ""');56 st.equal(flags(new RegExp('a')), '', 'new RegExp("a").flags !== ""');57 st.end();58 });59 t.test('generic flags', function (st) {60 st.equal(flags({}), '');61 st.equal(flags({ ignoreCase: true }), 'i');62 st.equal(flags({ dotAll: 1, global: 0, sticky: 1, unicode: 1 }), 'suy');63 st.equal(flags({ __proto__: { multiline: true } }), 'm');64 var obj = {};65 forEach(availableFlags, function (flag) {66 obj[regexProperties[flag]] = true;67 });68 st.equal(flags(obj), sortedFlags, 'an object with every available flag: ' + sortedFlags);69 st.end();70 });71 t.test('throws properly', function (st) {72 var nonObjects = ['', false, true, 42, NaN, null, undefined];73 st.plan(nonObjects.length);74 var throwsOnNonObject = function (nonObject) {75 st['throws'](flags.bind(null, nonObject), TypeError, inspect(nonObject) + ' is not an Object');76 };77 nonObjects.forEach(throwsOnNonObject);78 });79 t.test('getters', { skip: !supportsDescriptors }, function (st) {80 /* eslint getter-return: 0 */81 var calls = '';82 var re = {};83 Object.defineProperty(re, 'hasIndices', {84 get: function () {85 calls += 'd';86 }87 });88 Object.defineProperty(re, 'global', {89 get: function () {90 calls += 'g';91 }92 });93 Object.defineProperty(re, 'ignoreCase', {94 get: function () {95 calls += 'i';96 }97 });98 Object.defineProperty(re, 'multiline', {99 get: function () {100 calls += 'm';101 }102 });103 Object.defineProperty(re, 'dotAll', {104 get: function () {105 calls += 's';106 }107 });108 Object.defineProperty(re, 'unicode', {109 get: function () {110 calls += 'u';111 }112 });113 Object.defineProperty(re, 'sticky', {114 get: function () {115 calls += 'y';116 }117 });118 flags(re);119 st.equal(calls, 'dgimsuy', 'getters are called in expected order');120 st.end();121 });...
Using AI Code Generation
1import { flags } from 'storybook-root';2const { flags } = require('storybook-root');3const flags = require('storybook-root').flags;4const flags = require('storybook-root/flags');5const flags = require('storybook-root').default.flags;6const flags = require('storybook-root').default;7const flags = require('storybook-root').flags;8const flags = require('storybook-root/flags');9const flags = require('storybook-root').default.flags;10const flags = require('storybook-root').default;11const flags = require('storybook-root').flags;12const flags = require('storybook-root/flags');13const flags = require('storybook-root').default.flags;14const flags = require('storybook-root').default;15const flags = require('storybook-root').flags;16const flags = require('storybook-root/flags');17const flags = require('storybook-root').default.flags;18const flags = require('storybook-root').default;19const flags = require('storybook-root').flags;20const flags = require('storybook-root/flags');21const flags = require('storybook-root').default.flags;22const flags = require('storybook-root').default;23const flags = require('storybook-root').flags;24const flags = require('storybook-root/flags');
Using AI Code Generation
1import { flags } from "storybook-root";2import { flags } from "storybook-root";3import { flags } from "storybook-root";4import { flags } from "storybook-root";5import { flags } from "storybook-root";6import { flags } from "storybook-root";7import { flags } from "storybook-root";8import { flags } from "storybook-root";9import { flags } from "storybook-root";10import { flags } from "storybook-root";11import { flags } from "storybook-root";12import { flags } from "storybook-root";13import { flags } from "storybook-root";14import { flags } from "storybook-root";
Using AI Code Generation
1import { flags } from '@storybook/addons';2import { flags } from '@storybook/addons';3import { flags } from '@storybook/addons';4import { flags } from '@storybook/addons';5import { flags } from '@storybook/addons';6import { flags } from '@storybook/addons';7import { flags } from '@storybook/addons';8import { flags } from '@storybook/addons';9import { flags } from '@storybook/addons';10import { flags } from '@storybook/addons';11import { flags } from '@storybook/addons';12import { flags } from '@storybook/addons';
Using AI Code Generation
1import { flags } from '@storybook/addons';2const { setOptions } = flags;3setOptions({4});5import { flags } from '@storybook/addons';6const { setOptions } = flags;7setOptions({8});
Using AI Code Generation
1import { flags } from 'storybook-root';2flags.set({3});4import { flags } from 'storybook-root';5const MyComponent = () => {6 return (7 {flags.get('isFeatureEnabled') && <p>Feature is enabled</p>}8 {flags.get('isOtherFeatureEnabled') && <p>Other Feature is enabled</p>}9 {flags.get('isThirdFeatureEnabled') && <p>Third Feature is enabled</p>}10 );11};12export default MyComponent;13import { flags } from 'storybook-root';14describe('MyComponent', () => {15 it('renders the feature component when feature is enabled', () => {16 flags.set({ isFeatureEnabled: true });17 const wrapper = shallow(<MyComponent />);18 expect(wrapper.find('p').text()).toEqual('Feature is enabled');19 });20 it('renders the other feature component when other feature is enabled', () => {21 flags.set({ isOtherFeatureEnabled: true });22 const wrapper = shallow(<MyComponent />);23 expect(wrapper.find('p').text()).toEqual('Other Feature is enabled');24 });25 it('renders the third feature component when third feature is enabled', () => {26 flags.set({ isThirdFeatureEnabled: true });27 const wrapper = shallow(<MyComponent />);28 expect(wrapper.find('p').text()).toEqual('Third Feature is enabled');29 });30});31import { flags } from 'storybook-root';32storiesOf('MyComponent', module)33 .add('feature enabled', () => {34 flags.set({ isFeatureEnabled: true });35 return <MyComponent />;36 })37 .add('other feature enabled', () => {38 flags.set({ isOtherFeatureEnabled: true });39 return <MyComponent />;40 })41 .add('third feature enabled', () => {42 flags.set({ isThirdFeatureEnabled: true });43 return <MyComponent />;44 });
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!!