1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-03-09 23:38:54 +00:00

Initial Commit

This commit is contained in:
Mumshad Mannambeth 2017-06-07 13:36:44 -04:00
commit c92f737237
273 changed files with 16964 additions and 0 deletions

View file

@ -0,0 +1,25 @@
'use strict';
import angular from 'angular';
export function OauthButtonsController($window) {
'ngInject';
this.loginOauth = function(provider) {
$window.location.href = `/auth/${provider}`;
};
}
export default angular.module('app2App.oauthButtons', [])
.directive('oauthButtons', function() {
return {
template: require('./oauth-buttons.html'),
restrict: 'EA',
controller: OauthButtonsController,
controllerAs: 'OauthButtons',
scope: {
classes: '@'
}
};
})
.name;

View file

@ -0,0 +1,32 @@
'use strict';
import {
OauthButtonsController
} from './index';
describe('Controller: OauthButtonsController', function() {
var controller, $window;
beforeEach(() => {
angular.module('test', [])
.controller('OauthButtonsController', OauthButtonsController);
});
// load the controller's module
beforeEach(angular.mock.module('test'));
// Initialize the controller and a mock $window
beforeEach(inject(function($controller) {
$window = {
location: {}
};
controller = $controller('OauthButtonsController', {
$window
});
}));
it('should attach loginOauth', function() {
expect(controller.loginOauth)
.to.be.a('function');
});
});

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,59 @@
'use strict';
const $ = require('sprint-js');
import OauthButtons from './index';
describe('Directive: oauthButtons', function() {
// load the directive's module and view
beforeEach(angular.mock.module(OauthButtons));
// beforeEach(angular.mock.module('components/oauth-buttons/oauth-buttons.html'));
var element, parentScope, elementScope;
var compileDirective = function(template) {
inject(function($compile) {
element = angular.element(template);
element = $compile(element)(parentScope);
parentScope.$digest();
elementScope = element.isolateScope();
});
};
beforeEach(inject(function($rootScope) {
parentScope = $rootScope.$new();
}));
it('should contain anchor buttons', function() {
compileDirective('<oauth-buttons></oauth-buttons>');
expect($(element[0])
.find('a.btn.btn-social')
.length)
.to.be.at.least(1);
});
it('should evaluate and bind the classes attribute to scope.classes', function() {
parentScope.scopedClass = 'scopedClass1';
compileDirective('<oauth-buttons classes="testClass1 {{scopedClass}}"></oauth-buttons>');
expect(elementScope.classes)
.to.equal('testClass1 scopedClass1');
});
it('should bind scope.classes to class names on the anchor buttons', function() {
compileDirective('<oauth-buttons></oauth-buttons>');
// Add classes
elementScope.classes = 'testClass1 testClass2';
elementScope.$digest();
expect($(element[0])
.find('a.btn.btn-social.testClass1.testClass2')
.length)
.to.be.at.least(1);
// Remove classes
elementScope.classes = '';
elementScope.$digest();
expect($(element[0])
.find('a.btn.btn-social.testClass1.testClass2')
.length)
.to.equal(0);
});
});

View file

@ -0,0 +1,9 @@
<a ng-class="classes" ng-click="OauthButtons.loginOauth('facebook')" class="btn btn-social btn-facebook">
<i class="fa fa-facebook"></i>
Connect with Facebook
</a>
<a ng-class="classes" ng-click="OauthButtons.loginOauth('google')" class="btn btn-social btn-google">
<i class="fa fa-google-plus"></i>
Connect with Google+
</a>