How to use ctrl method in Protractor

Best JavaScript code snippet using protractor

controllers.js

Source:controllers.js Github

copy

Full Screen

1/// <reference path="controllers/businessProfile/BusinessProfileEditSelectCountryCtrl.js" />2/// <reference path="controllers/businessProfile/BusinessProfileEditSelectCountryCtrl.js" />3angular.module('starter.controllers', ['ngOpenFB'])4.controller('StartCtrl', StartCtrl)5.controller('SignupCtrl', SignupCtrl)6.controller('PasswordCtrl', PasswordCtrl)7.controller('ConfirmEmailCtrl', ConfirmEmailCtrl)8.controller('LoginCtrl', LoginCtrl)9.controller('forgotpasswordCtrl', forgotpasswordCtrl)10.controller('TabsCtrl', TabsCtrl)11.controller('CheckInCtrl', CheckInCtrl)12.controller('NewsfeedsCtrl', NewsfeedsCtrl)13.controller('NewsfeedCtrl', NewsfeedCtrl)14.controller('NewsfeedBusinessProfileCtrl', NewsfeedBusinessProfileCtrl)15.controller('NewsfeedUserProfileCtrl', NewsfeedUserProfileCtrl)16.controller('NewsfeedsAddABusinessCtrl', NewsfeedsAddABusinessCtrl)17.controller('NewsfeedsAddABusinessCountryCtrl', NewsfeedsAddABusinessCountryCtrl)18.controller('NewsfeedsAddABusinessCityCtrl', NewsfeedsAddABusinessCityCtrl)19.controller('NewsfeedsAddABusinessCategoriesCtrl', NewsfeedsAddABusinessCategoriesCtrl)20.controller('NewsfeedsAddABusinessCategorySubCategoriesCtrl', NewsfeedsAddABusinessCategorySubCategoriesCtrl)21.controller('NewsfeedsSearchCtrl', NewsfeedsSearchCtrl)22.controller('BusinessProfileClaimCodeCtrl', BusinessProfileClaimCodeCtrl)23.controller('SupportCtrl', SupportCtrl)24.controller('MyBusinessProfileCtrl', MyBusinessProfileCtrl)25.controller('MyBusinessProfileEditCtrl', MyBusinessProfileEditCtrl)26.controller('MyBusinessProfileEditSelectCountryCtrl', MyBusinessProfileEditSelectCountryCtrl)27.controller('MyBusinessProfileEditSelectCityCtrl', MyBusinessProfileEditSelectCityCtrl)28.controller('MyBusinessProfileEditSelectCategory', MyBusinessProfileEditSelectCategory)29.controller('MyBusinessProfileEditSelectSubCategory', MyBusinessProfileEditSelectSubCategory)30.controller('MyBusinessProfileAddReviewCtrl', MyBusinessProfileAddReviewCtrl)31.controller('MyBusinessProfilePhotoReviewCtrl', MyBusinessProfilePhotoReviewCtrl)32.controller('MyBusinessProfileMessagesCtrl', MyBusinessProfileMessagesCtrl)33.controller('MyBusinessProfileMoreCtrl', MyBusinessProfileMoreCtrl)34.controller('MyBusinessProfileMoreInfoCtrl', MyBusinessProfileMoreInfoCtrl)35.controller('MyBusinessProfileMoreInfoFollowersCtrl', MyBusinessProfileMoreInfoFollowersCtrl)36.controller('MyBusinessProfileGallaryCtrl', MyBusinessProfileGallaryCtrl)37.controller('MyBusinessMessagesChatersCtrl', MyBusinessMessagesChatersCtrl)38.controller('MyBusinessMessagesChatCtrl', MyBusinessMessagesChatCtrl)39.controller('BusinessProfileCtrl', BusinessProfileCtrl)40.controller('BusinessProfileAddReviewCtrl', BusinessProfileAddReviewCtrl)41.controller('BusinessProfilePhotoReviewCtrl', BusinessProfilePhotoReviewCtrl)42.controller('BusinessProfileAddRatingCtrl', BusinessProfileAddRatingCtrl)43.controller('BusinessProfileMoreCtrl', BusinessProfileMoreCtrl)44.controller('BusinessProfileMoreInfoFollowersCtrl', BusinessProfileMoreInfoFollowersCtrl)45.controller('BusinessProfileEditCtrl', BusinessProfileEditCtrl)46.controller('BusinessProfileEditSelectCountryCtrl', BusinessProfileEditSelectCountryCtrl)47.controller('BusinessProfileEditSelectCityCtrl', BusinessProfileEditSelectCityCtrl)48.controller('BusinessProfileEditSelectCategory', BusinessProfileEditSelectCategory)49.controller('BusinessProfileEditSelectSubCategory', BusinessProfileEditSelectSubCategory)50.controller('BusinessProfileClaimCtrl', BusinessProfileClaimCtrl)51.controller('BusinessProfileClaimSelectCategoryCtrl', BusinessProfileClaimSelectCategoryCtrl)52.controller('BusinessProfileClaimSelectCategorysubcategoryCtrl', BusinessProfileClaimSelectCategorysubcategoryCtrl)53.controller('BusinessProfileMoreInfoCtrl', BusinessProfileMoreInfoCtrl)54.controller('BusinessProfileMoreMessagesCtrl', BusinessProfileMoreMessagesCtrl)55.controller('BusinessProfileReviewCommentCtrl', BusinessProfileReviewCommentCtrl)56.controller('BusinessProfileGallaryCtrl', BusinessProfileGallaryCtrl)57.controller('UserProfileCtrl', UserProfileCtrl)58.controller('UserProfileMessageCtrl', UserProfileMessageCtrl)59.controller('UserProfileReviewCtrl', UserProfileReviewCtrl)60.controller('UserProfilePhotoCtrl', UserProfilePhotoCtrl)61.controller('UserProfileInfoCtrl', UserProfileInfoCtrl)62.controller('UserProfileInfoFriendsCtrl', UserProfileInfoFriendsCtrl)63.controller('UserProfileInfoFavouritesCtrl', UserProfileInfoFavouritesCtrl)64.controller('UserProfileCommentCtrl', UserProfileCommentCtrl)65.controller('MyProfileCtrl', MyProfileCtrl)66.controller('MyProfilePhotoesCtrl', MyProfilePhotoesCtrl)67.controller('MyProfileSettingsCtrl', MyProfileSettingsCtrl)68.controller('MyProfileInfoEditCtrl', MyProfileInfoEditCtrl)69.controller('MyProfileCountryCtrl', MyProfileCountryCtrl)70.controller('MyProfileCityCtrl', MyProfileCityCtrl)71.controller('MyProfileMessages', MyProfileMessages)72.controller('MyProfileMessageChats', MyProfileMessageChats)73.controller('PeopleAmFollowingCtrl', PeopleAmFollowingCtrl)74.controller('MyProfileEventsCtrl', MyProfileEventsCtrl)75.controller('MyProfileFollowersCtrl', MyProfileFollowersCtrl)76.controller('MyProfileMyBusinessesCtrl', MyProfileMyBusinessesCtrl)77.controller('MyProfileBusinessesFollowedByUserCtrl', MyProfileBusinessesFollowedByUserCtrl)78.controller('MyProfileBusinessesAddedByMeCtrl', MyProfileBusinessesAddedByMeCtrl)79.controller('MyProfileFriendsCtrl', MyProfileFriendsCtrl)80.controller('MyNewsfeedsCtrl',MyNewsfeedsCtrl)81.controller('RegisterCtrl', RegisterCtrl)82.controller('SubCategoryCtrl', SubCategoryCtrl)83.controller('SubCategoryResultsCtrl', SubCategoryResultsCtrl)84.controller('SubCategoryBusinessCtrl', SubCategoryBusinessCtrl)85.controller('SubCategoryAddBusinessReviewCtrl', SubCategoryAddBusinessReviewCtrl)86.controller('CheckInFormCtrl', CheckInFormCtrl)87.controller('NotificationsCtrl', NotificationsCtrl)88.controller('NotificationNewsfeedCtrl', NotificationNewsfeedCtrl)89.controller('MoreCtrl', MoreCtrl)90.controller('MoreFavouritesCtrl', MoreFavouritesCtrl)91.controller('MoreEventsCtrl', MoreEventsCtrl)92.controller('MoreGossipCtrl', MoreGossipCtrl)93.controller('MoreBusinessMessagesCtrl', MoreBusinessMessagesCtrl)94.controller('MoreBusinessMessageChatCtrl', MoreBusinessMessageChatCtrl)95.controller('MoreFindFriendsCtrl', MoreFindFriendsCtrl)96.controller('MoreFriendRequestsCtrl', MoreFriendRequestsCtrl)97.controller('MoreFindFriendsCountriesCtrl', MoreFindFriendsCountriesCtrl)98.controller('MoreFindFriendsCityCtrl', MoreFindFriendsCityCtrl)99.controller('MoreAboutCtrl', MoreAboutCtrl)100.controller('MoreSupportCtrl', MoreSupportCtrl)101.controller('MoreBusinessToClaimCtrl', MoreBusinessToClaimCtrl)102.controller('MoreBusinessToClaimPageCtrl', MoreBusinessToClaimPageCtrl)103.controller('MoreAddAbusinessCtrl', MoreAddAbusinessCtrl)104.controller('MoreAddABusinessCountryCtrl', MoreAddABusinessCountryCtrl)105.controller('MoreAddABusinessCityCtrl', MoreAddABusinessCityCtrl)106.controller('MoreAddABusinessCategoriesCtrl', MoreAddABusinessCategoriesCtrl)107.controller('MoreAddABusinessCategoriesSubCategoriesCtrl', MoreAddABusinessCategoriesSubCategoriesCtrl)108.controller('MoreMyBusinessMessagesCtrl', MoreMyBusinessMessagesCtrl)109.controller('MoreBusinessMessagesChatersCtrl', MoreBusinessMessagesChatersCtrl)110.controller('MoreBusinessMessagesChatCtrl', MoreBusinessMessagesChatCtrl)111.controller('MoreCinemaCtrl', MoreCinemaCtrl)112.controller('MoreSelectMovieCtrl', MoreSelectMovieCtrl)113.controller('MoreSelectDateCtrl', MoreSelectDateCtrl)114.controller('MoreShowTimeCtrl', MoreShowTimeCtrl)115.controller('MoreSelectSeatsCtrl', MoreSelectSeatsCtrl)116.controller('MoreViewBookingCtrl', MoreViewBookingCtrl)117.controller('MorePaymentMethodCtrl', MorePaymentMethodCtrl)118.controller('MorePaymentFinishedCtrl', MorePaymentFinishedCtrl)119.controller('MorePurchaseCtrl', MorePurchaseCtrl)120.controller('MorePendingTicketsCtrl', MorePendingTicketsCtrl)121.controller('MoreMyTicketsCtrl', MoreMyTicketsCtrl)122.controller('MoreMyMovieReceiptCtrl', MoreMyMovieReceiptCtrl)123.controller('MoreProfileCtrl', MoreProfileCtrl)124.controller('MoreProfileMyBussinessCtrl', MoreProfileMyBussinessCtrl)125.controller('MoreProfileMyMessagesCtrl', MoreProfileMyMessagesCtrl)126.controller('MoreProfileMyMessagesMyMessageCtrl', MoreProfileMyMessagesMyMessageCtrl)127.controller('MoreProfileMyBussinessBussinessCtrl', MoreProfileMyBussinessBussinessCtrl)128//directives...

