<commit_before>/**
 * @fileOverview Test initialization of the KafkaAvro lib, SR related.
 */
var chai = require('chai');
var expect = chai.expect;

const testLib = require('../lib/test.lib');
var KafkaAvro = require('../..');

// var srUrl = 'http://schema-registry-confluent.internal.dev.waldo.photos';
var srUrl = 'http://localhost:8081';

describe('Initialization of SR', function() {
  testLib.init();
  it('should initialize properly', function() {
    var kafkaAvro = new KafkaAvro({
      schemaRegistry: srUrl,
    });

    return kafkaAvro.init()
      .map((res) => {
        expect(res).to.have.keys([
          'responseRaw',
          'schemaType',
          'topic',
          'schemaRaw',
          'schemaTopicRaw',
          'type',
        ]);

        expect(res.responseRaw).to.have.keys([
          'subject',
          'version',
          'id',
          'schema',
        ]);
      })
      .then((all) => {
        expect(all).to.have.length.of.at.least(1);
      });
  });
  it('kafkaAvro instance should contain expected values after init', function() {
    var kafkaAvro = new KafkaAvro({
      schemaRegistry: srUrl,
    });

    return kafkaAvro.init()
      .map((res) => {
        if (res.schemaType.toLowerCase() === 'value') {
          expect(kafkaAvro.valueSchemas[res.topic]).to.be.an('object');
          expect(kafkaAvro.schemaMeta[res.topic]).to.be.an('object');

          expect(kafkaAvro.schemaMeta[res.topic]).to.have.keys([
            'subject',
            'version',
            'id',
            'schema',
          ]);

        } else {
          expect(kafkaAvro.keySchemas[res.topic]).to.be.an('object');
        }
      })
      .then((all) => {
        expect(all).to.have.length.of.at.least(1);
      });
  });

});<commit_msg>update SR test<commit_after>/**
 * @fileOverview Test initialization of the KafkaAvro lib, SR related.
 */
var chai = require('chai');
var expect = chai.expect;

const testLib = require('../lib/test.lib');
var SchemaRegistry = require('../../lib/schema-registry');

var srUrl = 'http://schema-registry-confluent.internal.dev.waldo.photos';
// var srUrl = 'http://localhost:8081';

describe('Initialization of SR', function() {
  testLib.init();
  it('should initialize properly', function() {
    var sr = new SchemaRegistry(srUrl);

    return sr.init()
      .map((res) => {
        expect(res).to.have.keys([
          'responseRaw',
          'schemaType',
          'topic',
          'schemaRaw',
          'schemaTopicRaw',
          'type',
        ]);

        expect(res.responseRaw).to.have.keys([
          'subject',
          'version',
          'id',
          'schema',
        ]);
      })
      .then((all) => {
        expect(all).to.have.length.of.at.least(1);
      });
  });
  it('SR instance should contain expected values after init', function() {
    var sr = new SchemaRegistry(srUrl);

    return sr.init()
      .map((res) => {
        if (res.schemaType.toLowerCase() === 'value') {
          expect(sr.valueSchemas[res.topic]).to.be.an('object');
          expect(sr.schemaMeta[res.topic]).to.be.an('object');

          expect(sr.schemaMeta[res.topic]).to.have.keys([
            'subject',
            'version',
            'id',
            'schema',
          ]);

        } else {
          expect(sr.keySchemas[res.topic]).to.be.an('object');
        }
      })
      .then((all) => {
        expect(all).to.have.length.of.at.least(1);
      });
  });

});
{'fraction_non_alphanumeric': 0.18032786885245902, 'fraction_numerical': 0.003451251078515962, 'mean_word_length': 2.0562390158172232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2743597', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1105, 'n_words': 182}