From: Aleksander Ɓukasz Date: Thu, 24 Oct 2013 08:27:32 +0000 (+0200) Subject: smartxml: node.setAttr tests X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/2f3c62f37144eb3878382f9cc655848965faea02?ds=sidebyside smartxml: node.setAttr tests --- diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 10610c4..2ccfa6d 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -133,6 +133,27 @@ describe('smartxml', function() { }); }); + describe('Setting node attributes', function() { + it('can set node attribute', function() { + var node = elementNodeFromXML('
'); + + node.setAttr('key', 'value'); + expect(node.getAttr('key')).to.equal('value'); + }); + it('emits nodeAttrChange event', function() { + var node = elementNodeFromXML('
'), + spy = sinon.spy(); + + node.document.on('change', spy); + node.setAttr('key', 'value2'); + var event = spy.args[0][0]; + + expect(event.type).to.equal('nodeAttrChange'); + expect(event.meta.node.sameNode(node)).to.be.true; + expect(event.meta.attr).to.equal('key'); + expect(event.meta.oldVal).to.equal('value1'); + }); + }); }); });