{"_id":"@dom-free/dom-free","_rev":"1-c0d32f6ad2b60310f821da94971bc456","name":"@dom-free/dom-free","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@dom-free/dom-free","version":"1.0.0","description":"I have been an agilista and evangelist for unit testing for many years.\r However, along with others, I have considered JavaScript testing somewhat of a lost cause.\r We have seen advancements in framework unit testing, but much of the JavaScript in the wil","type":"module","scripts":{"test":"jasmine","clean":"rm -rf ./lib","build":"npm run clean && npm run build:esm && npm run build:cjs","build:esm":"tsc -p ./tsconfig.esm.json && mv lib/esm/sms.js lib/esm/sms.mjs","build:cjs":"tsc -p ./tsconfig.cjs.json","prepack":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/infoAtDomFree/dom-free.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/infoAtDomFree/dom-free/issues"},"homepage":"https://github.com/infoAtDomFree/dom-free#readme","dependencies":{"jasmine":"^4.5.0","jquery":"^3.6.3"},"types":"./lib/cjs/types/index.d.ts","main":"./lib/cjs/index.js","exports":{".":{"import":{"types":"./lib/esm/types/index.d.ts","default":"./lib/esm/index.mjs"},"require":{"types":"./lib/cjs/types/index.d.ts","default":"./lib/cjs/index.js"}}},"devDependencies":{"@types/jquery":"^3.5.14"},"gitHead":"9615b89e370ada02e13499701a727af8e4e4417c","_id":"@dom-free/dom-free@1.0.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-3JEm1FrdeKfodfMczIy6Pp/+GhN4FpudUq/PaKJuU7sX7QYM4Lg82f12mL60gP4xUXTA1YArk+xYkDqMd5LVnw==","shasum":"2a329011b5de1aef1d1b2c2a4ff48448845b8190","tarball":"https://registry.npmjs.org/@dom-free/dom-free/-/dom-free-1.0.0.tgz","fileCount":8,"unpackedSize":32199,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAjas9uPS4i9ZE7QMFYoU4fZT4E1HpTH/CHy7DTex46GAiEA2QY/Bo4fcHmUIdNjYnXa3/5EP4Vc9G0xl4aBPU6fUHQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjqw8ZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo4qQ/+Iqg4cX2BBHsXhwiTZ34dz8B878MfY+C0qQ4AsofiOSJM6iSV\r\nnBdzeKhlRQL2LBNA1/EE6tloHbNDcKpPhrp41tIMo/Ua1IBQEZkm+PQUS/Oj\r\n7vdNOBhwR06UFZvd1EdGYhZmp2e0Kwe4DDdRam43t5jd4XZYXhiEnXeLGEMP\r\nFfwQA9/Yhm9CZOWNsp23PkF+oXK4Mn4eG0fV15LCLPj5yijmZYn/YEHCoSEx\r\no+6+hMQh5Va8fqBCPni80IdeTTZfU1H5894SwZAjV6yCcmEY5ZHgq4YPMGcr\r\nWYIReT3E4K7uGhaJKwPVEh26YSi63JoS+nu1Q3UTO2tVZ28cT3XQaKAfJVd4\r\nXfWMsXU/oIR+WcTQuSvLBigazHMdlBM7i4qLURKGmA0+4I6MOEexZ+VyAgNR\r\n9FI09icoIa/rInh8HF4NQWda41Ua+h23pU3K3uyo27yu9x555SgZywdMx49f\r\nhZ8K6mIjJUST5jCHI2i+HdvQHwHrekWglzUG6a/4NgpKHqJzJpLy/GsdogxF\r\nLOMEDHwmzqXTm7aLEeJvK8AQWnBvVOFz3DNL1AP1kLJBLqGLfPgtwcq8S87g\r\nucJ9F73Fsrs0l+Vvk1sApk+yj7vkC9zwrelRn9SL2n6kfwLPYXxlQpRi+f5A\r\nP+OhL3OZfDHcMRr1H8ISNl1Pgrn9zOq7xBc=\r\n=Ii1X\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dom-free","email":"info@dom-free.org"},"directories":{},"maintainers":[{"name":"dom-free","email":"info@dom-free.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dom-free_1.0.0_1672154905376_0.7423561128745915"},"_hasShrinkwrap":false},"1.0.1":{"name":"@dom-free/dom-free","version":"1.0.1","description":"I have been an agilista and evangelist for unit testing for many years.\r However, along with others, I have considered JavaScript testing somewhat of a lost cause.\r We have seen advancements in framework unit testing, but much of the JavaScript in the wil","type":"module","scripts":{"test":"jasmine","clean":"rm -rf ./lib","build":"npm run clean && npm run build:esm && npm run build:cjs","build:esm":"tsc -p ./tsconfig.esm.json && mv lib/esm/sms.js lib/esm/sms.mjs","build:cjs":"tsc -p ./tsconfig.cjs.json","prepack":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/infoAtDomFree/dom-free.git"},"author":"","license":"ISC","bugs":{"url":"https://github.com/infoAtDomFree/dom-free/issues"},"homepage":"https://github.com/infoAtDomFree/dom-free#readme","dependencies":{"jasmine":"^4.5.0","jquery":"^3.6.3"},"types":"./lib/cjs/types/index.d.ts","main":"./lib/cjs/index.js","exports":{".":{"import":{"types":"./lib/esm/types/index.d.ts","default":"./lib/esm/index.mjs"},"require":{"types":"./lib/cjs/types/index.d.ts","default":"./lib/cjs/index.js"}}},"devDependencies":{"@types/jquery":"^3.5.14"},"gitHead":"a755b29f50d6ea26f00b9d4dda5d3276f1085fc2","_id":"@dom-free/dom-free@1.0.1","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-0B4aKTiSBBxCDIhRWSFlYN0H8hI+MFtaV2acLcOdGbZgCJdQ4jDhcmCtgjqsEIb3LbWi4nIr+U3wtu4sv9XWzw==","shasum":"387a0f25cde33283c1f84062b98c85dfac8052c1","tarball":"https://registry.npmjs.org/@dom-free/dom-free/-/dom-free-1.0.1.tgz","fileCount":8,"unpackedSize":34312,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqQtqTI9LmSNfq7fXQoQGe1s2ukgHfRwfPz0hjTPGZMQIhALw+WoEeTrs+EH3vKRRMhYImRzO1vw4vUNf3XtICKne8"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjsx23ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrrNxAAnKR+YKqQeVPNsp+dwVOMoJPDRavSZFpQLX/eu2XdIPWDY9Qv\r\nGcjjoNvYNbZoxcipJxYeL6jjipQs1cdNiMI4+84xIzH72eTDSgjA/89TG+bm\r\nySalJGV9nfINvKrC4YjTCRDprGr7oOxlZXfRvHkLBgaMrZ0wIhH61i62bVfx\r\nYxE+gAbSPDLSHXlViqBKt4Cyk6Yq0iklhU004T7dOejpWACx21dCBJzW1w9I\r\nftvzdVJAfXB89VjZinGpH5RA5g7Guep3LAB3lUBmIxlHUBLBix4+cShSP7wj\r\nqZVPGKajeIPHvhGVTM7RBvvLIg4RUkCX9b2eFv0m/VlHNANYRdJ+F+ZjdUJQ\r\nxLpPusVaNCL6NeqqyZSEDjSMWrCDM8kTDfmyRmr7tp5R16Be9izt4px0aAqc\r\ndtfsMitt6UIBa70+kuoFWT180ZeOQiXRNBUIdRffOvfhbcWrFvLEzSFKkBq6\r\nt//HGw45OrEu937ExpUMmKyUok8yqM5pIFTp7x9Ke1JqlxaQmzMfJQJqBDIg\r\n4IcsjIDVHA55W16lJqQQMhF9JLXf/5ACSPsZZekmceApZEALC7zB/YXKX/w/\r\n1ta5lTSSIjr1uFIUGiG0ASMv4m6BC7qbNZJbrjTzDNoHDTvX3zDLfQuZ3cWs\r\nlT49Xo4JRNqPVqjAH4aqX9K0TNKo6vg4vdE=\r\n=PHnX\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dom-free","email":"info@dom-free.org"},"directories":{},"maintainers":[{"name":"dom-free","email":"info@dom-free.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dom-free_1.0.1_1672682935373_0.8402152008959769"},"_hasShrinkwrap":false}},"time":{"created":"2022-12-27T15:28:25.329Z","1.0.0":"2022-12-27T15:28:25.562Z","modified":"2023-01-02T18:08:55.625Z","1.0.1":"2023-01-02T18:08:55.544Z"},"maintainers":[{"name":"dom-free","email":"info@dom-free.org"}],"description":"I have been an agilista and evangelist for unit testing for many years.\r However, along with others, I have considered JavaScript testing somewhat of a lost cause.\r We have seen advancements in framework unit testing, but much of the JavaScript in the wil","homepage":"https://github.com/infoAtDomFree/dom-free#readme","repository":{"type":"git","url":"git+https://github.com/infoAtDomFree/dom-free.git"},"bugs":{"url":"https://github.com/infoAtDomFree/dom-free/issues"},"license":"ISC","readme":"# Dom Free\r\n# A state management system for JavaScript that will allow improved testability of client side code\r\n## Why I built this system\r\nI have been an agilista and evangelist for unit testing for many years.\r\nHowever, along with others, I have considered JavaScript testing somewhat of a lost cause.\r\nWe have seen advancements in framework unit testing, but much of the JavaScript in the wild\r\nremains untested, and largely untestable. This is principally because business logic is \r\nintermingled with DOM access code.\r\n\r\nI thought if we could untangle that mess, we could make legitimately testable JavaScript code that operates upon the DOM indirectly. That is why I built this system.\r\n\r\n## How it works\r\n### Browser Code:\r\n![Image](./Browser.png)\r\n\r\nThe JavaScript in your HTML file is simple, and is located in a single script tag as follows\r\n```\r\n<script lang=\"javascript\">\r\n\t$(document).ready(() => {\r\n\t\tsms.Clear();\r\n\t\tsms.Register(\"firstName\", $(\"#fname\"))\r\n            .attr('value', 'George');\r\n\t\tsms.Register(\"lastName\", $(\"#lname\"))\r\n            .attr('value', 'Washington');\r\n\r\n\t\tsms.Register(\"moveFirstToLast\", $(\"#moveFirstToLast\"))\r\n            .registerEvent(\"click\", Library.MoveFirstToLast);\r\n\r\n\t})\r\n</script>\r\n```\r\n\r\nWhen the use clicks the button with id = \"moveFirstToLast,\" the library function Library.MoveFirstToLast is called by SMS. MoveFirstToLast looks like this:\r\n`MoveFirstToLast: () => sms.Item('lastName').val(sms.Item('firstName').val()),`\r\nYou can see that we are using `sms.Item(<elementName>)` both to get the value (of firstName) and assign the value (to lastName).\r\n\r\n## Unit Test Code:\r\n\r\n![Image](./UnitTest.png)\r\n\r\nThe JavaScript in your Unit Test is very similar to the JavaScript in your HTML file (in fact, you can copy and paste). You just need to tell SMS that Mode is \"Mock\" as follows:\r\n\r\n```\r\n\tbeforeEach(function() {\r\n\t\tsms = SMS;\r\n\t\tsms.Clear();\r\n\t\tsms.Mode('Mock');\r\n\t\tlib = Library.default;\r\n\t\t\r\n\t\tfirstName = sms.Register(\"firstName\", \"#fname\")\r\n            .attr('value', 'George');\r\n\t\tlastName = sms.Register(\"lastName\", \"#lname\")\r\n            .attr('value', 'Washington');\r\n\r\n\t\tsms.Register(\"moveFirstToLast\", \"#moveFirstToLast\")\r\n            .registerEvent(\"click\", lib.MoveFirstToLast);\r\n\r\n\t})\r\n```\r\nBecause `sms.Mode('Mock')` has been called, the second parameter to `sms.Register()` is ignored.\r\n\r\nThen, in the unit test, we are able to verify the behavior of the MoveFirstToLast Library function, as follows:\r\n\r\n```\r\nit('should be able to Copy First Name to Last Name when clicked', function() {\r\n\t\tsms.Item('moveFirstToLast')\r\n            .fireEvent('click');\r\n\t\tvar target = sms.Item('lastName');\r\n\t\texpect(target.val())\r\n            .toBe('George')\r\n    });\r\n```\r\nThis test passes, proving the the Library is able to modify the \"DOM\" as required.\r\n\r\nObviously, this is a test that does not prove very much, but in a realistic scenario, the result of a complicated Library function is indeed the changing of one or more DOM elements' values or attributes, which can be verified in unit tests.\r\n\r\n## How to install DOM-FREE\r\n```\r\nnpm install infoAtDomFree/dom-free\r\n```\r\n\r\n## Sample Code\r\nYou can see example code at https://github.com/infoAtDomFree/example","readmeFilename":"README.md"}