Created
June 12, 2017 12:44
-
-
Save bkawk/614b136aa7f9134b55deaad80cb6b7c3 to your computer and use it in GitHub Desktop.
Web component testing cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| suite('caja-sanitizer', function() { | |
| test('testdiv is equal to one', function() { | |
| // Setup | |
| var element = fixture('BasicTestFixture'); | |
| var elementShadowRoot = element.shadowRoot; | |
| // Select Stuff | |
| var div1 = elementShadowRoot.querySelector('#div1'); | |
| var div2 = elementShadowRoot.querySelector('.div2'); | |
| // Test Stuff | |
| assert.equal(div1.innerHTML, div2.innerHTML); | |
| assert.isNotNull(div1.innerHTML); | |
| assert.match(div1, "test match"); | |
| }); | |
| }); | |
| </script> | |
| //https://www.npmjs.com/package/assert-match | |
| //polymer test -p | |
| // With a promise... | |
| test('call direct', function() { | |
| return fixture('callDirect').sanitize("<p>Hello, <b onclick=alert(1337)>World</b>!</p>") | |
| .then(function(res) { | |
| assert.equal(res.data, '<p>Hello, <b>World</b>!</p>'); | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment