<commit_before>var assert = require("assert");
var TextParser = require('../lib/index').parsers.TextParser;

describe('TextPaser', function() {

    var simple_scenario = ['Scenario: Simple', '   Given A', '   When B', '   Then C'].join('\n');
    var simple_feature = ['Feature: Tests with feature', 'Scenario: With Feature'].join('\n');
    var multiple_feature = ['Feature: Tests with 2 features', 'Scenario: For Feature 1', 'Feature: Second feature'].join('\n');
    var complex_scenario = ['Scenario: Complex', '', '  ', '   Given A', '', 'When B', ' ', '   Then C'].join('\n');
    var annotated_feature = ['@keyword1=value1', '@keyword2=value2', '@keyword3', 'Feature: Annotated', 'Scenario: Simple', 'Given A', 'When B', 'Then C'].join('\n');
    var annotated_scenario = ['Feature: Simple', '@keyword1=value1', '@keyword2=value2', '@keyword3', 'Scenario: Annotated', 'Given A', 'When B', 'Then C'].join('\n');


    var parser;

    beforeEach(function(){
        parser = new TextParser();
    });

    it('should parse a simple scenario', function() {
        var scenarios = parser.parse(simple_scenario).scenarios;
        assert.equal(scenarios.length, 1);
        assert.equal(scenarios[0].title, 'Simple');
        assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
    });

    it('should parse a complex scenario', function() {
        var scenarios = parser.parse(complex_scenario).scenarios;
        assert.equal(scenarios.length, 1);
        assert.equal(scenarios[0].title, 'Complex');
        assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
    });

    it('should parses multiple scenarios', function() {
        var scenarios = parser.parse(simple_scenario + '\n' + complex_scenario).scenarios;
        assert.equal(scenarios.length, 2);
        assert.equal(scenarios[0].title, 'Simple');
        assert.equal(scenarios[1].title, 'Complex');
    });

    it('should reset scenarios between parses', function() {
        assert.equal(parser.parse(simple_scenario).scenarios.length, 1);
        assert.equal(parser.parse(simple_scenario).scenarios.length, 1);
    });

    it('should parse feature title', function() {
        var feature = parser.parse(simple_feature);
        assert.equal(feature.title, 'Tests with feature');
    });

    it('should only allow a single feature', function() {
        assert.throws(function() {
            parser.parse(multiple_feature);
        }, /single feature/);
    });

    it('should parse feature annotations', function() {
        var feature = parser.parse(annotated_feature);
		assert.equal(feature.annotations['keyword1'], 'value1');
		assert.equal(feature.annotations['keyword2'], 'value2');
        assert(feature.annotations['keyword3']);
        assert.deepEqual(feature.scenarios[0].annotations, {});
    });

    it('should parse scenario annotations', function() {
        var feature = parser.parse(annotated_scenario);
        assert.deepEqual(feature.annotations, {});
        assert.equal(feature.scenarios[0].annotations['keyword1'], 'value1');
        assert.equal(feature.scenarios[0].annotations['keyword2'], 'value2');
        assert(feature.scenarios[0].annotations['keyword3']);        
    });    
});<commit_msg>Adding missing scenario test<commit_after>var assert = require("assert");
var TextParser = require('../lib/index').parsers.TextParser;

describe('TextPaser', function() {

    var simple_scenario = ['Scenario: Simple', '   Given A', '   When B', '   Then C'].join('\n');
    var simple_feature = ['Feature: Tests with feature', 'Scenario: With Feature'].join('\n');
    var multiple_feature = ['Feature: Tests with 2 features', 'Scenario: For Feature 1', 'Feature: Second feature'].join('\n');
    var complex_scenario = ['Scenario: Complex', '', '  ', '   Given A', '', 'When B', ' ', '   Then C'].join('\n');
    var annotated_feature = ['@keyword1=value1', '@keyword2=value2', '@keyword3', 'Feature: Annotated', 'Scenario: Simple', 'Given A', 'When B', 'Then C'].join('\n');
    var annotated_scenario = ['Feature: Simple', '@keyword1=value1', '@keyword2=value2', '@keyword3', 'Scenario: Annotated', 'Given A', 'When B', 'Then C'].join('\n');
    var missing_scenario = ['Given A', 'When B', 'Then C'].join('\n');    


    var parser;

    beforeEach(function(){
        parser = new TextParser();
    });

    it('should parse a simple scenario', function() {
        var scenarios = parser.parse(simple_scenario).scenarios;
        assert.equal(scenarios.length, 1);
        assert.equal(scenarios[0].title, 'Simple');
        assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
    });

    it('should parse a complex scenario', function() {
        var scenarios = parser.parse(complex_scenario).scenarios;
        assert.equal(scenarios.length, 1);
        assert.equal(scenarios[0].title, 'Complex');
        assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
    });

    it('should parses multiple scenarios', function() {
        var scenarios = parser.parse(simple_scenario + '\n' + complex_scenario).scenarios;
        assert.equal(scenarios.length, 2);
        assert.equal(scenarios[0].title, 'Simple');
        assert.equal(scenarios[1].title, 'Complex');
    });

    it('should reset scenarios between parses', function() {
        assert.equal(parser.parse(simple_scenario).scenarios.length, 1);
        assert.equal(parser.parse(simple_scenario).scenarios.length, 1);
    });

    it('should parse feature title', function() {
        var feature = parser.parse(simple_feature);
        assert.equal(feature.title, 'Tests with feature');
    });

    it('should only allow a single feature', function() {
        assert.throws(function() {
            parser.parse(multiple_feature);
        }, /single feature/);
    });

    it('should report steps with no scenario', function() {
        assert.throws(function() {
            parser.parse(missing_scenario);
        }, /Missing scenario/);
    });    

    it('should parse feature annotations', function() {
        var feature = parser.parse(annotated_feature);
		assert.equal(feature.annotations['keyword1'], 'value1');
		assert.equal(feature.annotations['keyword2'], 'value2');
        assert(feature.annotations['keyword3']);
        assert.deepEqual(feature.scenarios[0].annotations, {});
    });

    it('should parse scenario annotations', function() {
        var feature = parser.parse(annotated_scenario);
        assert.deepEqual(feature.annotations, {});
        assert.equal(feature.scenarios[0].annotations['keyword1'], 'value1');
        assert.equal(feature.scenarios[0].annotations['keyword2'], 'value2');
        assert(feature.scenarios[0].annotations['keyword3']);        
    });    
});
{'fraction_non_alphanumeric': 0.17286684381458517, 'fraction_numerical': 0.010924121641570712, 'mean_word_length': 3.5684423465947406, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1646396', 'n_tokens_mistral': 2012, 'n_tokens_neox': 1957, 'n_words': 430}