124 lines
No EOL
4.4 KiB
JavaScript
124 lines
No EOL
4.4 KiB
JavaScript
describe("Service: RouteBuilder", function() {
|
|
var RouteBuilder;
|
|
var routeProviderMock;
|
|
var pagesMock;
|
|
var profiles;
|
|
var currentProfile;
|
|
|
|
it("sanity", function() {
|
|
expect(true).toBe(false);
|
|
});
|
|
|
|
// beforeEach(module('quay'));
|
|
//
|
|
// beforeEach(inject(function($injector) {
|
|
// profiles = [
|
|
// {id: 'old-layout', templatePath: '/static/partials/'},
|
|
// {id: 'layout', templatePath: '/static/partials/'}
|
|
// ];
|
|
// currentProfile = 'layout';
|
|
// routeProviderMock = jasmine.createSpyObj('routeProvider', ['otherwise', 'when']);
|
|
// pagesMock = jasmine.createSpyObj('pagesMock', ['get', 'create']);
|
|
// RouteBuilder = $injector.get('RouteBuilder');
|
|
// }));
|
|
//
|
|
// describe("constructor", function() {
|
|
//
|
|
// it("returns a RouteBuilder object", function() {
|
|
// var routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
//
|
|
// expect(routeBuilder).toBeDefined();
|
|
// });
|
|
//
|
|
// it("initializes dependencies", function() {
|
|
// var routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
//
|
|
// expect(routeBuilder.routeProvider).toEqual(routeProviderMock);
|
|
// expect(routeBuilder.pages).toEqual(pagesMock);
|
|
// expect(routeBuilder.profiles).toBeDefined();
|
|
// });
|
|
//
|
|
// it("sets 'profiles' to all given profiles if given current profile does not match any of the given profiles' id", function() {
|
|
// var routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, 'fake-profile');
|
|
//
|
|
// expect(routeBuilder.profiles).toEqual(profiles);
|
|
// });
|
|
//
|
|
// it("sets 'profiles' to the first given profile with id matching given current profile", function() {
|
|
// var routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
//
|
|
// expect(routeBuilder.profiles).toEqual([profiles[1]]);
|
|
// });
|
|
// });
|
|
//
|
|
// describe("otherwise", function() {
|
|
// var routeBuilder;
|
|
//
|
|
// beforeEach(function() {
|
|
// routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
// });
|
|
//
|
|
// it("calls routeProvider to set fallback route with given options", function() {
|
|
// var options = {1: "option"};
|
|
// routeBuilder.otherwise(options);
|
|
//
|
|
// expect(routeProviderMock.otherwise.calls.argsFor(0)[0]).toEqual(options);
|
|
// });
|
|
// });
|
|
//
|
|
// describe("route", function() {
|
|
// var routeBuilder;
|
|
// var path;
|
|
// var pagename;
|
|
// var page;
|
|
//
|
|
// beforeEach(function() {
|
|
// path = '/repository/:namespace/:name';
|
|
// pagename = 'repo-view';
|
|
// page = {
|
|
// templateName: 'repository.html',
|
|
// reloadOnSearch: false,
|
|
// controller: jasmine.createSpy('pageController'),
|
|
// flags: {},
|
|
// };
|
|
// routeBuilder = new RouteBuilder(routeProviderMock, pagesMock, profiles, currentProfile);
|
|
// });
|
|
//
|
|
// it("calls pages with given pagename and 'profiles' to get matching page and profile pair", function() {
|
|
// pagesMock.get.and.returnValue([profiles[1], page]);
|
|
// routeBuilder.route(path, pagename);
|
|
//
|
|
// expect(pagesMock.get.calls.argsFor(0)[0]).toEqual(pagename);
|
|
// expect(pagesMock.get.calls.argsFor(0)[1]).toEqual(routeBuilder.profiles);
|
|
// });
|
|
//
|
|
// it("throws error if no matching page/profile pair found", function() {
|
|
// pagesMock.get.and.returnValue();
|
|
// try {
|
|
// routeBuilder.route(path, pagename);
|
|
// fail();
|
|
// } catch (error) {
|
|
// expect(error.message).toEqual('Unknown page: ' + pagename);
|
|
// }
|
|
// });
|
|
//
|
|
// it("calls routeProvider to set route for given path and options", function() {
|
|
// pagesMock.get.and.returnValue([profiles[1], page]);
|
|
// var expectedOptions = {
|
|
// templateUrl: profiles[1].templatePath + page.templateName,
|
|
// reloadOnSearch: false,
|
|
// controller: page.controller,
|
|
// };
|
|
// routeBuilder.route(path, pagename);
|
|
//
|
|
// expect(routeProviderMock.when.calls.argsFor(0)[0]).toEqual(path);
|
|
// expect(routeProviderMock.when.calls.argsFor(0)[1]).toEqual(expectedOptions);
|
|
// });
|
|
//
|
|
// it("returns itself (the RouteBuilder instance)", function() {
|
|
// pagesMock.get.and.returnValue([profiles[1], page]);
|
|
//
|
|
// expect(routeBuilder.route(path, pagename)).toEqual(routeBuilder);
|
|
// });
|
|
// });
|
|
}); |