From 2f3c62f37144eb3878382f9cc655848965faea02 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 24 Oct 2013 10:27:32 +0200 Subject: [PATCH 1/1] smartxml: node.setAttr tests --- src/smartxml/smartxml.test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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'); + }); + }); }); }); -- 2.20.1