1 define(function(require) {
4 /* globals describe, it */
6 var chai = require('libs/chai'),
7 wlxml = require('wlxml/wlxml');
8 //edumedExtension = require('./edumed.js');
10 var expect = chai.expect;
13 var getDocumentFromXML = function(xml, options) {
14 var doc = wlxml.WLXMLDocumentFromXML(xml, options || {});
15 //doc.registerExtension(edumedExtension);
20 describe('Setting answer', function() {
21 it('sets answer (1)', function() {
22 /* jshint multistr:true */
23 var doc = getDocumentFromXML('\
24 <div class="exercise.order">\
25 <div class="list.orderable">\
26 <div class="item.answer" answer="3">Element 3</div>\
27 <div class="item.answer" answer="1">Element 1</div>\
28 <div class="item.answer" answer="2">Element 2</div>\
32 doc.root.object.getItems()[2].setAnswer(1);
34 var items = doc.root.object.getItems();
36 expect(items[0].getAnswer()).to.equal(3);
37 expect(items[1].getAnswer()).to.equal(2);
38 expect(items[2].getAnswer()).to.equal(1);
41 it('sets answer (2)', function() {
42 /* jshint multistr:true */
43 var doc = getDocumentFromXML('\
44 <div class="exercise.order">\
45 <div class="list.orderable">\
46 <div class="item.answer" answer="1">Element 1</div>\
47 <div class="item.answer" answer="2">Element 2</div>\
48 <div class="item.answer" answer="3">Element 3</div>\
51 doc.transaction(function() {
52 doc.root.object.getItems()[2].setAnswer(2);
54 error: function(e) { throw e;}
58 var items = doc.root.object.getItems();
60 expect(items[0].getAnswer()).to.equal(1);
61 expect(items[1].getAnswer()).to.equal(3);
62 expect(items[2].getAnswer()).to.equal(2);