<commit_before>should = require 'should'

describe 'simple schema', ->
  schema = 'module foo;'

  it "should parse simple module statement", ->
    y = yang.parse schema
    y.should.have.property('tag').and.equal('foo')

  it "should create simple module element", ->
    o = (yang schema)()
    o.should.have.property('__')

describe 'extended schema', ->
  schema = """
    module foo {
      prefix foo;
      namespace "http://corenova.com";
      
      description "extended module test";
      contact "<NAME> <<EMAIL>>";
      organization "Corenova Technologies, Inc.";
      reference "http://github.com/corenova/yang-js";

      identity core {
        description "the core identity";
      }

      grouping some-shared-info {
        leaf a { type string; }
        leaf b { type uint8; }
      }

      container bar {
        uses some-shared-info;
      }

      rpc some-method-1 {
        description "update config for 'bar'";
        input {
          uses some-shared-info;
        }
      }
      rpc some-method-2;
    }
    """
  it "should parse extended module statement", ->
    y = yang.parse schema
    y.prefix.should.have.property('tag').and.equal('foo')

  it "should create extended module element", ->
    o = (yang schema)()
    o.should.have.property('bar')

  it "should evaluate configuration data", ->
    o = (yang schema)<commit_msg>see #15, added a simple test case on 'module' extension testing to convert toObject<commit_after>should = require 'should'

describe 'simple schema', ->
  schema = 'module foo;'

  it "should parse simple module statement", ->
    y = yang.parse schema
    y.should.have.property('tag').and.equal('foo')

  it "should create simple module element", ->
    o = (yang schema)()
    o.should.have.property('__')

describe 'extended schema', ->
  schema = """
    module foo {
      prefix foo;
      namespace "http://corenova.com";
      
      description "extended module test";
      contact "<NAME> <<EMAIL>>";
      organization "Corenova Technologies, Inc.";
      reference "http://github.com/corenova/yang-js";

      identity core {
        description "the core identity";
      }

      grouping some-shared-info {
        leaf a { type string; }
        leaf b { type uint8; }
      }

      container bar {
        uses some-shared-info;
      }

      rpc some-method-1 {
        description "update config for 'bar'";
        input {
          uses some-shared-info;
        }
      }
      rpc some-method-2;
    }
    """
  it "should parse extended module statement", ->
    y = yang.parse schema
    y.prefix.should.have.property('tag').and.equal('foo')

  it "should convert toObject", ->
    y = yang.parse schema
    obj = y.toObject()
    obj.should.have.property('module').and.have.property('foo')

  it "should create extended module element", ->
    o = (yang schema)()
    o.should.have.property('bar')

  it "should evaluate configuration data", ->
    o = (yang schema)
{'fraction_non_alphanumeric': 0.13353514968045746, 'fraction_numerical': 0.0026908846283215607, 'mean_word_length': 2.3007769145394006, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '5370223', 'n_tokens_mistral': 897, 'n_tokens_neox': 850, 'n_words': 246}