-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big update. Writed tests, modular devided controllers #2
- Loading branch information
1 parent
a46782a
commit d92e79b
Showing
45 changed files
with
521 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
node_modules | ||
dist | ||
coverage | ||
public | ||
/public | ||
build | ||
|
||
.tmp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ node_modules | |
public | ||
build | ||
|
||
node_modules | ||
.tmp | ||
.sass-cache | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Pavel Zinovev <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
/* Copyright (C) Simply.info | ||
* Unauthorized copying of this file, via any medium is strictly prohibited | ||
* Proprietary and confidential | ||
* Written by Pavel Zinovev <[email protected]>, February 2016 | ||
*/ | ||
|
||
describe('Application', () => { | ||
beforeEach(() => { | ||
browser.get('/'); | ||
}); | ||
|
||
|
||
it('should have a title', () => { | ||
expect(browser.getTitle()).toEqual('Title'); | ||
}); | ||
|
@@ -16,5 +21,19 @@ describe('Application', () => { | |
expect(element(by.css('.wrapper')).isPresent()).toEqual(true); | ||
}); | ||
|
||
it('should have content', () => { | ||
expect(element(by.css('.page-content')).isPresent()).toEqual(true); | ||
}); | ||
|
||
it('should get the current state', function (){ | ||
const currentStateName = browser.executeAsyncScript((callback) => { | ||
const el = document.querySelector('html'); | ||
const injector = angular.element(el).injector(); | ||
const service = injector.get('$state'); | ||
|
||
callback(service.current.name); | ||
}); | ||
|
||
expect(currentStateName).toEqual('home'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
import angular from 'angular'; | ||
import uiRouter from 'angular-ui-router'; | ||
import uiRouterStateHelper from 'angular-ui-router.statehelper'; | ||
|
||
import Config from './Config'; | ||
import layoutView from './modules/Layout/views/layout.jade'; | ||
import Config from './Config'; | ||
import Runners from './Runners'; | ||
import AppView from './modules/Application/views/layout.jade'; | ||
|
||
import Layout from './modules/Layout/Index'; | ||
import Home from './modules/Home/Index'; | ||
import Controllers from './modules/Application/Controllers'; | ||
|
||
|
||
const appname = 'Workflow'; /** App and root module name */ | ||
const deps = [uiRouter, 'ui.router.stateHelper']; /** All global dependencies */ | ||
const modules = [Controllers]; /** All app dependencies */ | ||
|
||
const appname = 'Workflow'; | ||
const deps = [uiRouter]; | ||
const modules = [Layout, Home]; | ||
document.getElementById('app-container').innerHTML = AppView(); /** Store our app. (Getting html from jade) */ | ||
angular.module(appname, deps.concat(modules)).config(Config).run(Runners); /** Declare root module */ | ||
angular.bootstrap(document, [appname]); /** Bootstrap our application. Поехали! */ | ||
|
||
document.getElementById('app-container').innerHTML = layoutView(); | ||
angular.module(appname, deps.concat(modules)).config(Config); | ||
angular.bootstrap(document, [appname]); | ||
/** Export appname. Just in case. */ | ||
export default appname; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
const Config = ($stateProvider, $urlRouterProvider, $locationProvider) => { /*@ngInject*/ | ||
$locationProvider.html5Mode(true); | ||
/* Copyright (C) Simply.info | ||
* Unauthorized copying of this file, via any medium is strictly prohibited | ||
* Proprietary and confidential | ||
* Written by Pavel Zinovev <[email protected]>, March 2016 | ||
*/ | ||
|
||
$urlRouterProvider.otherwise('/'); | ||
/** | ||
* @module Config | ||
* @see Application | ||
* @param {Object} stateHelperProvider - Ui-router module for right nesting. | ||
* @param {Object} $urlRouterProvider - Configures how the application routing. | ||
* @param {Object} $locationProvider - Configures how the application deep linking paths are stored. | ||
* @param {Object} $logProvider - Configures how the application logs messages. | ||
*/ | ||
const Config = (stateHelperProvider, $urlRouterProvider, $locationProvider, $logProvider) => { | ||
/*@ngInject*/ | ||
|
||
$stateProvider | ||
.state('home', { | ||
url: '/', | ||
template: require('./modules/Home/views/home.jade')(), | ||
controller: 'HomeController' | ||
$logProvider.debugEnabled(true); /** Turn debug mode on/off */ | ||
$locationProvider.html5Mode(true); /** Turn html5 mode on */ | ||
$urlRouterProvider.otherwise('/home'); /** If current route not in routes then redirect to home */ | ||
|
||
/** | ||
* Url processing. | ||
* @param {Object} $injector - Ability to inject providers. | ||
* @param {Object} $location - Current location. | ||
*/ | ||
$urlRouterProvider.rule(($injector, $location) => { | ||
const path = $location.path(); | ||
$location.path(path[path.length - 1] === '/' ? path.slice(0, -1) : path); /** If route like as /home/ then /home */ | ||
}); | ||
|
||
stateHelperProvider /** Describe our states */ | ||
.state({ | ||
url: '/', | ||
name: 'home', | ||
controller: 'HomeController', | ||
template: require('./modules/Home/views/home.jade')() | ||
}); | ||
}; | ||
|
||
/** Export our config */ | ||
export default Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright (C) Simply.info | ||
* Unauthorized copying of this file, via any medium is strictly prohibited | ||
* Proprietary and confidential | ||
* Written by Pavel Zinovev <[email protected]>, March 2016 | ||
*/ | ||
|
||
/** | ||
* Adding redirectTo from config ability. | ||
* @module Runners | ||
* @see Application | ||
* @param {Object} $rootScope - Global application model. | ||
* @param {Object} $state - Provides interfaces to current state. | ||
*/ | ||
const Runners = ($rootScope, $state) => { /*@ngInject*/ | ||
|
||
/** | ||
* Waiting route change start event. | ||
* @param {Object} event. | ||
* @param {Object} to - Next state. | ||
*/ | ||
$rootScope.$on('$stateChangeStart', (event, to) => { | ||
if (to.redirectTo) { | ||
event.preventDefault(); | ||
$state.go(to.redirectTo); | ||
} | ||
}); | ||
}; | ||
|
||
/** Export our runners */ | ||
export default Runners; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* Copyright (C) Simply.info | ||
* Unauthorized copying of this file, via any medium is strictly prohibited | ||
* Proprietary and confidential | ||
* Written by Pavel Zinovev <[email protected]>, March 2016 | ||
*/ | ||
|
||
/* | ||
* Javascripts | ||
* ========================================================================== */ | ||
|
||
import angular from 'angular'; | ||
|
||
import Layout from './Index'; | ||
import Home from '../Home/Index'; | ||
|
||
/** | ||
* Define app module. | ||
* @param {String} moduleName. | ||
* @param {Array} dependencies. | ||
* @export Controllers module | ||
*/ | ||
export default angular.module('Simply.App.controllers', [ | ||
Layout, Home | ||
]).name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import App from '../Index'; | ||
|
||
describe('Controller: App', () => { | ||
let $scope, $controller, controller; | ||
|
||
beforeEach(angular.mock.module(App)); | ||
|
||
beforeEach(angular.mock.inject((_$controller_, _$rootScope_) => { | ||
$controller = _$controller_; | ||
$scope = _$rootScope_.$new(); | ||
|
||
controller = $controller('AppController', { $scope }); | ||
$scope.$digest(); | ||
})); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
|
||
it('should have scope', () => { | ||
expect(typeof controller.$scope).toBe('object'); | ||
}); | ||
}); |
Oops, something went wrong.