| * Created by teone on 4/15/16. |
| describe('The xos.helper module', function(){ |
| describe('The xos-validation component', () => { |
| let element, scope, isolatedScope; |
| beforeEach(module('xos.helpers')); |
| beforeEach(inject(($compile, $rootScope) => { |
| scope = $rootScope.$new(); |
| element = angular.element(`<xos-validation errors="errors"></xos-validation>`); |
| $compile(element)(scope); |
| isolatedScope = element.isolateScope().vm; |
| it('should not show an alert', () => { |
| expect($(element).find('xos-alert > .alert')[0]).toHaveClass('ng-hide'); |
| message: 'Field required' |
| message: 'This is not a valid email' |
| // use a loop to generate similar test |
| availableErrors.forEach((e, i) => { |
| it(`should show an alert for ${e.type} errors`, () => { |
| scope.errors[e.type] = true; |
| let alert = $(element).find('xos-alert > .alert')[i]; |
| expect(alert).not.toHaveClass('ng-hide'); |
| expect(alert).toHaveText(e.message); |