{"version":3,"sources":["../test/shape.jsx"],"names":["describe","it","shape","to","equal","TypeError","undefined","NaN","assertPasses","validator","element","propName","assertFails","be","instanceOf","Error","toFixed","func","isRequired","missing","bool","length","number","nope"],"mappings":";;AAAA;;AACA;;AAMA;;AAEA;;AAEA;;;;;;AAEAA,QAAQ,CAAC,OAAD,EAAU,YAAM;AACtBC,EAAAA,EAAE,CAAC,eAAD,EAAkB,YAAM;AACxB,8BAAcC,OAAd,GAAqBC,EAArB,CAAwBC,KAAxB,CAA8B,UAA9B;AACD,GAFC,CAAF;AAIAJ,EAAAA,QAAQ,CAAC,QAAD,EAAW,YAAM;AACvBC,IAAAA,EAAE,CAAC,oCAAD,EAAuC,YAAM;AAC7C,wBAAO;AAAA,eAAM,cAAN;AAAA,OAAP,EAAsBE,EAAtB,UAA+BE,SAA/B;AACA,wBAAO;AAAA,eAAM,aAAMC,SAAN,CAAN;AAAA,OAAP,EAA+BH,EAA/B,UAAwCE,SAAxC;AACA,wBAAO;AAAA,eAAM,aAAM,IAAN,CAAN;AAAA,OAAP,EAA0BF,EAA1B,UAAmCE,SAAnC;AACA,wBAAO;AAAA,eAAM,aAAM,EAAN,CAAN;AAAA,OAAP,EAAwBF,EAAxB,UAAiCE,SAAjC;AACA,wBAAO;AAAA,eAAM,aAAM,EAAN,CAAN;AAAA,OAAP,EAAwBF,EAAxB,UAAiCE,SAAjC;AACA,wBAAO;AAAA,eAAM,aAAM,EAAN,CAAN;AAAA,OAAP,EAAwBF,EAAxB,UAAiCE,SAAjC;AACA,wBAAO;AAAA,eAAM,aAAME,GAAN,CAAN;AAAA,OAAP,EAAyBJ,EAAzB,UAAkCE,SAAlC;AACD,KARC,CAAF;AASD,GAVO,CAAR;AAYAL,EAAAA,QAAQ,CAAC,WAAD,EAAc,YAAM;AAC1BC,IAAAA,EAAE,CAAC,oBAAD,EAAuB,YAAM;AAC7B,gCAAc,aAAM,EAAN,CAAd,GAAyBE,EAAzB,CAA4BC,KAA5B,CAAkC,UAAlC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R;AAuED,CAxFO,CAAR","sourcesContent":["import { expect } from 'chai';\nimport {\n bool,\n func,\n oneOf,\n number,\n} from 'prop-types';\nimport React from 'react';\n\nimport { shape } from '..';\n\nimport callValidator from './_callValidator';\n\ndescribe('shape', () => {\n it('is a function', () => {\n expect(typeof shape).to.equal('function');\n });\n\n describe('errors', () => {\n it('throws if not given a shape object', () => {\n expect(() => shape()).to.throw(TypeError);\n expect(() => shape(undefined)).to.throw(TypeError);\n expect(() => shape(null)).to.throw(TypeError);\n expect(() => shape([])).to.throw(TypeError);\n expect(() => shape('')).to.throw(TypeError);\n expect(() => shape(42)).to.throw(TypeError);\n expect(() => shape(NaN)).to.throw(TypeError);\n });\n });\n\n describe('validator', () => {\n it('returns a function', () => {\n expect(typeof shape({})).to.equal('function');\n });\n\n function assertPasses(validator, element, propName) {\n expect(callValidator(validator, element, propName, '\"shape\" test')).to.equal(null);\n }\n\n function assertFails(validator, element, propName) {\n expect(callValidator(validator, element, propName, '\"shape\" test')).to.be.instanceOf(Error);\n }\n\n it('behaves when nullary', () => {\n const validator = shape({ toFixed: func.isRequired });\n\n assertPasses(validator, (
), 'a');\n assertPasses(validator, (), 'a');\n assertPasses(validator, (), 'a');\n\n assertFails(validator.isRequired, (), 'a');\n assertFails(validator.isRequired, (), 'a');\n assertFails(validator.isRequired, (), 'a');\n });\n\n it('enforces the provided type', () => {\n assertPasses(\n shape({ toFixed: func.isRequired }),\n (),\n 'foo',\n );\n assertFails(\n shape({ missing: bool.isRequired }),\n (),\n 'foo',\n );\n });\n\n it('enforces the provided shape', () => {\n assertPasses(\n shape({\n length: oneOf([2]),\n }),\n (),\n 'foo',\n );\n assertFails(\n shape({\n length: oneOf([2]),\n missing: number.isRequired,\n }),\n (),\n 'foo',\n );\n assertFails(\n shape({\n length: oneOf([1]),\n }),\n (),\n 'foo',\n );\n });\n\n it('skips falsy shape keys', () => {\n assertPasses(\n shape({ toFixed: func.isRequired, missing: null, nope: false }),\n (),\n 'foo',\n );\n });\n });\n});\n"],"file":"shape.js"}