function testSetValues() {
  var q = new vsaq.Questionnaire(root);
  q.setTemplate(QUESTIONNAIRE);
  q.render();

  var values = {};
  values[BOX.id] = 'boxvalue';
  values[LINE.id] = 'linevalue';
  values[CHECK.id] = 'checked';
  values[RADIO1.id] = 'checked';
  values[RADIO2.id] = 'unchecked';
  values[YESNO.id] = 'yes';
  q.setValues(values);

  assertEquals('boxvalue', goog.dom.getElement(BOX.id).value);
  assertEquals('linevalue', goog.dom.getElement(LINE.id).value);
  assertEquals('checked', q.items_[CHECK.id].getValue());
  assertEquals('checked', q.items_[RADIO1.id].getValue());
  assertEquals('', q.items_[RADIO2.id].getValue());
  assertEquals('yes', q.items_[YESNO.id].getValue());

  var verify = JSON.parse(q.getValuesAsJson());
  assertEquals('boxvalue', verify[BOX.id]);
  assertEquals('linevalue', verify[LINE.id]);
  assertEquals('yes', verify[YESNO.id]);
  assertEquals('checked', verify[CHECK.id]);
  assertEquals('checked', verify[RADIO1.id]);
  assertEquals('checked', verify[CHECK.id]);

  values[YESNO.id] = 'no';
  values[CHECK.id] = '';
  q.setValues(values);

  assertEquals('', q.items_[CHECK.id].getValue());
  assertEquals('no', q.items_[YESNO.id].getValue());

  verify = JSON.parse(q.getValuesAsJson());
  assertEquals('', verify[CHECK.id]);
  assertEquals('no', verify[YESNO.id]);
}
/**
 * Tests setting values for the Questionnaire.
 */
Tests setting values for the Questionnaire.
Tests setting values for the Questionnaire .
function testSetValues() {
  var q = new vsaq.Questionnaire(root);
  q.setTemplate(QUESTIONNAIRE);
  q.render();
  var values = {};
  values[BOX.id] = 'boxvalue';
  values[LINE.id] = 'linevalue';
  values[CHECK.id] = 'checked';
  values[RADIO1.id] = 'checked';
  values[RADIO2.id] = 'unchecked';
  values[YESNO.id] = 'yes';
  q.setValues(values);
  assertEquals('boxvalue', goog.dom.getElement(BOX.id).value);
  assertEquals('linevalue', goog.dom.getElement(LINE.id).value);
  assertEquals('checked', q.items_[CHECK.id].getValue());
  assertEquals('checked', q.items_[RADIO1.id].getValue());
  assertEquals('', q.items_[RADIO2.id].getValue());
  assertEquals('yes', q.items_[YESNO.id].getValue());
  var verify = JSON.parse(q.getValuesAsJson());
  assertEquals('boxvalue', verify[BOX.id]);
  assertEquals('linevalue', verify[LINE.id]);
  assertEquals('yes', verify[YESNO.id]);
  assertEquals('checked', verify[CHECK.id]);
  assertEquals('checked', verify[RADIO1.id]);
  assertEquals('checked', verify[CHECK.id]);
  values[YESNO.id] = 'no';
  values[CHECK.id] = '';
  q.setValues(values);
  assertEquals('', q.items_[CHECK.id].getValue());
  assertEquals('no', q.items_[YESNO.id].getValue());
  verify = JSON.parse(q.getValuesAsJson());
  assertEquals('', verify[CHECK.id]);
  assertEquals('no', verify[YESNO.id]);
}
function testSetValues ( ) { var q = new vsaq . Questionnaire ( root ) ; q . setTemplate ( QUESTIONNAIRE ) ; q . render ( ) ; var values = { } ; values [ BOX . id ] = 'boxvalue' ; values [ LINE . id ] = 'linevalue' ; values [ CHECK . id ] = 'checked' ; values [ RADIO1 . id ] = 'checked' ; values [ RADIO2 . id ] = 'unchecked' ; values [ YESNO . id ] = 'yes' ; q . setValues ( values ) ; assertEquals ( 'boxvalue' , goog . dom . getElement ( BOX . id ) . value ) ; assertEquals ( 'linevalue' , goog . dom . getElement ( LINE . id ) . value ) ; assertEquals ( 'checked' , q . items_ [ CHECK . id ] . getValue ( ) ) ; assertEquals ( 'checked' , q . items_ [ RADIO1 . id ] . getValue ( ) ) ; assertEquals ( '' , q . items_ [ RADIO2 . id ] . getValue ( ) ) ; assertEquals ( 'yes' , q . items_ [ YESNO . id ] . getValue ( ) ) ; var verify = JSON . parse ( q . getValuesAsJson ( ) ) ; assertEquals ( 'boxvalue' , verify [ BOX . id ] ) ; assertEquals ( 'linevalue' , verify [ LINE . id ] ) ; assertEquals ( 'yes' , verify [ YESNO . id ] ) ; assertEquals ( 'checked' , verify [ CHECK . id ] ) ; assertEquals ( 'checked' , verify [ RADIO1 . id ] ) ; assertEquals ( 'checked' , verify [ CHECK . id ] ) ; values [ YESNO . id ] = 'no' ; values [ CHECK . id ] = '' ; q . setValues ( values ) ; assertEquals ( '' , q . items_ [ CHECK . id ] . getValue ( ) ) ; assertEquals ( 'no' , q . items_ [ YESNO . id ] . getValue ( ) ) ; verify = JSON . parse ( q . getValuesAsJson ( ) ) ; assertEquals ( '' , verify [ CHECK . id ] ) ; assertEquals ( 'no' , verify [ YESNO . id ] ) ; }
Tests setting values for the Questionnaire.
Tests setting values for the Questionnaire .