From: Aleksander Ɓukasz Date: Thu, 24 Oct 2013 08:27:18 +0000 (+0200) Subject: smartxml: testing emition of the nodeTagChange event X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/87ea9b141e236d41d34885a25c7942ec04d0ec28?ds=sidebyside smartxml: testing emition of the nodeTagChange event --- diff --git a/src/smartxml/smartxml.test.js b/src/smartxml/smartxml.test.js index 86f16de..10610c4 100644 --- a/src/smartxml/smartxml.test.js +++ b/src/smartxml/smartxml.test.js @@ -1,7 +1,8 @@ define([ 'libs/chai', + 'libs/sinon', './smartxml.js' -], function(chai, smartxml) { +], function(chai, sinon, smartxml) { 'use strict'; /*jshint expr:true */ @@ -84,6 +85,19 @@ describe('smartxml', function() { expect(node.getTagName()).to.equal('span'); }); + it('emits nodeTagChange event', function() { + var node = elementNodeFromXML('
'), + spy = sinon.spy(); + + node.document.on('change', spy); + node.setTag('span'); + var event = spy.args[0][0]; + + expect(event.type).to.equal('nodeTagChange'); + expect(event.meta.node.sameNode(node)).to.be.true; + expect(event.meta.oldTagName).to.equal('div'); + }); + describe('Implementation specific expectations', function() { // DOM specifies ElementNode tag as a read-only property, so // changing it in a seamless way is a little bit tricky. For this reason