Full Screen

Full Screen

paging.spec.js

Source:paging.spec.js Github

copy

Full Screen

1describe('paging factory', function() {2 var $rootScope, $scope, ctrl, attrs;3 beforeEach(module('ui.bootstrap.paging'));4 beforeEach(inject(function(_$rootScope_, uibPaging) {5 $rootScope = _$rootScope_;6 $scope = $rootScope.$new();7 ctrl = {};8 attrs = {};9 uibPaging.create(ctrl, $scope, attrs);10 }));11 describe('init', function() {12 var ngModelCtrl, config;13 beforeEach(function() {14 ngModelCtrl = {};15 config = {16 foo: 'bar',17 itemsPerPage: 1218 };19 });20 describe('without itemsPerPage', function() {21 beforeEach(function() {22 ctrl.init(ngModelCtrl, config);23 });24 it('should set the ngModel and config', function() {25 expect(ctrl.ngModelCtrl).toBe(ngModelCtrl);26 expect(ctrl.config).toBe(config);27 });28 it('should properly render the model', function() {29 spyOn(ctrl, 'render');30 ngModelCtrl.$render();31 expect(ctrl.render).toHaveBeenCalled();32 });33 it('should set to default itemsPerPage', function() {34 expect(ctrl.itemsPerPage).toBe(12);35 });36 it('should update the page when total items changes', function() {37 spyOn(ctrl, 'calculateTotalPages').and.returnValue(5);38 spyOn(ctrl, 'updatePage');39 $rootScope.$digest();40 expect(ctrl.calculateTotalPages.calls.count()).toBe(0);41 expect(ctrl.updatePage.calls.count()).toBe(0);42 $scope.totalItems = 10;43 $rootScope.$digest();44 expect(ctrl.calculateTotalPages.calls.count()).toBe(1);45 expect(ctrl.updatePage.calls.count()).toBe(1);46 expect($scope.totalPages).toBe(5);47 $scope.totalItems = undefined;48 $scope.totalPages = 2;49 $rootScope.$digest();50 expect(ctrl.calculateTotalPages.calls.count()).toBe(2);51 expect(ctrl.updatePage.calls.count()).toBe(2);52 expect($scope.totalPages).toBe(5);53 });54 });55 describe('with itemsPerPage', function() {56 beforeEach(function() {57 attrs.itemsPerPage = 'abc';58 $rootScope.abc = 10;59 ctrl.init(ngModelCtrl, config);60 });61 it('should update the page when itemsPerPage changes', function() {62 spyOn(ctrl, 'calculateTotalPages').and.returnValue(5);63 spyOn(ctrl, 'updatePage');64 $rootScope.$digest();65 expect(ctrl.itemsPerPage).toBe(10);66 expect($scope.totalPages).toBe(5);67 expect(ctrl.updatePage).toHaveBeenCalled();68 });69 });70 });71 describe('calculate totalPages', function() {72 it('when itemsPerPage is less than 1', function() {73 ctrl.itemsPerPage = 0;74 $scope.totalItems = 101;75 expect(ctrl.calculateTotalPages()).toBe(1);76 });77 it('when itemsPerPage is greater than 1', function() {78 ctrl.itemsPerPage = 10;79 $scope.totalItems = 101;80 expect(ctrl.calculateTotalPages()).toBe(11);81 });82 });83 describe('render', function() {84 it('should set page to 1 when invalid', function() {85 ctrl.ngModelCtrl.$viewValue = 'abcd';86 $scope.page = 10;87 ctrl.render();88 expect($scope.page).toBe(1);89 });90 it('should set page to view value when valid', function() {91 ctrl.ngModelCtrl.$viewValue = '3';92 $scope.page = 10;93 ctrl.render();94 expect($scope.page).toBe(3);95 });96 });97 describe('select page', function() {98 beforeEach(function() {99 spyOn(ctrl.ngModelCtrl, '$setViewValue');100 ctrl.ngModelCtrl.$render = jasmine.createSpy('ctrl.ngModelCtrl.$render');101 $scope.page = 5;102 $scope.totalPages = 20;103 });104 it('should change the page', function() {105 $scope.selectPage(12);106 expect(ctrl.ngModelCtrl.$setViewValue).toHaveBeenCalledWith(12);107 expect(ctrl.ngModelCtrl.$render).toHaveBeenCalled();108 });109 it('should not change the page to one out of range', function() {110 $scope.selectPage(-1);111 expect(ctrl.ngModelCtrl.$setViewValue).not.toHaveBeenCalled();112 expect(ctrl.ngModelCtrl.$render).not.toHaveBeenCalled();113 $scope.selectPage(21);114 expect(ctrl.ngModelCtrl.$setViewValue).not.toHaveBeenCalled();115 expect(ctrl.ngModelCtrl.$render).not.toHaveBeenCalled();116 });117 describe('on click', function() {118 var evt;119 beforeEach(function() {120 evt = {121 preventDefault: jasmine.createSpy('evt.preventDefault'),122 target: {123 blur: jasmine.createSpy('evt.target.blur')124 }125 };126 });127 it('should prevent default behavior', function() {128 $scope.selectPage(12, evt);129 expect(evt.preventDefault).toHaveBeenCalled();130 });131 it('should not change the page if disabled and from an event', function() {132 $scope.ngDisabled = true;133 $scope.selectPage(12, evt);134 expect(ctrl.ngModelCtrl.$setViewValue).not.toHaveBeenCalled();135 expect(ctrl.ngModelCtrl.$render).not.toHaveBeenCalled();136 });137 it('should blur the element clicked', function() {138 $scope.selectPage(12, evt);139 expect(evt.target.blur).toHaveBeenCalled();140 });141 });142 });143 it('should get the text', function() {144 $scope.fooText = 'bar';145 expect($scope.getText('foo')).toBe('bar');146 });147 it('should get the default text', function() {148 ctrl.config = {149 fooText: 'bar'150 };151 expect($scope.getText('foo')).toBe('bar');152 });153 it('should disable previous button', function() {154 $scope.page = 1;155 expect($scope.noPrevious()).toBe(true);156 });157 it('should enable previous button', function() {158 $scope.page = 2;159 expect($scope.noPrevious()).toBe(false);160 });161 it('should disable next button', function() {162 $scope.page = 10;163 $scope.totalPages = 10;164 expect($scope.noNext()).toBe(true);165 });166 it('should enable next button', function() {167 $scope.page = 9;168 $scope.totalPages = 10;169 expect($scope.noNext()).toBe(false);170 });171 describe('update page', function() {172 beforeEach(function() {173 spyOn($scope, 'selectPage');174 ctrl.ngModelCtrl.$render = jasmine.createSpy('ctrl.ngModelCtrl.$render');175 ctrl.setNumPages = jasmine.createSpy('ctrl.setNumPages');176 $scope.totalPages = 10;177 });178 it('should select the last page if page is above total', function() {179 $scope.page = 12;180 ctrl.updatePage();181 expect(ctrl.setNumPages).toHaveBeenCalledWith($rootScope, 10);182 expect($scope.selectPage).toHaveBeenCalledWith(10);183 expect(ctrl.ngModelCtrl.$render).not.toHaveBeenCalled();184 });185 it('should execute render if page is within range', function() {186 $scope.page = 5;187 ctrl.updatePage();188 expect(ctrl.setNumPages).toHaveBeenCalledWith($rootScope, 10);189 expect($scope.selectPage).not.toHaveBeenCalled();190 expect(ctrl.ngModelCtrl.$render).toHaveBeenCalled();191 });192 });193 describe('gc', function() {194 it('should clear watchers', function() {195 var watcher1 = jasmine.createSpy('watcher1'),196 watcher2 = jasmine.createSpy('watcher2');197 ctrl._watchers = [watcher1, watcher2];198 $scope.$destroy();199 expect(ctrl._watchers.length).toBe(0);200 expect(watcher1).toHaveBeenCalled();201 expect(watcher2).toHaveBeenCalled();202 });203 });...

Full Screen

Full Screen

keymap.js

Source:keymap.js Github

copy

Full Screen

1import { flipCtrlCmd, mac, presto } from "../util/browser"2import { map } from "../util/misc"3import { keyNames } from "./keynames"4export let keyMap = {}5keyMap.basic = {6 "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",7 "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",8 "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",9 "Tab": "defaultTab", "Shift-Tab": "indentAuto",10 "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",11 "Esc": "singleSelection"12}13// Note that the save and find-related commands aren't defined by14// default. User code or addons can define them. Unknown commands15// are simply ignored.16keyMap.pcDefault = {17 "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",18 "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",19 "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",20 "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",21 "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",22 "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",23 "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",24 fallthrough: "basic"25}26// Very basic readline/emacs-style bindings, which are standard on Mac.27keyMap.emacsy = {28 "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",29 "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",30 "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",31 "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",32 "Ctrl-O": "openLine"33}34keyMap.macDefault = {35 "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",36 "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",37 "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",38 "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",39 "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",40 "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",41 "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",42 fallthrough: ["basic", "emacsy"]43}44keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault45// KEYMAP DISPATCH46function normalizeKeyName(name) {47 let parts = name.split(/-(?!$)/)48 name = parts[parts.length - 1]49 let alt, ctrl, shift, cmd50 for (let i = 0; i < parts.length - 1; i++) {51 let mod = parts[i]52 if (/^(cmd|meta|m)$/i.test(mod)) cmd = true53 else if (/^a(lt)?$/i.test(mod)) alt = true54 else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true55 else if (/^s(hift)?$/i.test(mod)) shift = true56 else throw new Error("Unrecognized modifier name: " + mod)57 }58 if (alt) name = "Alt-" + name59 if (ctrl) name = "Ctrl-" + name60 if (cmd) name = "Cmd-" + name61 if (shift) name = "Shift-" + name62 return name63}64// This is a kludge to keep keymaps mostly working as raw objects65// (backwards compatibility) while at the same time support features66// like normalization and multi-stroke key bindings. It compiles a67// new normalized keymap, and then updates the old object to reflect68// this.69export function normalizeKeyMap(keymap) {70 let copy = {}71 for (let keyname in keymap) if (keymap.hasOwnProperty(keyname)) {72 let value = keymap[keyname]73 if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue74 if (value == "...") { delete keymap[keyname]; continue }75 let keys = map(keyname.split(" "), normalizeKeyName)76 for (let i = 0; i < keys.length; i++) {77 let val, name78 if (i == keys.length - 1) {79 name = keys.join(" ")80 val = value81 } else {82 name = keys.slice(0, i + 1).join(" ")83 val = "..."84 }85 let prev = copy[name]86 if (!prev) copy[name] = val87 else if (prev != val) throw new Error("Inconsistent bindings for " + name)88 }89 delete keymap[keyname]90 }91 for (let prop in copy) keymap[prop] = copy[prop]92 return keymap93}94export function lookupKey(key, map, handle, context) {95 map = getKeyMap(map)96 let found = map.call ? map.call(key, context) : map[key]97 if (found === false) return "nothing"98 if (found === "...") return "multi"99 if (found != null && handle(found)) return "handled"100 if (map.fallthrough) {101 if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")102 return lookupKey(key, map.fallthrough, handle, context)103 for (let i = 0; i < map.fallthrough.length; i++) {104 let result = lookupKey(key, map.fallthrough[i], handle, context)105 if (result) return result106 }107 }108}109// Modifier key presses don't count as 'real' key presses for the110// purpose of keymap fallthrough.111export function isModifierKey(value) {112 let name = typeof value == "string" ? value : keyNames[value.keyCode]113 return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"114}115export function addModifierNames(name, event, noShift) {116 let base = name117 if (event.altKey && base != "Alt") name = "Alt-" + name118 if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name119 if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name120 if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name121 return name122}123// Look up the name of a key as indicated by an event object.124export function keyName(event, noShift) {125 if (presto && event.keyCode == 34 && event["char"]) return false126 let name = keyNames[event.keyCode]127 if (name == null || event.altGraphKey) return false128 return addModifierNames(name, event, noShift)129}130export function getKeyMap(val) {131 return typeof val == "string" ? keyMap[val] : val...

Full Screen

Full Screen

emacs_test.js

Source:emacs_test.js Github

copy

Full Screen

1(function() {2 "use strict";3 var Pos = CodeMirror.Pos;4 namespace = "emacs_";5 var eventCache = {};6 function fakeEvent(keyName) {7 var event = eventCache[key];8 if (event) return event;9 var ctrl, shift, alt;10 var key = keyName.replace(/\w+-/g, function(type) {11 if (type == "Ctrl-") ctrl = true;12 else if (type == "Alt-") alt = true;13 else if (type == "Shift-") shift = true;14 return "";15 });16 var code;17 for (var c in CodeMirror.keyNames)18 if (CodeMirror.keyNames[c] == key) { code = c; break; }19 if (c == null) throw new Error("Unknown key: " + key);20 return eventCache[keyName] = {21 type: "keydown", keyCode: code, ctrlKey: ctrl, shiftKey: shift, altKey: alt,22 preventDefault: function(){}, stopPropagation: function(){}23 };24 }25 function sim(name, start /*, actions... */) {26 var keys = Array.prototype.slice.call(arguments, 2);27 testCM(name, function(cm) {28 for (var i = 0; i < keys.length; ++i) {29 var cur = keys[i];30 if (cur instanceof Pos) cm.setCursor(cur);31 else if (cur.call) cur(cm);32 else cm.triggerOnKeyDown(fakeEvent(cur));33 }34 }, {keyMap: "emacs", value: start, mode: "javascript"});35 }36 function at(line, ch) { return function(cm) { eqPos(cm.getCursor(), Pos(line, ch)); }; }37 function txt(str) { return function(cm) { eq(cm.getValue(), str); }; }38 sim("motionHSimple", "abc", "Ctrl-F", "Ctrl-F", "Ctrl-B", at(0, 1));39 sim("motionHMulti", "abcde",40 "Ctrl-4", "Ctrl-F", at(0, 4), "Ctrl--", "Ctrl-2", "Ctrl-F", at(0, 2),41 "Ctrl-5", "Ctrl-B", at(0, 0));42 sim("motionHWord", "abc. def ghi",43 "Alt-F", at(0, 3), "Alt-F", at(0, 8),44 "Ctrl-B", "Alt-B", at(0, 5), "Alt-B", at(0, 0));45 sim("motionHWordMulti", "abc. def ghi ",46 "Ctrl-3", "Alt-F", at(0, 12), "Ctrl-2", "Alt-B", at(0, 5),47 "Ctrl--", "Alt-B", at(0, 8));48 sim("motionVSimple", "a\nb\nc\n", "Ctrl-N", "Ctrl-N", "Ctrl-P", at(1, 0));49 sim("motionVMulti", "a\nb\nc\nd\ne\n",50 "Ctrl-2", "Ctrl-N", at(2, 0), "Ctrl-F", "Ctrl--", "Ctrl-N", at(1, 1),51 "Ctrl--", "Ctrl-3", "Ctrl-P", at(4, 1));52 sim("killYank", "abc\ndef\nghi",53 "Ctrl-F", "Ctrl-Space", "Ctrl-N", "Ctrl-N", "Ctrl-W", "Ctrl-E", "Ctrl-Y",54 txt("ahibc\ndef\ng"));55 sim("killRing", "abcdef",56 "Ctrl-Space", "Ctrl-F", "Ctrl-W", "Ctrl-Space", "Ctrl-F", "Ctrl-W",57 "Ctrl-Y", "Alt-Y",58 txt("acdef"));59 sim("copyYank", "abcd",60 "Ctrl-Space", "Ctrl-E", "Alt-W", "Ctrl-Y",61 txt("abcdabcd"));62 sim("killLineSimple", "foo\nbar", "Ctrl-F", "Ctrl-K", txt("f\nbar"));63 sim("killLineEmptyLine", "foo\n \nbar", "Ctrl-N", "Ctrl-K", txt("foo\nbar"));64 sim("killLineMulti", "foo\nbar\nbaz",65 "Ctrl-F", "Ctrl-F", "Ctrl-K", "Ctrl-K", "Ctrl-K", "Ctrl-A", "Ctrl-Y",66 txt("o\nbarfo\nbaz"));67 sim("moveByParagraph", "abc\ndef\n\n\nhij\nklm\n\n",68 "Ctrl-F", "Ctrl-Down", at(2, 0), "Ctrl-Down", at(6, 0),69 "Ctrl-N", "Ctrl-Up", at(3, 0), "Ctrl-Up", at(0, 0),70 Pos(1, 2), "Ctrl-Down", at(2, 0), Pos(4, 2), "Ctrl-Up", at(3, 0));71 sim("moveByParagraphMulti", "abc\n\ndef\n\nhij\n\nklm",72 "Ctrl-U", "2", "Ctrl-Down", at(3, 0),73 "Shift-Alt-.", "Ctrl-3", "Ctrl-Up", at(1, 0));74 sim("moveBySentence", "sentence one! sentence\ntwo\n\nparagraph two",75 "Alt-E", at(0, 13), "Alt-E", at(1, 3), "Ctrl-F", "Alt-A", at(0, 13));76 sim("moveByExpr", "function foo(a, b) {}",77 "Ctrl-Alt-F", at(0, 8), "Ctrl-Alt-F", at(0, 12), "Ctrl-Alt-F", at(0, 18),78 "Ctrl-Alt-B", at(0, 12), "Ctrl-Alt-B", at(0, 9));79 sim("moveByExprMulti", "foo bar baz bug",80 "Ctrl-2", "Ctrl-Alt-F", at(0, 7),81 "Ctrl--", "Ctrl-Alt-F", at(0, 4),82 "Ctrl--", "Ctrl-2", "Ctrl-Alt-B", at(0, 11));83 sim("delExpr", "var x = [\n a,\n b\n c\n];",84 Pos(0, 8), "Ctrl-Alt-K", txt("var x = ;"), "Ctrl-/",85 Pos(4, 1), "Ctrl-Alt-Backspace", txt("var x = ;"));86 sim("delExprMulti", "foo bar baz",87 "Ctrl-2", "Ctrl-Alt-K", txt(" baz"),88 "Ctrl-/", "Ctrl-E", "Ctrl-2", "Ctrl-Alt-Backspace", txt("foo "));89 sim("justOneSpace", "hi bye ",90 Pos(0, 4), "Alt-Space", txt("hi bye "),91 Pos(0, 4), "Alt-Space", txt("hi b ye "),92 "Ctrl-A", "Alt-Space", "Ctrl-E", "Alt-Space", txt(" hi b ye "));93 sim("openLine", "foo bar", "Alt-F", "Ctrl-O", txt("foo\n bar"))94 sim("transposeChar", "abcd\ne",95 "Ctrl-F", "Ctrl-T", "Ctrl-T", txt("bcad\ne"), at(0, 3),96 "Ctrl-F", "Ctrl-T", "Ctrl-T", "Ctrl-T", txt("bcda\ne"), at(0, 4),97 "Ctrl-F", "Ctrl-T", txt("bcde\na"), at(1, 0));98 sim("manipWordCase", "foo BAR bAZ",99 "Alt-C", "Alt-L", "Alt-U", txt("Foo bar BAZ"),100 "Ctrl-A", "Alt-U", "Alt-L", "Alt-C", txt("FOO bar Baz"));101 sim("manipWordCaseMulti", "foo Bar bAz",102 "Ctrl-2", "Alt-U", txt("FOO BAR bAz"),103 "Ctrl-A", "Ctrl-3", "Alt-C", txt("Foo Bar Baz"));104 sim("upExpr", "foo {\n bar[];\n baz(blah);\n}",105 Pos(2, 7), "Ctrl-Alt-U", at(2, 5), "Ctrl-Alt-U", at(0, 4));106 sim("transposeExpr", "do foo[bar] dah",107 Pos(0, 6), "Ctrl-Alt-T", txt("do [bar]foo dah"));108 sim("clearMark", "abcde", Pos(0, 2), "Ctrl-Space", "Ctrl-F", "Ctrl-F",109 "Ctrl-G", "Ctrl-W", txt("abcde"));110 sim("delRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Delete", txt("cde"));111 sim("backspaceRegion", "abcde", "Ctrl-Space", "Ctrl-F", "Ctrl-F", "Backspace", txt("cde"));112 testCM("save", function(cm) {113 var saved = false;114 CodeMirror.commands.save = function(cm) { saved = cm.getValue(); };115 cm.triggerOnKeyDown(fakeEvent("Ctrl-X"));116 cm.triggerOnKeyDown(fakeEvent("Ctrl-S"));117 is(saved, "hi");118 }, {value: "hi", keyMap: "emacs"});...

Full Screen

Full Screen

network-throttle.client.js

Source:network-throttle.client.js Github

copy

Full Screen

1(function (angular) {2 const SECTION_NAME = "network-throttle";3 angular4 .module("BrowserSync")5 .controller("NetworkThrottleController", [6 "options",7 "pagesConfig",8 "Socket",9 "$scope",10 NetworkThrottleController11 ]);12 /**13 * @param options14 * @param pagesConfig15 * @param Socket16 * @param $scope17 */18 function NetworkThrottleController (options, pagesConfig, Socket, $scope) {19 var ctrl = this;20 ctrl.section = pagesConfig[SECTION_NAME];21 ctrl.options = options.bs;22 ctrl.uiOptions = options.ui;23 ctrl.clientFiles = options.ui.clientFiles || {};24 ctrl.section = pagesConfig[SECTION_NAME];25 ctrl.throttle = ctrl.uiOptions[SECTION_NAME];26 ctrl.selected = ctrl.throttle.targets[0].id;27 ctrl.servers = ctrl.throttle.servers;28 ctrl.port = "";29 ctrl.portEntry = "auto";30 ctrl.serverCount = Object.keys(ctrl.servers).length;31 ctrl.blurs = [];32 ctrl.state = {33 success: false,34 waiting: false,35 classname: "ready"36 };37 ctrl.createServer = function (selected, event) {38 if (ctrl.blurs.indexOf(event.target) === -1) {39 ctrl.blurs.push(event.target);40 }41 var item = getByProp(ctrl.throttle.targets, "id", ctrl.selected);42 if (ctrl.portEntry === "auto") {43 return send("");44 }45 if (!ctrl.port || !ctrl.port.length) {46 setError();47 return;48 }49 if (!ctrl.port.match(/\d{4,5}/)) {50 setError();51 return;52 }53 var port = parseInt(ctrl.port, 10);54 if (port < 1024 || port > 65535) {55 setError();56 return;57 }58 send(ctrl.port);59 function setError() {60 ctrl.state.waiting = false;61 ctrl.state.portError = true;62 }63 function send (port) {64 ctrl.state.classname = "waiting";65 ctrl.state.waiting = true;66 Socket.uiEvent({67 namespace: SECTION_NAME,68 event: "server:create",69 data: {70 speed: item,71 port: port72 }73 });74 }75 };76 ctrl.destroyServer = function (item, port) {77 Socket.uiEvent({78 namespace: SECTION_NAME,79 event: "server:destroy",80 data: {81 speed: item,82 port: port83 }84 });85 };86 ctrl.toggleSpeed = function (item) {87 if (!item.active) {88 item.urls = [];89 }90 };91 ctrl.update = function (data) {92 ctrl.servers = data.servers;93 ctrl.serverCount = Object.keys(ctrl.servers).length;94 if (data.event === "server:create") {95 updateButtonState();96 }97 $scope.$digest();98 };99 function updateButtonState() {100 ctrl.state.success = true;101 ctrl.state.classname = "success";102 setTimeout(function () {103 ctrl.blurs.forEach(function (elem) {104 elem.blur();105 });106 setTimeout(function () {107 ctrl.state.success = false;108 ctrl.state.waiting = false;109 ctrl.state.classname = "ready";110 $scope.$digest();111 }, 500);112 }, 300);113 }114 /**115 * @param collection116 * @param prop117 * @returns {*}118 */119 function getByProp (collection, prop, name) {120 var match = collection.filter(function (item) {121 return item[prop] === name;122 });123 if (match.length) {124 return match[0];125 }126 return false;127 }128 Socket.on("ui:network-throttle:update", ctrl.update);129 $scope.$on("$destroy", function () {130 Socket.off("ui:network-throttle:update", ctrl.update);131 });132 }133 /**134 * Display the snippet when in snippet mode135 */136 angular137 .module("BrowserSync")138 .directive("throttle", function () {139 return {140 restrict: "E",141 replace: true,142 scope: {143 "target": "=",144 "options": "="145 },146 templateUrl: "network-throttle.directive.html",147 controller: ["$scope", "Socket", throttleDirectiveControlller],148 controllerAs: "ctrl"149 };150 });151 /**152 * @param $scope153 */154 function throttleDirectiveControlller ($scope) {155 var ctrl = this;156 ctrl.throttle = $scope.options[SECTION_NAME];157 }...

Full Screen

Full Screen

Control.js

Source:Control.js Github

copy

Full Screen

1(function() {2 module("tinymce.ui.Control");3 test("Initial states", function() {4 var ctrl;5 ctrl = new tinymce.ui.Control({});6 // Check initial states7 equal(ctrl.disabled(), false);8 equal(ctrl.active(), false);9 equal(ctrl.visible(), true);10 equal(ctrl.text(), undefined);11 equal(ctrl.name(), undefined);12 equal(ctrl.title(), undefined);13 equal(ctrl.parent(), undefined);14 deepEqual(ctrl.settings, {});15 });16 test("Settings", function() {17 var ctrl = new tinymce.ui.Control({18 disabled: true,19 active: true,20 visible: true,21 text: 'Text',22 title: 'Title',23 name: 'Name'24 });25 // Check settings states26 equal(ctrl.disabled(), true);27 equal(ctrl.active(), true);28 equal(ctrl.visible(), true);29 equal(ctrl.text(), "Text");30 equal(ctrl.name(), "Name");31 equal(ctrl.title(), "Title");32 equal(ctrl.parent(), undefined);33 deepEqual(ctrl.settings, {34 disabled: true,35 active: true,36 visible: true,37 text: 'Text',38 title: 'Title',39 name: 'Name'40 });41 });42 test("Properties", function() {43 var ctrl, cont;44 cont = new tinymce.ui.Container({});45 ctrl = new tinymce.ui.Control({});46 // Set all states47 ctrl = ctrl.48 disabled(true).49 active(true).50 visible(true).51 text("Text").52 title("Title").53 name("Name").parent(cont);54 // Check states55 equal(ctrl.disabled(), true);56 equal(ctrl.active(), true);57 equal(ctrl.visible(), true);58 equal(ctrl.text(), "Text");59 equal(ctrl.name(), "Name");60 equal(ctrl.title(), "Title");61 equal(ctrl.parent(), cont);62 deepEqual(ctrl.settings, {});63 });64 test("Chained methods", function() {65 var ctrl = new tinymce.ui.Control({});66 // Set all states67 ctrl = ctrl.68 on('click', function() {}).69 off().70 renderTo(document.getElementById('view')).71 remove();72 // Check so that the chain worked73 ok(ctrl instanceof tinymce.ui.Control);74 });75 test("Events", function() {76 var ctrl = new tinymce.ui.Control({77 onMyEvent: function() {78 count++;79 },80 callbacks: {81 handler1: function() {82 count++;83 }84 }85 }), count;86 ctrl.on('MyEvent', function(args) {87 equal(ctrl, args.control);88 equal(ctrl, this);89 equal(args.myKey, 'myVal');90 });91 ctrl.fire('MyEvent', {myKey: 'myVal'});92 function countAndBreak() {93 count++;94 return false;95 }96 // Bind two events97 ctrl.on('MyEvent2', countAndBreak);98 ctrl.on('MyEvent2', countAndBreak);99 // Check if only one of them was called100 count = 0;101 ctrl.fire('MyEvent2', {myKey: 'myVal'});102 equal(count, 1);103 // Fire unbound event104 ctrl.fire('MyEvent3', {myKey: 'myVal'});105 // Unbind all106 ctrl.off();107 count = 0;108 ctrl.fire('MyEvent2', {myKey: 'myVal'});109 equal(count, 0, 'Unbind all');110 // Unbind by name111 ctrl.on('MyEvent1', countAndBreak);112 ctrl.on('MyEvent2', countAndBreak);113 ctrl.off('MyEvent2');114 count = 0;115 ctrl.fire('MyEvent1', {myKey: 'myVal'});116 ctrl.fire('MyEvent2', {myKey: 'myVal'});117 equal(count, 1);118 // Unbind by name callback119 ctrl.on('MyEvent1', countAndBreak);120 ctrl.on('MyEvent1', function() {count++;});121 ctrl.off('MyEvent1', countAndBreak);122 count = 0;123 ctrl.fire('MyEvent1', {myKey: 'myVal'});124 equal(count, 1);125 // Bind by named handler126 ctrl.off();127 ctrl.on('MyEvent', 'handler1');128 count = 0;129 ctrl.fire('MyEvent', {myKey: 'myVal'});130 equal(count, 1);131 });132 test("hasClass,addClass,removeClass", function() {133 var ctrl = new tinymce.ui.Control({classes: 'class1 class2 class3'});134 equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3');135 ok(ctrl.classes.contains('class1'));136 ok(ctrl.classes.contains('class2'));137 ok(ctrl.classes.contains('class3'));138 ok(!ctrl.classes.contains('class4'));139 ctrl.classes.add('class4');140 equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3 mce-class4');141 ok(ctrl.classes.contains('class1'));142 ok(ctrl.classes.contains('class2'));143 ok(ctrl.classes.contains('class3'));144 ok(ctrl.classes.contains('class4'));145 ctrl.classes.remove('class4');146 equal(ctrl.classes, 'mce-class1 mce-class2 mce-class3');147 ok(ctrl.classes.contains('class1'));148 ok(ctrl.classes.contains('class2'));149 ok(ctrl.classes.contains('class3'));150 ok(!ctrl.classes.contains('class4'));151 ctrl.classes.remove('class3').remove('class2');152 equal(ctrl.classes, 'mce-class1');153 ok(ctrl.classes.contains('class1'));154 ok(!ctrl.classes.contains('class2'));155 ok(!ctrl.classes.contains('class3'));156 ctrl.classes.remove('class3').remove('class1');157 equal(ctrl.classes, '');158 ok(!ctrl.classes.contains('class1'));159 ok(!ctrl.classes.contains('class2'));160 ok(!ctrl.classes.contains('class3'));161 });162 test("encode", function() {163 tinymce.i18n.add('en', {'old': '"new"'});164 equal(new tinymce.ui.Control({}).encode('<>"&'), '&#60;&#62;&#34;&#38;');165 equal(new tinymce.ui.Control({}).encode('old'), '&#34;new&#34;');166 equal(new tinymce.ui.Control({}).encode('old', false), 'old');167 });168 test("translate", function() {169 tinymce.i18n.add('en', {'old': 'new'});170 equal(new tinymce.ui.Control({}).translate('old'), 'new');171 equal(new tinymce.ui.Control({}).translate('old2'), 'old2');172 });...

Full Screen

Full Screen

paging.js

Source:paging.js Github

copy

Full Screen

1angular.module('ui.bootstrap.paging', [])2/**3 * Helper internal service for generating common controller code between the4 * pager and pagination components5 */6.factory('uibPaging', ['$parse', function($parse) {7 return {8 create: function(ctrl, $scope, $attrs) {9 ctrl.setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;10 ctrl.ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl11 ctrl._watchers = [];12 ctrl.init = function(ngModelCtrl, config) {13 ctrl.ngModelCtrl = ngModelCtrl;14 ctrl.config = config;15 ngModelCtrl.$render = function() {16 ctrl.render();17 };18 if ($attrs.itemsPerPage) {19 ctrl._watchers.push($scope.$parent.$watch($attrs.itemsPerPage, function(value) {20 ctrl.itemsPerPage = parseInt(value, 10);21 $scope.totalPages = ctrl.calculateTotalPages();22 ctrl.updatePage();23 }));24 } else {25 ctrl.itemsPerPage = config.itemsPerPage;26 }27 $scope.$watch('totalItems', function(newTotal, oldTotal) {28 if (angular.isDefined(newTotal) || newTotal !== oldTotal) {29 $scope.totalPages = ctrl.calculateTotalPages();30 ctrl.updatePage();31 }32 });33 };34 ctrl.calculateTotalPages = function() {35 var totalPages = ctrl.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / ctrl.itemsPerPage);36 return Math.max(totalPages || 0, 1);37 };38 ctrl.render = function() {39 $scope.page = parseInt(ctrl.ngModelCtrl.$viewValue, 10) || 1;40 };41 $scope.selectPage = function(page, evt) {42 if (evt) {43 evt.preventDefault();44 }45 var clickAllowed = !$scope.ngDisabled || !evt;46 if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {47 if (evt && evt.target) {48 evt.target.blur();49 }50 ctrl.ngModelCtrl.$setViewValue(page);51 ctrl.ngModelCtrl.$render();52 }53 };54 $scope.getText = function(key) {55 return $scope[key + 'Text'] || ctrl.config[key + 'Text'];56 };57 $scope.noPrevious = function() {58 return $scope.page === 1;59 };60 $scope.noNext = function() {61 return $scope.page === $scope.totalPages;62 };63 ctrl.updatePage = function() {64 ctrl.setNumPages($scope.$parent, $scope.totalPages); // Readonly variable65 if ($scope.page > $scope.totalPages) {66 $scope.selectPage($scope.totalPages);67 } else {68 ctrl.ngModelCtrl.$render();69 }70 };71 $scope.$on('$destroy', function() {72 while (ctrl._watchers.length) {73 ctrl._watchers.shift()();74 }75 });76 }77 };...

Full Screen

Full Screen

map_controller_spec_back.js

Source:map_controller_spec_back.js Github

copy

Full Screen

1/* global ngMap, google */2describe('__MapController', function() {3 'use strict';4 var scope, ctrl;5 var el = document.body;6 beforeEach(function() {7 module('ngMap');8 inject( function($controller, $rootScope, $element, $parse, Attr2MapOptions, NgMap){9 scope = $rootScope;10 ctrl = $controller('__MapController', {11 $scope: scope,12 '$element': $element,13 '$attrs': $attrs,14 '$parse': $parse,15 Attr2MapOptions: Attr2MapOptions,16 NgMap: NgMap17 });18 });19 });20 describe('addObject', function() {21 it('should add a marker to the existing map', function() {22 ctrl.map = new google.maps.Map(el, {}); //each method require ctrl.map;23 ctrl.map.markers = {};24 var marker = new google.maps.Marker({25 position: new google.maps.LatLng(1,1),26 centered: true27 });28 ctrl.addObject('markers', marker);29 // set map for this marker30 expect(marker.getMap()).toBe(ctrl.map);31 // set center of the map with this marker32 expect(marker.getPosition()).toBe(ctrl.map.getCenter());33 // ctrl.map.markers34 expect(Object.keys(ctrl.map.markers).length).toEqual(1);35 });36 it('should add a marker to ctrl._objects when ctrl.map is not init', function() {37 ctrl._objects = [];38 var marker = new google.maps.Marker({position: new google.maps.LatLng(1,1)});39 ctrl.addObject('markers', marker);40 expect(ctrl._objects[0]).toBe(marker);41 });42 });43 describe('addShape', function() {44 it('should add a shape to ctrl._objects when ctrl.map is not init', function() {45 ctrl._objects = [];46 var circle = new google.maps.Circle({center: new google.maps.LatLng(1,1)});47 ctrl.addObject('shapes', circle);48 expect(ctrl._objects[0]).toBe(circle);49 });50 it('should add a shape to the existing map', function() {51 ctrl.map = new google.maps.Map(el, {}); //each method require ctrl.map;52 ctrl.map.shapes = {};53 var circle = new google.maps.Circle({center: new google.maps.LatLng(1,1)});54 ctrl.addObject('shapes', circle);55 expect(ctrl.map.shapes[0]).toBe(circle);56 expect(ctrl.map.shapes[0].getMap()).toBe(ctrl.map);57 });58 });59 describe('addObjects', function() {60 it('should add objects; markers and shapes when map is init', function() {61 var marker = new google.maps.Marker({position: new google.maps.LatLng(1,1)});62 var circle = new google.maps.Circle({center: new google.maps.LatLng(1,1)});63 var objects = [marker, circle];64 ctrl.map = new google.maps.Map(el, {}); //each method require ctrl.map;65 ctrl.addObjects(objects);66 expect(marker.getMap()).toBe(ctrl.map);67 expect(circle.getMap()).toBe(ctrl.map);68 });69 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1ctrl.get = function(url) {2 browser.get(url);3};4ctrl.findElement = function(locator) {5 return browser.findElement(locator);6};7ctrl.findElements = function(locator) {8 return browser.findElements(locator);9};10ctrl.wait = function(condition, timeout, message) {11 return browser.wait(condition, timeout, message);12};13ctrl.waitForAngular = function() {14 return browser.waitForAngular();15};16ctrl.sleep = function(ms) {17 return browser.sleep(ms);18};19ctrl.getCurrentUrl = function() {20 return browser.getCurrentUrl();21};22ctrl.getTitle = function() {23 return browser.getTitle();24};25ctrl.takeScreenshot = function() {26 return browser.takeScreenshot();27};28ctrl.wait = function(condition, timeout, message) {29 return browser.wait(condition, timeout, message);30};31ctrl.findElement = function(locator) {32 return browser.findElement(locator);33};34ctrl.findElements = function(locator) {35 return browser.findElements(locator);36};37ctrl.getCapabilities = function() {38 return browser.getCapabilities();39};40ctrl.isElementPresent = function(locator) {41 return browser.isElementPresent(locator);42};43ctrl.controlFlow = function() {44 return browser.controlFlow();45};46ctrl.executeAsyncScript = function(script, ...var_args) {47 return browser.executeAsyncScript(script, ...var_args);48};49ctrl.executeScript = function(script, ...var_args) {50 return browser.executeScript(script, ...var_args);51};52ctrl.pause = function() {53 return browser.pause();54};55ctrl.restart = function() {56 return browser.restart();57};58ctrl.manage = function() {59 return browser.manage();60};61ctrl.switchTo = function() {62 return browser.switchTo();63};64ctrl.actions = function() {65 return browser.actions();66};67ctrl.call = function() {68 return browser.call();69};70ctrl.forkNewDriverInstance = function(opt_useSameUrl, opt_copyMockModules, opt_angularjs) {71 return browser.forkNewDriverInstance(opt_useSameUrl, opt_copyMockModules, opt_angularjs);72};73ctrl.resetUrl = function(opt_newBaseUrl) {74 return browser.resetUrl(opt_newBaseUrl);75};76ctrl.restartSync = function() {77 return browser.restartSync();78};79ctrl.waitForAngularEnabled = function(enabled) {80 return browser.waitForAngularEnabled(enabled);81};82ctrl.waitForAngularEnabled = function() {83 return browser.waitForAngularEnabled();84};85ctrl.getPageSource = function() {

Full Screen

Selenium Protractor Tutorial

Protractor is developed by Google Developers to test Angular and AngularJS code. Today, it is used to test non-Angular applications as well. It performs a real-world user-like test against your application in a real browser. It comes under an end-to-end testing framework. As of now, Selenium Protractor has proved to be a popular framework for end-to-end automation for AngularJS.

Let’s talk about what it does:

  • Protractor, built on WebDriver JS (Selenium), offers Angular-specific locator strategies.
  • It helps to construct automated tests for applications other than Angular JS and is not just intended to test AngularJS applications.
  • Page object design pattern is supported by Protractor Selenium, which improves in producing clear and legible code. Automation testers need to write clean code.
  • Frameworks like Jasmine, Cucumber, and others are fully integrated with Protractor.

Chapters:

Protractor is a JavaScript framework, end-to-end test automation framework for Angular and AngularJS applications.

Protractor Selenium provides new locator methods that actually make it easier to find elements in the DOM.

Two files are required to execute Protractor Selenium tests for end-to-end automation: Specs & Config. Go through the link above to understand in a better way.

To carry out extensive, automated cross browser testing, you can't imagine installing thousands of the available browsers on your own workstation. The only way to increase browser usage is through remote execution on the cloud. To execute your automation test scripts across a variety of platforms and browser versions, LambdaTest offers more than 3000 browsers.

We recommend Selenium for end-to-end automation for AngularJS because both are maintained and owned by Google, and they build JavaScript test automation framework to handle AngularJS components in a way that better matches how developers use it.

For scripting, selenium locators are essential since if they're off, your automation scripts won't run. Therefore, in any testing framework, these Selenium locators are the foundation of your Selenium test automation efforts.

To make sure that your Selenium automation tests function as intended, debugging can be an effective option. Check the blog to know more.

Get familiar with global variables that are majorly used in locating the DOM elements with examples for better understanding of these Selenium locators in protractor.

If you are not familiar with writing Selenium test automation on Protractor, here is a blog for you to get you understand in depth.

Selenium tests are asynchronous and there are various reasons for a timeout to occur in a Protractor test. Find out how to handle timeouts in this Protractor tutorial.

In this Protractor tutorial, learn how to handle frames or iframes in Selenium with Protractor for automated browser testing.

Handle alerts and popups in Protractor more efficiently. It can be confusing. Here's a simple guide to understand how to handle alerts and popups in Selenium.

Run Protractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful