knowhow-server
Version:
A personal workflow engine that can manage and use any network connected host
1,591 lines (1,214 loc) • 173 kB
JavaScript
describe("angular+jqlite", function() {
describe("api/angular.lowercase", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.lowercase");
});
});
describe("api/angular.uppercase", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.uppercase");
});
});
describe("api/angular.forEach", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.forEach");
});
});
describe("api/angular.extend", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.extend");
});
});
describe("api/angular.noop", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.noop");
});
});
describe("api/angular.identity", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.identity");
});
});
describe("api/angular.isUndefined", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isUndefined");
});
});
describe("api/angular.isDefined", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isDefined");
});
});
describe("api/angular.isObject", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isObject");
});
});
describe("api/angular.isString", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isString");
});
});
describe("api/angular.isNumber", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isNumber");
});
});
describe("api/angular.isDate", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isDate");
});
});
describe("api/angular.isArray", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isArray");
});
});
describe("api/angular.isFunction", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isFunction");
});
});
describe("api/angular.isElement", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.isElement");
});
});
describe("api/angular.copy", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.copy");
});
});
describe("api/angular.equals", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.equals");
});
});
describe("api/angular.bind", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.bind");
});
});
describe("api/angular.toJson", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.toJson");
});
});
describe("api/angular.fromJson", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.fromJson");
});
});
describe("api/ng.directive:ngApp", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngApp");
});
});
describe("api/angular.bootstrap", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.bootstrap");
});
});
describe("api/angular.version", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.version");
});
});
describe("api/angular.injector", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.injector");
});
});
describe("api/AUTO", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/AUTO");
});
});
describe("api/AUTO.$injector", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/AUTO.$injector");
});
});
describe("api/AUTO.$provide", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/AUTO.$provide");
});
});
describe("api/angular.element", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.element");
});
});
describe("api/angular.Module", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.Module");
});
});
describe("api/angular.module", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/angular.module");
});
});
describe("api/ng.$anchorScroll", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$anchorScroll");
});
});
describe("api/ng.$animateProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$animateProvider");
});
});
describe("api/ng.$animate", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$animate");
});
});
describe("api/ng.$cacheFactory", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$cacheFactory");
});
});
describe("api/ng.$templateCache", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$templateCache");
});
});
describe("api/ng.$controllerProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$controllerProvider");
});
});
describe("api/ng.$controller", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$controller");
});
});
describe("api/ng.directive:a", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:a");
});
});
describe("api/ng.directive:ngHref", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngHref");
});
it('should execute ng-click but not reload when href without value', function() {
element('#link-1').click();
expect(input('value').val()).toEqual('1');
expect(element('#link-1').attr('href')).toBe("");
});
it('should execute ng-click but not reload when href empty string', function() {
element('#link-2').click();
expect(input('value').val()).toEqual('2');
expect(element('#link-2').attr('href')).toBe("");
});
it('should execute ng-click and change url when ng-href specified', function() {
expect(element('#link-3').attr('href')).toBe("/123");
element('#link-3').click();
expect(browser().window().path()).toEqual('/123');
});
it('should execute ng-click but not reload when href empty string and name specified', function() {
element('#link-4').click();
expect(input('value').val()).toEqual('4');
expect(element('#link-4').attr('href')).toBe('');
});
it('should execute ng-click but not reload when no href but name specified', function() {
element('#link-5').click();
expect(input('value').val()).toEqual('5');
expect(element('#link-5').attr('href')).toBe(undefined);
});
it('should only change url when only ng-href', function() {
input('value').enter('6');
expect(element('#link-6').attr('href')).toBe('6');
element('#link-6').click();
expect(browser().location().url()).toEqual('/6');
});
});
describe("api/ng.directive:ngSrc", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngSrc");
});
});
describe("api/ng.directive:ngSrcset", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngSrcset");
});
});
describe("api/ng.directive:ngDisabled", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngDisabled");
});
it('should toggle button', function() {
expect(element('.doc-example-live :button').prop('disabled')).toBeFalsy();
input('checked').check();
expect(element('.doc-example-live :button').prop('disabled')).toBeTruthy();
});
});
describe("api/ng.directive:ngChecked", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngChecked");
});
it('should check both checkBoxes', function() {
expect(element('.doc-example-live #checkSlave').prop('checked')).toBeFalsy();
input('master').check();
expect(element('.doc-example-live #checkSlave').prop('checked')).toBeTruthy();
});
});
describe("api/ng.directive:ngReadonly", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngReadonly");
});
it('should toggle readonly attr', function() {
expect(element('.doc-example-live :text').prop('readonly')).toBeFalsy();
input('checked').check();
expect(element('.doc-example-live :text').prop('readonly')).toBeTruthy();
});
});
describe("api/ng.directive:ngSelected", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngSelected");
});
it('should select Greetings!', function() {
expect(element('.doc-example-live #greet').prop('selected')).toBeFalsy();
input('selected').check();
expect(element('.doc-example-live #greet').prop('selected')).toBeTruthy();
});
});
describe("api/ng.directive:ngOpen", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngOpen");
});
it('should toggle open', function() {
expect(element('#details').prop('open')).toBeFalsy();
input('open').check();
expect(element('#details').prop('open')).toBeTruthy();
});
});
describe("api/ng.directive:form.FormController", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:form.FormController");
});
});
describe("api/ng.directive:ngForm", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngForm");
});
});
describe("api/ng.directive:form", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:form");
});
it('should initialize to model', function() {
expect(binding('userType')).toEqual('guest');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function() {
input('userType').enter('');
expect(binding('userType')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
});
describe("api/ng.directive:ngBind", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngBind");
});
it('should check ng-bind', function() {
expect(using('.doc-example-live').binding('name')).toBe('Whirled');
using('.doc-example-live').input('name').enter('world');
expect(using('.doc-example-live').binding('name')).toBe('world');
});
});
describe("api/ng.directive:ngBindTemplate", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngBindTemplate");
});
it('should check ng-bind', function() {
expect(using('.doc-example-live').binding('salutation')).
toBe('Hello');
expect(using('.doc-example-live').binding('name')).
toBe('World');
using('.doc-example-live').input('salutation').enter('Greetings');
using('.doc-example-live').input('name').enter('user');
expect(using('.doc-example-live').binding('salutation')).
toBe('Greetings');
expect(using('.doc-example-live').binding('name')).
toBe('user');
});
});
describe("api/ng.directive:ngBindHtml", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngBindHtml");
});
it('should check ng-bind-html', function() {
expect(using('.doc-example-live').binding('myHTML')).
toBe(
'I am an <code>HTML</code>string with <a href="#">links!</a> and other <em>stuff</em>'
);
});
});
describe("api/ng.directive:input.text", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.text");
});
it('should initialize to model', function() {
expect(binding('text')).toEqual('guest');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function() {
input('text').enter('');
expect(binding('text')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
it('should be invalid if multi word', function() {
input('text').enter('hello world');
expect(binding('myForm.input.$valid')).toEqual('false');
});
it('should not be trimmed', function() {
input('text').enter('untrimmed ');
expect(binding('text')).toEqual('untrimmed ');
expect(binding('myForm.input.$valid')).toEqual('true');
});
});
describe("api/ng.directive:input.number", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.number");
});
it('should initialize to model', function() {
expect(binding('value')).toEqual('12');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function() {
input('value').enter('');
expect(binding('value')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
it('should be invalid if over max', function() {
input('value').enter('123');
expect(binding('value')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
});
describe("api/ng.directive:input.url", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.url");
});
it('should initialize to model', function() {
expect(binding('text')).toEqual('http://google.com');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function() {
input('text').enter('');
expect(binding('text')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
it('should be invalid if not url', function() {
input('text').enter('xxx');
expect(binding('myForm.input.$valid')).toEqual('false');
});
});
describe("api/ng.directive:input.email", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.email");
});
it('should initialize to model', function() {
expect(binding('text')).toEqual('me@example.com');
expect(binding('myForm.input.$valid')).toEqual('true');
});
it('should be invalid if empty', function() {
input('text').enter('');
expect(binding('text')).toEqual('');
expect(binding('myForm.input.$valid')).toEqual('false');
});
it('should be invalid if not email', function() {
input('text').enter('xxx');
expect(binding('myForm.input.$valid')).toEqual('false');
});
});
describe("api/ng.directive:input.radio", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.radio");
});
it('should change state', function() {
expect(binding('color')).toEqual('blue');
input('color').select('red');
expect(binding('color')).toEqual('red');
});
});
describe("api/ng.directive:input.checkbox", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input.checkbox");
});
it('should change state', function() {
expect(binding('value1')).toEqual('true');
expect(binding('value2')).toEqual('YES');
input('value1').check();
input('value2').check();
expect(binding('value1')).toEqual('false');
expect(binding('value2')).toEqual('NO');
});
});
describe("api/ng.directive:textarea", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:textarea");
});
});
describe("api/ng.directive:input", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:input");
});
it('should initialize to model', function() {
expect(binding('user')).toEqual('{"name":"guest","last":"visitor"}');
expect(binding('myForm.userName.$valid')).toEqual('true');
expect(binding('myForm.$valid')).toEqual('true');
});
it('should be invalid if empty when required', function() {
input('user.name').enter('');
expect(binding('user')).toEqual('{"last":"visitor"}');
expect(binding('myForm.userName.$valid')).toEqual('false');
expect(binding('myForm.$valid')).toEqual('false');
});
it('should be valid if empty when min length is set', function() {
input('user.last').enter('');
expect(binding('user')).toEqual('{"name":"guest","last":""}');
expect(binding('myForm.lastName.$valid')).toEqual('true');
expect(binding('myForm.$valid')).toEqual('true');
});
it('should be invalid if less than required min length', function() {
input('user.last').enter('xx');
expect(binding('user')).toEqual('{"name":"guest"}');
expect(binding('myForm.lastName.$valid')).toEqual('false');
expect(binding('myForm.lastName.$error')).toMatch(/minlength/);
expect(binding('myForm.$valid')).toEqual('false');
});
it('should be invalid if longer than max length', function() {
input('user.last').enter('some ridiculously long name');
expect(binding('user'))
.toEqual('{"name":"guest"}');
expect(binding('myForm.lastName.$valid')).toEqual('false');
expect(binding('myForm.lastName.$error')).toMatch(/maxlength/);
expect(binding('myForm.$valid')).toEqual('false');
});
});
describe("api/ng.directive:ngModel.NgModelController", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngModel.NgModelController");
});
it('should data-bind and become invalid', function() {
var contentEditable = element('[contenteditable]');
expect(contentEditable.text()).toEqual('Change me!');
input('userContent').enter('');
expect(contentEditable.text()).toEqual('');
expect(contentEditable.prop('className')).toMatch(/ng-invalid-required/);
});
});
describe("api/ng.directive:ngModel", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngModel");
});
});
describe("api/ng.directive:ngChange", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngChange");
});
it('should evaluate the expression if changing from view', function() {
expect(binding('counter')).toEqual('0');
element('#ng-change-example1').click();
expect(binding('counter')).toEqual('1');
expect(binding('confirmed')).toEqual('true');
});
it('should not evaluate the expression if changing from model', function() {
element('#ng-change-example2').click();
expect(binding('counter')).toEqual('0');
expect(binding('confirmed')).toEqual('true');
});
});
describe("api/ng.directive:ngList", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngList");
});
it('should initialize to model', function() {
expect(binding('names')).toEqual('["igor","misko","vojta"]');
expect(binding('myForm.namesInput.$valid')).toEqual('true');
expect(element('span.error').css('display')).toBe('none');
});
it('should be invalid if empty', function() {
input('names').enter('');
expect(binding('names')).toEqual('');
expect(binding('myForm.namesInput.$valid')).toEqual('false');
expect(element('span.error').css('display')).not().toBe('none');
});
});
describe("api/ng.directive:ngValue", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngValue");
});
it('should initialize to model', function() {
expect(binding('my.favorite')).toEqual('unicorns');
});
it('should bind the values to the inputs', function() {
input('my.favorite').select('pizza');
expect(binding('my.favorite')).toEqual('pizza');
});
});
describe("api/ng.directive:ngClass", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngClass");
});
it('should let you toggle the class', function() {
expect(element('.doc-example-live p:first').prop('className')).not().toMatch(/bold/);
expect(element('.doc-example-live p:first').prop('className')).not().toMatch(/red/);
input('important').check();
expect(element('.doc-example-live p:first').prop('className')).toMatch(/bold/);
input('error').check();
expect(element('.doc-example-live p:first').prop('className')).toMatch(/red/);
});
it('should let you toggle string example', function() {
expect(element('.doc-example-live p:nth-of-type(2)').prop('className')).toBe('');
input('style').enter('red');
expect(element('.doc-example-live p:nth-of-type(2)').prop('className')).toBe('red');
});
it('array example should have 3 classes', function() {
expect(element('.doc-example-live p:last').prop('className')).toBe('');
input('style1').enter('bold');
input('style2').enter('strike');
input('style3').enter('red');
expect(element('.doc-example-live p:last').prop('className')).toBe('bold strike red');
});
it('should check ng-class', function() {
expect(element('.doc-example-live span').prop('className')).not().
toMatch(/my-class/);
using('.doc-example-live').element(':button:first').click();
expect(element('.doc-example-live span').prop('className')).
toMatch(/my-class/);
using('.doc-example-live').element(':button:last').click();
expect(element('.doc-example-live span').prop('className')).not().
toMatch(/my-class/);
});
});
describe("api/ng.directive:ngClassOdd", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngClassOdd");
});
it('should check ng-class-odd and ng-class-even', function() {
expect(element('.doc-example-live li:first span').prop('className')).
toMatch(/odd/);
expect(element('.doc-example-live li:last span').prop('className')).
toMatch(/even/);
});
});
describe("api/ng.directive:ngClassEven", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngClassEven");
});
it('should check ng-class-odd and ng-class-even', function() {
expect(element('.doc-example-live li:first span').prop('className')).
toMatch(/odd/);
expect(element('.doc-example-live li:last span').prop('className')).
toMatch(/even/);
});
});
describe("api/ng.directive:ngCloak", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngCloak");
});
it('should remove the template directive and css class', function() {
expect(element('.doc-example-live #template1').attr('ng-cloak')).
not().toBeDefined();
expect(element('.doc-example-live #template2').attr('ng-cloak')).
not().toBeDefined();
});
});
describe("api/ng.directive:ngController", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngController");
});
it('should check controller as', function() {
expect(element('#ctrl-as-exmpl>:input').val()).toBe('John Smith');
expect(element('#ctrl-as-exmpl li:nth-child(1) input').val())
.toBe('408 555 1212');
expect(element('#ctrl-as-exmpl li:nth-child(2) input').val())
.toBe('john.smith@example.org');
element('#ctrl-as-exmpl li:first a:contains("clear")').click();
expect(element('#ctrl-as-exmpl li:first input').val()).toBe('');
element('#ctrl-as-exmpl li:last a:contains("add")').click();
expect(element('#ctrl-as-exmpl li:nth-child(3) input').val())
.toBe('yourname@example.org');
});
it('should check controller', function() {
expect(element('#ctrl-exmpl>:input').val()).toBe('John Smith');
expect(element('#ctrl-exmpl li:nth-child(1) input').val())
.toBe('408 555 1212');
expect(element('#ctrl-exmpl li:nth-child(2) input').val())
.toBe('john.smith@example.org');
element('#ctrl-exmpl li:first a:contains("clear")').click();
expect(element('#ctrl-exmpl li:first input').val()).toBe('');
element('#ctrl-exmpl li:last a:contains("add")').click();
expect(element('#ctrl-exmpl li:nth-child(3) input').val())
.toBe('yourname@example.org');
});
});
describe("api/ng.directive:ngCsp", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngCsp");
});
});
describe("api/ng.directive:ngClick", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngClick");
});
});
describe("api/ng.directive:ngDblclick", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngDblclick");
});
});
describe("api/ng.directive:ngMousedown", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMousedown");
});
});
describe("api/ng.directive:ngMouseup", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMouseup");
});
});
describe("api/ng.directive:ngMouseover", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMouseover");
});
});
describe("api/ng.directive:ngMouseenter", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMouseenter");
});
});
describe("api/ng.directive:ngMouseleave", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMouseleave");
});
});
describe("api/ng.directive:ngMousemove", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngMousemove");
});
});
describe("api/ng.directive:ngKeydown", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngKeydown");
});
});
describe("api/ng.directive:ngKeyup", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngKeyup");
});
});
describe("api/ng.directive:ngKeypress", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngKeypress");
});
});
describe("api/ng.directive:ngSubmit", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngSubmit");
});
it('should check ng-submit', function() {
expect(binding('list')).toBe('[]');
element('.doc-example-live #submit').click();
expect(binding('list')).toBe('["hello"]');
expect(input('text').val()).toBe('');
});
it('should ignore empty strings', function() {
expect(binding('list')).toBe('[]');
element('.doc-example-live #submit').click();
element('.doc-example-live #submit').click();
expect(binding('list')).toBe('["hello"]');
});
});
describe("api/ng.directive:ngFocus", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngFocus");
});
});
describe("api/ng.directive:ngBlur", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngBlur");
});
});
describe("api/ng.directive:ngCopy", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngCopy");
});
});
describe("api/ng.directive:ngCut", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngCut");
});
});
describe("api/ng.directive:ngPaste", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngPaste");
});
});
describe("api/ng.directive:ngIf", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngIf");
});
});
describe("api/ng.directive:ngInclude", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngInclude");
});
it('should load template1.html', function() {
expect(element('.doc-example-live [ng-include]').text()).
toMatch(/Content of template1.html/);
});
it('should load template2.html', function() {
select('template').option('1');
expect(element('.doc-example-live [ng-include]').text()).
toMatch(/Content of template2.html/);
});
it('should change to blank', function() {
select('template').option('');
expect(element('.doc-example-live [ng-include]')).toBe(undefined);
});
});
describe("api/ng.directive:ngInit", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngInit");
});
it('should alias index positions', function() {
expect(element('.example-init').text())
.toBe('list[ 0 ][ 0 ] = a;' +
'list[ 0 ][ 1 ] = b;' +
'list[ 1 ][ 0 ] = c;' +
'list[ 1 ][ 1 ] = d;');
});
});
describe("api/ng.directive:ngNonBindable", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngNonBindable");
});
it('should check ng-non-bindable', function() {
expect(using('.doc-example-live').binding('1 + 2')).toBe('3');
expect(using('.doc-example-live').element('div:last').text()).
toMatch(/1 \+ 2/);
});
});
describe("api/ng.directive:ngPluralize", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngPluralize");
});
it('should show correct pluralized string', function() {
expect(element('.doc-example-live ng-pluralize:first').text()).
toBe('1 person is viewing.');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Igor is viewing.');
using('.doc-example-live').input('personCount').enter('0');
expect(element('.doc-example-live ng-pluralize:first').text()).
toBe('Nobody is viewing.');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Nobody is viewing.');
using('.doc-example-live').input('personCount').enter('2');
expect(element('.doc-example-live ng-pluralize:first').text()).
toBe('2 people are viewing.');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Igor and Misko are viewing.');
using('.doc-example-live').input('personCount').enter('3');
expect(element('.doc-example-live ng-pluralize:first').text()).
toBe('3 people are viewing.');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Igor, Misko and one other person are viewing.');
using('.doc-example-live').input('personCount').enter('4');
expect(element('.doc-example-live ng-pluralize:first').text()).
toBe('4 people are viewing.');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Igor, Misko and 2 other people are viewing.');
});
it('should show data-binded names', function() {
using('.doc-example-live').input('personCount').enter('4');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Igor, Misko and 2 other people are viewing.');
using('.doc-example-live').input('person1').enter('Di');
using('.doc-example-live').input('person2').enter('Vojta');
expect(element('.doc-example-live ng-pluralize:last').text()).
toBe('Di, Vojta and 2 other people are viewing.');
});
});
describe("api/ng.directive:ngRepeat", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngRepeat");
});
it('should render initial data set', function() {
var r = using('.doc-example-live').repeater('ul li');
expect(r.count()).toBe(10);
expect(r.row(0)).toEqual(["1","John","25"]);
expect(r.row(1)).toEqual(["2","Jessie","30"]);
expect(r.row(9)).toEqual(["10","Samantha","60"]);
expect(binding('friends.length')).toBe("10");
});
it('should update repeater when filter predicate changes', function() {
var r = using('.doc-example-live').repeater('ul li');
expect(r.count()).toBe(10);
input('q').enter('ma');
expect(r.count()).toBe(2);
expect(r.row(0)).toEqual(["1","Mary","28"]);
expect(r.row(1)).toEqual(["2","Samantha","60"]);
});
});
describe("api/ng.directive:ngShow", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngShow");
});
it('should check ng-show / ng-hide', function() {
expect(element('.doc-example-live span:first:hidden').count()).toEqual(1);
expect(element('.doc-example-live span:last:visible').count()).toEqual(1);
input('checked').check();
expect(element('.doc-example-live span:first:visible').count()).toEqual(1);
expect(element('.doc-example-live span:last:hidden').count()).toEqual(1);
});
});
describe("api/ng.directive:ngHide", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngHide");
});
it('should check ng-show / ng-hide', function() {
expect(element('.doc-example-live .check-element:first:hidden').count()).toEqual(1);
expect(element('.doc-example-live .check-element:last:visible').count()).toEqual(1);
input('checked').check();
expect(element('.doc-example-live .check-element:first:visible').count()).toEqual(1);
expect(element('.doc-example-live .check-element:last:hidden').count()).toEqual(1);
});
});
describe("api/ng.directive:ngStyle", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngStyle");
});
it('should check ng-style', function() {
expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
element('.doc-example-live :button[value=set]').click();
expect(element('.doc-example-live span').css('color')).toBe('rgb(255, 0, 0)');
element('.doc-example-live :button[value=clear]').click();
expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
});
});
describe("api/ng.directive:ngSwitch", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngSwitch");
});
it('should start in settings', function() {
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Settings Div/);
});
it('should change to home', function() {
select('selection').option('home');
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Home Span/);
});
it('should select default', function() {
select('selection').option('other');
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/default/);
});
});
describe("api/ng.directive:ngTransclude", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:ngTransclude");
});
it('should have transcluded', function() {
input('title').enter('TITLE');
input('text').enter('TEXT');
expect(binding('title')).toEqual('TITLE');
expect(binding('text')).toEqual('TEXT');
});
});
describe("api/ng.directive:script", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:script");
});
it('should load template defined inside script tag', function() {
element('#tpl-link').click();
expect(element('#tpl-content').text()).toMatch(/Content of the template/);
});
});
describe("api/ng.directive:select", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.directive:select");
});
it('should check ng-options', function() {
expect(binding('{selected_color:color}')).toMatch('red');
select('color').option('0');
expect(binding('{selected_color:color}')).toMatch('black');
using('.nullable').select('color').option('');
expect(binding('{selected_color:color}')).toMatch('null');
});
});
describe("api/ng.$document", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$document");
});
});
describe("api/ng.$exceptionHandler", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$exceptionHandler");
});
});
describe("api/ng.filter:limitTo", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:limitTo");
});
it('should limit the number array to first three items', function() {
expect(element('.doc-example-live input[ng-model=numLimit]').val()).toBe('3');
expect(element('.doc-example-live input[ng-model=letterLimit]').val()).toBe('3');
expect(binding('numbers | limitTo:numLimit')).toEqual('[1,2,3]');
expect(binding('letters | limitTo:letterLimit')).toEqual('abc');
});
it('should update the output when -3 is entered', function() {
input('numLimit').enter(-3);
input('letterLimit').enter(-3);
expect(binding('numbers | limitTo:numLimit')).toEqual('[7,8,9]');
expect(binding('letters | limitTo:letterLimit')).toEqual('ghi');
});
it('should not exceed the maximum size of input array', function() {
input('numLimit').enter(100);
input('letterLimit').enter(100);
expect(binding('numbers | limitTo:numLimit')).toEqual('[1,2,3,4,5,6,7,8,9]');
expect(binding('letters | limitTo:letterLimit')).toEqual('abcdefghi');
});
});
describe("api/ng.filter:filter", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:filter");
});
it('should search across all fields when filtering with a string', function() {
input('searchText').enter('m');
expect(repeater('#searchTextResults tr', 'friend in friends').column('friend.name')).
toEqual(['Mary', 'Mike', 'Adam']);
input('searchText').enter('76');
expect(repeater('#searchTextResults tr', 'friend in friends').column('friend.name')).
toEqual(['John', 'Julie']);
});
it('should search in specific fields when filtering with a predicate object', function() {
input('search.$').enter('i');
expect(repeater('#searchObjResults tr', 'friend in friends').column('friend.name')).
toEqual(['Mary', 'Mike', 'Julie', 'Juliette']);
});
it('should use a equal comparison when comparator is true', function() {
input('search.name').enter('Julie');
input('strict').check();
expect(repeater('#searchObjResults tr', 'friend in friends').column('friend.name')).
toEqual(['Julie']);
});
});
describe("api/ng.filter:currency", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:currency");
});
it('should init with 1234.56', function() {
expect(binding('amount | currency')).toBe('$1,234.56');
expect(binding('amount | currency:"USD$"')).toBe('USD$1,234.56');
});
it('should update', function() {
input('amount').enter('-1234');
expect(binding('amount | currency')).toBe('($1,234.00)');
expect(binding('amount | currency:"USD$"')).toBe('(USD$1,234.00)');
});
});
describe("api/ng.filter:number", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:number");
});
it('should format numbers', function() {
expect(binding('val | number')).toBe('1,234.568');
expect(binding('val | number:0')).toBe('1,235');
expect(binding('-val | number:4')).toBe('-1,234.5679');
});
it('should update', function() {
input('val').enter('3374.333');
expect(binding('val | number')).toBe('3,374.333');
expect(binding('val | number:0')).toBe('3,374');
expect(binding('-val | number:4')).toBe('-3,374.3330');
});
});
describe("api/ng.filter:date", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:date");
});
it('should format date', function() {
expect(binding("1288323623006 | date:'medium'")).
toMatch(/Oct 2\d, 2010 \d{1,2}:\d{2}:\d{2} (AM|PM)/);
expect(binding("1288323623006 | date:'yyyy-MM-dd HH:mm:ss Z'")).
toMatch(/2010\-10\-2\d \d{2}:\d{2}:\d{2} (\-|\+)?\d{4}/);
expect(binding("'1288323623006' | date:'MM/dd/yyyy @ h:mma'")).
toMatch(/10\/2\d\/2010 @ \d{1,2}:\d{2}(AM|PM)/);
});
});
describe("api/ng.filter:json", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:json");
});
it('should jsonify filtered objects', function() {
expect(binding("{'name':'value'}")).toMatch(/\{\n "name": ?"value"\n}/);
});
});
describe("api/ng.filter:lowercase", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:lowercase");
});
});
describe("api/ng.filter:uppercase", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:uppercase");
});
});
describe("api/ng.filter:orderBy", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.filter:orderBy");
});
it('should be reverse ordered by aged', function() {
expect(binding('predicate')).toBe('-age');
expect(repeater('table.friend', 'friend in friends').column('friend.age')).
toEqual(['35', '29', '21', '19', '10']);
expect(repeater('table.friend', 'friend in friends').column('friend.name')).
toEqual(['Adam', 'Julie', 'Mike', 'Mary', 'John']);
});
it('should reorder the table when user selects different predicate', function() {
element('.doc-example-live a:contains("Name")').click();
expect(repeater('table.friend', 'friend in friends').column('friend.name')).
toEqual(['Adam', 'John', 'Julie', 'Mary', 'Mike']);
expect(repeater('table.friend', 'friend in friends').column('friend.age')).
toEqual(['35', '10', '29', '19', '21']);
element('.doc-example-live a:contains("Phone")').click();
expect(repeater('table.friend', 'friend in friends').column('friend.phone')).
toEqual(['555-9876', '555-8765', '555-5678', '555-4321', '555-1212']);
expect(repeater('table.friend', 'friend in friends').column('friend.name')).
toEqual(['Mary', 'Julie', 'Adam', 'Mike', 'John']);
});
});
describe("api/ng.$filterProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$filterProvider");
});
});
describe("api/ng.$filter", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$filter");
});
});
describe("api/ng.$httpBackend", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$httpBackend");
});
});
describe("api/ng.$http", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$http");
});
it('should make an xhr GET request', function() {
element(':button:contains("Sample GET")').click();
element(':button:contains("fetch")').click();
expect(binding('status')).toBe('200');
expect(binding('data')).toMatch(/Hello, \$http!/);
});
it('should make a JSONP request to angularjs.org', function() {
element(':button:contains("Sample JSONP")').click();
element(':button:contains("fetch")').click();
expect(binding('status')).toBe('200');
expect(binding('data')).toMatch(/Super Hero!/);
});
it('should make JSONP request to invalid URL and invoke the error handler',
function() {
element(':button:contains("Invalid JSONP")').click();
element(':button:contains("fetch")').click();
expect(binding('status')).toBe('0');
expect(binding('data')).toBe('Request failed');
});
});
describe("api/ng.$interpolateProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$interpolateProvider");
});
it('should interpolate binding with custom symbols', function() {
expect(binding('demo.label')).toBe('This binding is brought you by // interpolation symbols.');
});
});
describe("api/ng.$interpolate", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$interpolate");
});
});
describe("api/ng.$interval", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$interval");
});
});
describe("api/ng.$locale", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$locale");
});
});
describe("api/ng.$location", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$location");
});
});
describe("api/ng.$locationProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$locationProvider");
});
});
describe("api/ng.$log", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$log");
});
});
describe("api/ng.$logProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$logProvider");
});
});
describe("api/ng.$parse", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$parse");
});
});
describe("api/ng.$parseProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$parseProvider");
});
});
describe("api/ng.$q", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$q");
});
});
describe("api/ng.$rootElement", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$rootElement");
});
});
describe("api/ng.$rootScopeProvider", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$rootScopeProvider");
});
});
describe("api/ng.$rootScope", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$rootScope");
});
});
describe("api/ng.$rootScope.Scope", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$rootScope.Scope");
});
});
describe("api/ng.$timeout", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$timeout");
});
});
describe("api/ng.$sceDelegate", function() {
beforeEach(function() {
browser().navigateTo("index-nocache.html#!/api/ng.$sceDelegate");
});
});
describe("api/ng.$sceDelegateProvider", function() {
beforeEach(function() {
browser().navigateTo("index-noc