Skip to content

Instantly share code, notes, and snippets.

@bkawk
Created June 12, 2017 12:44
Show Gist options
  • Select an option

  • Save bkawk/614b136aa7f9134b55deaad80cb6b7c3 to your computer and use it in GitHub Desktop.

Select an option

Save bkawk/614b136aa7f9134b55deaad80cb6b7c3 to your computer and use it in GitHub Desktop.
Web component testing cheat sheet
<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