<commit_before>var chai = require('chai')
  , patternHelper = require('../../../lib/helpers/route/pattern');
  

describe('helpers/route/pattern', function() {
  
  describe('path', function() {
    
    describe('without placeholder', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/songs'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
          })
          .create(function(err, helper) {
            if (err) { return done(err); }
            pathHelper = helper;
            return done();
          });
      });
    
      it('should build correct path', function() {
        expect(pathHelper()).to.equal('/songs');
      });
    });
    
    describe('with one placeholder', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/songs/:id'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
          })
          .create(function(err, helper) {
            if (err) { return done(err); }
            pathHelper = helper;
            return done();
          });
      });
    
      it('should build correct path with number', function() {
        expect(pathHelper(7)).to.equal('/songs/7');
        expect(pathHelper(0)).to.equal('/songs/0');
      });
      it('should build correct path with string', function() {
        expect(pathHelper('mr-jones')).to.equal('/songs/mr-jones');
      });
      it('should build correct path with object id', function() {
        expect(pathHelper({ id: 101 })).to.equal('/songs/101');
        expect(pathHelper({ id: 0 })).to.equal('/songs/0');
      });
      it('should throw if incorrect number of arguments', function() {
        expect(function() {
          pathHelper()
        }).to.throw("Incorrect number of arguments passed to route helper for /songs/:id");
      });
    });
    
    describe('with two placeholders', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/bands/:band_id/albums/:id'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';<commit_msg>More test cases for pattern helper.<commit_after>var chai = require('chai')
  , patternHelper = require('../../../lib/helpers/route/pattern');
  

describe('helpers/route/pattern', function() {
  
  describe('path', function() {
    
    describe('without placeholder', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/songs'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
          })
          .create(function(err, helper) {
            if (err) { return done(err); }
            pathHelper = helper;
            return done();
          });
      });
    
      it('should build correct path', function() {
        expect(pathHelper()).to.equal('/songs');
      });
    });
    
    describe('with one placeholder', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/songs/:id'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
          })
          .create(function(err, helper) {
            if (err) { return done(err); }
            pathHelper = helper;
            return done();
          });
      });
    
      it('should build correct path with number', function() {
        expect(pathHelper(7)).to.equal('/songs/7');
        expect(pathHelper(0)).to.equal('/songs/0');
      });
      it('should build correct path with string', function() {
        expect(pathHelper('mr-jones')).to.equal('/songs/mr-jones');
      });
      it('should build correct path with object id', function() {
        expect(pathHelper({ id: 101 })).to.equal('/songs/101');
        expect(pathHelper({ id: 0 })).to.equal('/songs/0');
      });
      it('should throw if incorrect number of arguments', function() {
        expect(function() {
          pathHelper()
        }).to.throw("Incorrect number of arguments passed to route helper for /songs/:id");
      });
    });
    
    describe('with one placeholder and one optional placeholder', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/songs/:id.:format?'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
          })
          .create(function(err, helper) {
            if (err) { return done(err); }
            pathHelper = helper;
            return done();
          });
      });
    
      it('should build correct path without optional placeholder', function() {
        expect(pathHelper('mr-jones')).to.equal('/songs/mr-jones');
      });
    });
    
    describe('with two placeholders', function() {
      var pathHelper;
    
      before(function(done) {
        chai.locomotive.helper(patternHelper.path('/bands/:band_id/albums/:id'), 'test', 'show')
          .req(function(req) {
            req.headers.host = 'www.example.com';
{'fraction_non_alphanumeric': 0.16663492668063226, 'fraction_numerical': 0.0045705579889544845, 'mean_word_length': 2.1411483253588517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 7, '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': '3610375', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1501, 'n_words': 292}