Sha256: e8db6a3f674a4ad80bc4c269e5e444193520ed7f5e1e33d71784fa38d1ff33ce

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

describe("Jax.RouteSet", function() {
  var map;
  var controller_class = Jax.Controller.create({index: function() { }});
  Jax.views.push("generic/index", function() { });
  
  beforeEach(function() { map = Jax.routes; map.clear(); });
  
  describe("when a controller name is given during controller definition", function() {
    beforeEach(function() {
      controller_class = Jax.Controller.create("welcome", {index: function() { }});
    });
    
    it("should map routes automatically", function() {
      var route = map.recognizeRoute("welcome");
      expect(route.controller).toEqual(controller_class);
      expect(route.action).toEqual("index");
    });
    
    it("should automatically map actions added after controller is defined", function() {
      controller_class.prototype.other = function() { };
      var route = map.recognizeRoute("welcome/other");
      expect(route.controller).toEqual(controller_class);
      expect(route.action).toEqual("other");
    });

    it("should return the controller name in an array", function() {
      var arr = map.getControllerNames();
      expect(arr.length).toEqual(1);
      expect(arr[0]).toEqual("welcome");
    });
  });
  
  describe("with a map", function() {
    beforeEach(function() { map.map("generic/index", controller_class, "index"); });
    
    it("should recognize the route without /index", function() {
      var route = map.recognizeRoute("generic");
      
      expect(route.controller).toEqual(controller_class);
      expect(route.action).toEqual("index");
    });
    
    it("should return the controller name in an array", function() {
      var arr = map.getControllerNames();
      expect(arr.length).toEqual(1);
      expect(arr[0]).toEqual("generic");
    });
  });
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jax-2.0.5 spec/javascripts/jax/mvc/route_set_spec.js
jax-2.0.4 spec/javascripts/jax/mvc/route_set_spec.js
jax-2.0.3 spec/javascripts/jax/mvc/route_set_spec.js
jax-2.0.2 spec/javascripts/jax/mvc/route_set_spec.js
jax-2.0.1 spec/javascripts/jax/mvc/route_set_spec.js
jax-2.0.0 spec/javascripts/jax/mvc/route_set_spec.js