{"size": 1432, "ext": "js", "max_stars_repo_path": "test/streamTransformers/yamlToJson.spec.js", "max_stars_repo_name": "michaellennox/circus", "max_stars_repo_stars_event_min_datetime": "2016-03-14T11:32:05.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-10T10:24:50.000Z", "max_issues_repo_path": "test/streamTransformers/yamlToJson.spec.js", "max_issues_repo_name": "michaellennox/circus", "max_issues_repo_issues_event_min_datetime": "2017-03-17T17:50:04.000Z", "max_issues_repo_issues_event_max_datetime": "2017-03-17T17:50:04.000Z", "max_forks_repo_path": "test/streamTransformers/yamlToJson.spec.js", "max_forks_repo_name": "michaellennox/circus", "max_forks_repo_forks_event_min_datetime": "2016-07-18T15:24:43.000Z", "max_forks_repo_forks_event_max_datetime": "2019-03-21T17:10:25.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 4, "avg_line_length": 24.6896551724, "max_line_length": 73, "alphanum_fraction": 0.6187150838}
const chai = require('chai');
const expect = chai.expect;

const streamContainsHelper = require('../../lib/utils/chaiStreamHelper');
const streamFrom = require('../../lib/utils/streamFrom');
const yamlToJson = require('../../lib/streamTransformers/yamlToJson');

chai.use(streamContainsHelper);

describe('cssToYaml', function() {

  it('converts a simple yaml', function() {
    const fixture = `some: value`;

    const output = streamFrom([fixture])
      .pipe(yamlToJson());

    return expect(output).to.be.a.stream([
      JSON.stringify({ some: 'value' })
    ]);
  });

  it('ignores YAML comments which dont produce an object', function() {
    const fixture = `some value`;

    const output = streamFrom([fixture])
      .pipe(yamlToJson());

    return expect(output).to.be.a.stream([]);
  });

  it('converts multiple yaml docs', function() {
    const fixture = [
     'some: value',
     'another: value'
    ];

    const output = streamFrom(fixture)
      .pipe(yamlToJson());

    return expect(output).to.be.a.stream([
      JSON.stringify({ some: 'value' }),
      JSON.stringify({ another: 'value' })
    ]);
  });

  it('fires an error event when it cannot parse yaml', function(done) {
    const fixture = `* some: value`;
    const output = streamFrom([fixture])
      .pipe(yamlToJson());

    output.on('error', function(ex) {
      expect(ex.name).to.eq('YAMLException');
      done();
    });
  });
});
