<commit_before>// ==========================================================================
// Project:   MySystem.nodesController Unit Test
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals MySystem module test ok equals same stop start */

module("MySystem.nodesController");

sc_require('lib/old_format_json_parser');

test("Data loading", function() {
  expect(2);
  // Tests that nodes get loaded from the store
  var nodes = MySystem.store.find(MySystem.Node);
  MySystem.nodesController.set('content', nodes);
  ok(nodes.get('length') > 0, "There should be nodes in the store");
  equals(MySystem.nodesController.get('content').get('length'), nodes.get('length'), "Controller should have as many Nodes as the store");
});

test("Data loading from JSON", function() {
  expect(2);
  var oldFirstNode = MySystem.store.find(MySystem.Node).firstObject().toString();
  // To prove we're loading from JSON we should test that the nodes
  // loaded here are different from those loaded from the store.
  // We've serialized the first of the old nodes in order to save the value;
  // if the following function works it would overwrite the original node.
  MySystem.loadCanvas(); // Clears the store and re-loads the store from JSON.
  var nodes = MySystem.store.find(MySystem.Node); // Load nodes from store.
  ok(nodes.get('length') > 0, "There should be nodes in the store");
  ok(!(nodes.firstObject().toString() == oldFirstNode), "The JSON objects shouldn't be the same as the fixture objects");
});

test("Adding nodes", function() {
  expect(2);
  var oldNodeCount = MySystem.store.find(MySystem.Node).get('length');
  MySystem.nodesController.addNode("QUnit Test Node", "http://blog.concord.org/uploads/icons/software-badge.thumb.jpg", 100, 100);
  var newNodeCount = MySystem.store.find(MySystem.Node).get('length');
  equals(newNodeCount, oldNodeCount + 1, "There should be one more node in the store.");
  // The method tolerates empty arguments
  MySystem.nodesController.addNode();
  equals(MySystem.store.find(MySystem.Node).get('length'), newNodeCount+1, "Adding with no arguments should still create a new node.");
});

test("Deleting nodes on-canvas", function() {
  expect(1);
  ok(true, "This might be better tested by Lebowski.");
});
<commit_msg>QUnit test for the selected-objects nodes controller attribute<commit_after>// ==========================================================================
// Project:   MySystem.nodesController Unit Test
// Copyright: ©2010 My Company, Inc.
// ==========================================================================
/*globals MySystem module test ok equals same stop start */

module("MySystem.nodesController");

sc_require('lib/old_format_json_parser');

test("Data loading", function() {
  expect(2);
  // Tests that nodes get loaded from the store
  var nodes = MySystem.store.find(MySystem.Node);
  MySystem.nodesController.set('content', nodes);
  ok(nodes.get('length') > 0, "There should be nodes in the store");
  equals(MySystem.nodesController.get('content').get('length'), nodes.get('length'), "Controller should have as many Nodes as the store");
});

test("Data loading from JSON", function() {
  expect(2);
  var oldFirstNode = MySystem.store.find(MySystem.Node).firstObject().toString();
  // To prove we're loading from JSON we should test that the nodes
  // loaded here are different from those loaded from the store.
  // We've serialized the first of the old nodes in order to save the value;
  // if the following function works it would overwrite the original node.
  MySystem.loadCanvas(); // Clears the store and re-loads the store from JSON.
  var nodes = MySystem.store.find(MySystem.Node); // Load nodes from store.
  ok(nodes.get('length') > 0, "There should be nodes in the store");
  ok(!(nodes.firstObject().toString() == oldFirstNode), "The JSON objects shouldn't be the same as the fixture objects");
});

test("Adding nodes", function() {
  expect(2);
  var oldNodeCount = MySystem.store.find(MySystem.Node).get('length');
  MySystem.nodesController.addNode("QUnit Test Node", "http://blog.concord.org/uploads/icons/software-badge.thumb.jpg", 100, 100);
  var newNodeCount = MySystem.store.find(MySystem.Node).get('length');
  equals(newNodeCount, oldNodeCount + 1, "There should be one more node in the store.");
  // The method tolerates empty arguments
  MySystem.nodesController.addNode();
  equals(MySystem.store.find(MySystem.Node).get('length'), newNodeCount+1, "Adding with no arguments should still create a new node.");
});

test("Deleting nodes on-canvas", function() {
  expect(1);
  ok(true, "This might be better tested by Lebowski.");
});

test("Managing the selected array", function() {
  expect(1);
  var oldSelected = MySystem.nodesController.get('allSelected').get('length');
  MySystem.nodesController.selectObject(MySystem.nodesController.get('content').firstObject());
  var newSelected = MySystem.nodesController.get('allSelected').get('length');
  equals(newSelected,oldSelected+1,"Another item is selected");
  // Testing link selection isn't easy for QUnit at this point
  // MySystem.nodesController.linkSelected = MySystem.store.find('MySystem.Link', 'link1');
  // newSelected = MySystem.nodesController.get('allSelected').get('length');
  // equals(newSelected,oldSelected+2,"A node and a link are selected");
});
{'fraction_non_alphanumeric': 0.1851373778351466, 'fraction_numerical': 0.007375991148810621, 'mean_word_length': 5.1426953567383915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '514472', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1466, 'n_words': 470}