Files
meanTorrent/modules/chat/tests/client/chat.client.routes.tests.js
Marek Grzybek d14d5130af feat(config): Deprecate JSHint in favor of ESLint
Add basic ESLint setup extending well-known Airbnb code style.

Fixes #1072, #1097
2016-03-15 19:11:12 +01:00

64 lines
1.9 KiB
JavaScript

(function () {
'use strict';
describe('Chat Route Tests', function () {
// Initialize global variables
var $scope,
Authentication;
// We can start by loading the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
// The injector ignores leading and trailing underscores here (i.e. _$httpBackend_).
// This allows us to inject a service but then attach it to a variable
// with the same name as the service.
beforeEach(inject(function ($rootScope, _Authentication_) {
// Set a new global scope
$scope = $rootScope.$new();
Authentication = _Authentication_;
}));
describe('Route Config', function () {
describe('Main Route', function () {
var mainstate;
beforeEach(inject(function ($state) {
mainstate = $state.get('chat');
}));
it('Should have the correct URL', function () {
expect(mainstate.url).toEqual('/chat');
});
it('Should not be abstract', function () {
expect(mainstate.abstract).toBe(undefined);
});
it('Should have templateUrl', function () {
expect(mainstate.templateUrl).toBe('modules/chat/client/views/chat.client.view.html');
});
});
describe('Handle Trailing Slash', function () {
beforeEach(inject(function ($state, $rootScope, _Authentication_) {
Authentication.user = {
name: 'user',
roles: ['user']
};
$state.go('chat');
$rootScope.$digest();
}));
it('Should remove trailing slash', inject(function ($state, $location, $rootScope) {
$location.path('chat/');
$rootScope.$digest();
expect($location.path()).toBe('/chat');
expect($state.current.templateUrl).toBe('modules/chat/client/views/chat.client.view.html');
}));
});
});
});
}());