Sha256: 0acf501a1013b4132623182673a91764be15f0ff73cf1853bc2b66be8b04d8af

Contents?: true

Size: 1.35 KB

Versions: 7

Compression:

Stored size: 1.35 KB

Contents

describe('A Route', {
  before_each: function() {
    r = new ExtMVC.Route(':controller/:action/:id');
  },
  
  'should return whether or not it matches a given URL': function() {
    value_of(r.recognises('someroute')).should_be(false);
    value_of(r.recognises('c/a/id')).should_be(true);
  },
  
  "should have an array of all matching segments found in the matching string": function() {
    var obj = r.paramsInMatchString;
    value_of(obj).should_be([':controller', ':action', ':id']);
  },
  
  "should return false from matches_for when the route doesn't match" : function() {
    value_of(r.matchesFor('a')).should_be(false);
  },
  
  "should return the correct params hash from a matching url": function() {
    var obj = r.matchesFor('con/act/1');
    value_of(obj[":controller"]).should_be('con');
    value_of(obj[":action"]).should_be('act');
    value_of(obj[":id"]).should_be('1');
  },
  
  'return an object with all extra passed params' : function() {
    r = new ExtMVC.Route(':controller/:action/:id', {':some_key': 'some value'});
    obj = r.matchesFor('c/a/id');
    
    value_of(obj[':some_key']).should_be('some value');
  },
  
  'should convert mapping "regexes" into actual regexes useful for matching' : function() {
    expected = /^([a-zA-Z0-9\_,]+)\/([a-zA-Z0-9\_,]+)\/([a-zA-Z0-9\_,]+)$/;
    value_of(r.matcherRegex).should_be(expected);
  }
});

Version data entries

7 entries across 6 versions & 1 rubygems

Version Path
extjs-mvc-0.4.0.k test/app/vendor/extjs-mvc/specs-old/route.js
extjs-mvc-0.4.0.k lib/extjs-mvc/src/specs-old/route.js
extjs-mvc-0.4.0.f lib/src/specs-old/route.js
extjs-mvc-0.4.0.e lib/vendor/specs-old/route.js
extjs-mvc-0.4.0.d lib/vendor/specs-old/route.js
extjs-mvc-0.4.0.b lib/js/specs-old/route.js
extjs-mvc-0.4.0.a lib/js/specs-old/route.js