function testSetMultipleTemplates() {
  var extensionItemId = 'extension_test_id';
  var extensionItem = {
    id: extensionItemId,
    type: 'line',
    text: HTML_STRING,
    insertBefore: RADIO2['id']
  };

  var baseQuestionnaire = {'questionnaire': [BLOCK1], 'version': 4};
  var extension = {
    'extensions': [extensionItem], 'version': 4, 'namespace': 'test'};

  var q = new vsaq.Questionnaire(root);
  q.setMultipleTemplates(baseQuestionnaire, extension);

  // Make sure that the line item from the extension is rendered and visible.
  var rendered_extension_item = q.items_[extensionItem['id']];
  assertTrue(rendered_extension_item.isVisible());

  // Make sure that the line item was inserted after RADIO2.
  var block1Items = BLOCK1['items'];
  var extensionItemPos = goog.array.indexOf(block1Items, extensionItem);
  var elementAfter = block1Items[extensionItemPos + 1];
  assertEquals(RADIO2, elementAfter);

  // Make sure that the namespace was applied to inserted item id.
  assertEquals(
      extension['namespace'] + ':' + extensionItemId, extensionItem['id']);

  // Namespace of items in base template should not have changed.
  assertEquals('radio_id2', RADIO2['id']);
}
/**
 * Tests merging of two templates.
 * The extension template holds a line item that is getting added after the
 * RADIO2 item in the base template.
 */
Tests merging of two templates.
The extension template holds a line item that is getting added after the
RADIO2 item in the base template.
Tests merging of two templates . The extension template holds a line item that is getting added after the RADIO2 item in the base template .
function testSetMultipleTemplates() {
  var extensionItemId = 'extension_test_id';
  var extensionItem = {
    id: extensionItemId,
    type: 'line',
    text: HTML_STRING,
    insertBefore: RADIO2['id']
  };
  var baseQuestionnaire = {'questionnaire': [BLOCK1], 'version': 4};
  var extension = {
    'extensions': [extensionItem], 'version': 4, 'namespace': 'test'};
  var q = new vsaq.Questionnaire(root);
  q.setMultipleTemplates(baseQuestionnaire, extension);
  var rendered_extension_item = q.items_[extensionItem['id']];
  assertTrue(rendered_extension_item.isVisible());
  var block1Items = BLOCK1['items'];
  var extensionItemPos = goog.array.indexOf(block1Items, extensionItem);
  var elementAfter = block1Items[extensionItemPos + 1];
  assertEquals(RADIO2, elementAfter);
  assertEquals(
      extension['namespace'] + ':' + extensionItemId, extensionItem['id']);
  assertEquals('radio_id2', RADIO2['id']);
}
function testSetMultipleTemplates ( ) { var extensionItemId = 'extension_test_id' ; var extensionItem = { id : extensionItemId , type : 'line' , text : HTML_STRING , insertBefore : RADIO2 [ 'id' ] } ; var baseQuestionnaire = { 'questionnaire' : [ BLOCK1 ] , 'version' : 4 } ; var extension = { 'extensions' : [ extensionItem ] , 'version' : 4 , 'namespace' : 'test' } ; var q = new vsaq . Questionnaire ( root ) ; q . setMultipleTemplates ( baseQuestionnaire , extension ) ; var rendered_extension_item = q . items_ [ extensionItem [ 'id' ] ] ; assertTrue ( rendered_extension_item . isVisible ( ) ) ; var block1Items = BLOCK1 [ 'items' ] ; var extensionItemPos = goog . array . indexOf ( block1Items , extensionItem ) ; var elementAfter = block1Items [ extensionItemPos + 1 ] ; assertEquals ( RADIO2 , elementAfter ) ; assertEquals ( extension [ 'namespace' ] + ':' + extensionItemId , extensionItem [ 'id' ] ) ; assertEquals ( 'radio_id2' , RADIO2 [ 'id' ] ) ; }
Tests merging of two templates.
Tests merging of two templates .
// Make sure that the line item from the extension is rendered and visible. // Make sure that the line item was inserted after RADIO2. // Make sure that the namespace was applied to inserted item id. // Namespace of items in base template should not have changed.