<commit_before>require 'spec_helper'
require 'conceptql/nodes/node'
require 'conceptql/behaviors/dottable'

class NodeDouble < ConceptQL::Nodes::Node
  include ConceptQL::Behaviors::Dottable

  attr_accessor :values, :options
  def initialize(*values)
    @values = values
    @options = {}
    @types = []
  end
end

describe ConceptQL::Behaviors::Dottable do
  before do
    @obj = NodeDouble.new
    @obj.must_behave_like(:node)
  end

  describe '#display_name' do
    it 'should show just the name if no children or arguments' do
      @obj.values = []
      @obj.display_name.must_equal 'Node Double'
    end

    it 'should show name and args' do
      @obj.values = [5, 10]
      @obj.display_name.must_equal 'Node Double: 5, 10'
    end

    it 'should not include children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.display_name.must_equal 'Node Double'
    end
  end

  describe '#node_name' do
    it 'should show just the name and digit if no children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end

    it 'should not show args' do
      @obj.values = [5, 10]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end

    it 'should not include children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end
  end

  describe '#graph_it' do
    it 'should add itself as a node if no children' do
      @obj.values = []
      mock_graph = Minitest::Mock.new
      mock_node = Minitest::Mock.new
      mock_graph.expect :add_nodes, mock_node, [@obj.node_name]
      mock_node.expect :[]=, nil, [:label, @obj.display_name]
      mock_node.expect :[]=, nil, [:color, 'black']
      @obj.graph_it(mock_graph, Sequel.mock)<commit_msg>DottableSpec: fix names of nodes<commit_after>require 'spec_helper'
require 'conceptql/nodes/node'
require 'conceptql/behaviors/dottable'

class NodeDouble < ConceptQL::Nodes::Node
  include ConceptQL::Behaviors::Dottable

  attr_accessor :values, :options
  def initialize(*values)
    @values = values
    @options = {}
    @types = []
  end
end

describe ConceptQL::Behaviors::Dottable do
  before do
    @obj = NodeDouble.new
    @obj.must_behave_like(:node)
  end

  describe '#display_name' do
    it 'should show just the name if no children or arguments' do
      @obj.values = []
      @obj.display_name.must_match(/Node Double \d+/)
    end

    it 'should show name and args' do
      @obj.values = [5, 10]
      @obj.display_name.must_match(/Node Double \d+: 5, 10/)
    end

    it 'should not include children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.display_name.must_match(/Node Double \d+/)
    end
  end

  describe '#node_name' do
    it 'should show just the name and digit if no children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end

    it 'should not show args' do
      @obj.values = [5, 10]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end

    it 'should not include children' do
      @obj.values = [::ConceptQL::Nodes::Node.new]
      @obj.node_name.must_match(/^node_double_\d+$/)
    end
  end

  describe '#graph_it' do
    it 'should add itself as a node if no children' do
      @obj.values = []
      mock_graph = Minitest::Mock.new
      mock_node = Minitest::Mock.new
      mock_graph.expect :add_nodes, mock_node, [@obj.node_name]
      mock_node.expect :[]=, nil, [:label, @obj.display_name]
      mock_node.expect :[]=, nil, [:color, 'black']
      @obj.graph_it(mock_graph, Sequel.mock)
{'fraction_non_alphanumeric': 0.12960924600990645, 'fraction_numerical': 0.0049532195927352776, 'mean_word_length': 3.0934684684684686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6601487', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1236, 'n_words': 311}