diff options
| author | Caitlin Potter | 2014-02-21 14:31:23 -0500 |
|---|---|---|
| committer | Caitlin Potter | 2014-02-21 14:52:12 -0500 |
| commit | 2f4513339337bb8aa6c9dfe1191d169b4fc57999 (patch) | |
| tree | ce0d47cee3d490c907cef680cc12e131f2a1cbf9 /example/personalLog | |
| parent | 4a6a3ba7fb08ce99007893ef75365a3e8aff938a (diff) | |
| download | angular.js-2f4513339337bb8aa6c9dfe1191d169b4fc57999.tar.bz2 | |
chore(examples): remove ancient examples from the tree
Let these poor scripts retire, goodness.
Closes #6398
Closes #3310
Diffstat (limited to 'example/personalLog')
| -rw-r--r-- | example/personalLog/personalLog.html | 33 | ||||
| -rw-r--r-- | example/personalLog/personalLog.js | 72 | ||||
| -rw-r--r-- | example/personalLog/scenario/personalLogScenario.js | 98 | ||||
| -rw-r--r-- | example/personalLog/scenario/runner.html | 11 | ||||
| -rw-r--r-- | example/personalLog/test/personalLogSpec.js | 120 |
5 files changed, 0 insertions, 334 deletions
diff --git a/example/personalLog/personalLog.html b/example/personalLog/personalLog.html deleted file mode 100644 index 483a37b8..00000000 --- a/example/personalLog/personalLog.html +++ /dev/null @@ -1,33 +0,0 @@ -<!doctype html> -<html ng-app="personalLog"> - <head> - <title>Personal Log</title> - <script src="../../src/loader.js"></script> - <script> - setupModuleLoader(window); - </script> - <script src="personalLog.js"></script> - <script src="../../src/angular-bootstrap.js"></script> - <script src="../../src/ngCookies/cookies.js"></script> - </head> - - - <body ng-controller="LogCtrl"> - - <form action="" ng-submit="addLog(newMsg)"> - <input type="text" ng-model="newMsg"> - <input type="submit" value="add"> - <input type="button" value="remove all" ng-click="rmLogs()"> - </form> - - <hr/> - <h2>Logs:</h2> - <ul> - <li ng-repeat="log in logs | orderBy:'-at'"> - {{log.at | date:'yy-MM-dd HH:mm'}} {{log.msg}} - [<a href="" ng-click="rmLog(log)">x</a>] - </li> - </ul> - - </body> -</html> diff --git a/example/personalLog/personalLog.js b/example/personalLog/personalLog.js deleted file mode 100644 index c22b8702..00000000 --- a/example/personalLog/personalLog.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * @fileOverview Very simple personal log demo application to demonstrate angular functionality, - * especially: - * - the MVC model - * - testability of controllers - * - dependency injection for controllers via $inject and constructor function - * - $cookieStore for persistent cookie-backed storage - * - simple templating constructs such as ng-repeat and {{}} - * - date filter - * - and binding onSubmit and onClick events to angular expressions - * @author Igor Minar - */ - -//name space isolating closure -(function() { - -var app = angular.module('personalLog', ['ngCookies']); - -var LOGS = 'logs'; - -/** - * The controller for the personal log app. - */ -app.controller('LogCtrl', ['$cookieStore', '$scope', function LogCtrl($cookieStore, $scope) { - - var logs = $scope.logs = $cookieStore.get(LOGS) || []; //main model - - - /** - * Adds newMsg to the logs array as a log, persists it and clears newMsg. - * @param {string} msg Message to add (message is passed as parameter to make testing easier). - */ - $scope.addLog = function(msg) { - var newMsg = msg || $scope.newMsg; - if (!newMsg) return; - var log = { - at: new Date().getTime(), - msg: newMsg - }; - - logs.push(log); - $cookieStore.put(LOGS, logs); - $scope.newMsg = ''; - }; - - - /** - * Persistently removes a log from logs. - * @param {object} log The log to remove. - */ - $scope.rmLog = function(log) { - for ( var i = 0; i < logs.length; i++) { - if (log === logs[i]) { - logs.splice(i, 1); - break; - } - } - - $cookieStore.put(LOGS, logs); - }; - - - /** - * Persistently removes all logs. - */ - $scope.rmLogs = function() { - logs.splice(0, logs.length); - $cookieStore.remove(LOGS); - }; -}]); - -})(); diff --git a/example/personalLog/scenario/personalLogScenario.js b/example/personalLog/scenario/personalLogScenario.js deleted file mode 100644 index f9a37cf4..00000000 --- a/example/personalLog/scenario/personalLogScenario.js +++ /dev/null @@ -1,98 +0,0 @@ -describe('personal log', function() { - - beforeEach(function() { - browser().navigateTo('../personalLog.html'); - }); - - - afterEach(function() { - clearCookies(); - }); - - - it('should create new logs and order them in reverse chronological order', function() { - //create first msg - input('newMsg').enter('my first message'); - element('form input[type="submit"]').click(); - - expect(repeater('ul li').count()).toEqual(1); - expect(repeater('ul li').column('log.msg')).toEqual(['my first message']); - - //create second msg - input('newMsg').enter('my second message'); - element('form input[type="submit"]').click(); - - expect(repeater('ul li').count()).toEqual(2); - expect(repeater('ul li').column('log.msg')).toEqual(['my second message', 'my first message']); - }); - - - it('should delete a log when user clicks on the related X link', function() { - //create first msg - input('newMsg').enter('my first message'); - element('form input[type="submit"]').click(); - //create second msg - input('newMsg').enter('my second message'); - element('form input[type="submit"]').click(); - expect(repeater('ul li').count()).toEqual(2); - - element('ul li a:eq(1)').click(); - expect(repeater('ul li').count()).toEqual(1); - expect(repeater('ul li').column('log.msg')).toEqual(['my second message']); - - element('ul li a:eq(0)').click(); - expect(repeater('ul li').count()).toEqual(0); - }); - - - it('should delete all cookies when user clicks on "remove all" button', function() { - //create first msg - input('newMsg').enter('my first message'); - element('form input[type="submit"]').click(); - //create second msg - input('newMsg').enter('my second message'); - element('form input[type="submit"]').click(); - expect(repeater('ul li').count()).toEqual(2); - - element('input[value="remove all"]').click(); - expect(repeater('ul li').count()).toEqual(0); - }); - - - it('should preserve logs over page reloads', function() { - input('newMsg').enter('my persistent message'); - element('form input[type="submit"]').click(); - expect(repeater('ul li').count()).toEqual(1); - - browser().reload(); - - expect(repeater('ul li').column('log.msg')).toEqual(['my persistent message']); - expect(repeater('ul li').count()).toEqual(1); - }); -}); - - -/** - * DSL for deleting all cookies. - */ -angular.scenario.dsl('clearCookies', function() { - /** - * Deletes cookies by interacting with the cookie service within the application under test. - */ - return function() { - this.addFutureAction('clear all cookies', function($window, $document, done) { - var element = $window.angular.element($document[0]), - rootScope = element.scope(), - $cookies = element.data('$injector')('$cookies'), - cookieName; - - rootScope.$apply(function() { - for (cookieName in $cookies) { - delete $cookies[cookieName]; - } - }); - - done(); - }); - }; -}); diff --git a/example/personalLog/scenario/runner.html b/example/personalLog/scenario/runner.html deleted file mode 100644 index 298581d9..00000000 --- a/example/personalLog/scenario/runner.html +++ /dev/null @@ -1,11 +0,0 @@ -<!doctype html"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> - <head> - <title>Personal Log Scenario Runner</title> - <meta http-equiv="expires" content="0"> - <script type="text/javascript" src="../../../src/scenario/angular-bootstrap.js" ng:autotest></script> - <script type="text/javascript" src="personalLogScenario.js"></script> - </head> - <body> - </body> -</html> diff --git a/example/personalLog/test/personalLogSpec.js b/example/personalLog/test/personalLogSpec.js deleted file mode 100644 index c68fbfc2..00000000 --- a/example/personalLog/test/personalLogSpec.js +++ /dev/null @@ -1,120 +0,0 @@ -describe('example.personalLog.LogCtrl', function() { - var logScope; - - - beforeEach(module('personalLog')); - - beforeEach(inject(function($rootScope, $controller) { - logScope = $rootScope.$new(); - $controller('LogCtrl', {$scope: logScope}); - })); - - - it('should initialize notes with an empty array', function() { - expect(logScope.logs).toEqual([]); - }); - - - describe('addLog', function() { - - beforeEach(function() { - expect(logScope.logs).toEqual([]); - }); - - - it('should add newMsg to logs as a log entry', function() { - logScope.newMsg = 'first log message'; - logScope.addLog(); - - expect(logScope.logs.length).toBe(1); - expect(logScope.logs[0].msg).toBe('first log message'); - - //one more msg, this time passed in as param - logScope.addLog('second log message'); - - expect(logScope.logs.length).toBe(2); - expect(logScope.logs[0].msg).toBe('first log message'); - expect(logScope.logs[1].msg).toBe('second log message'); - }); - - - it('should clear newMsg when log entry is persisted', function() { - logScope.addLog('first log message'); - expect(logScope.newMsg).toBe(''); - }); - - - it('should store logs in the logs cookie', inject(function($cookies) { - expect($cookies.logs).not.toBeDefined(); - logScope.addLog('first log message'); - expect($cookies.logs).toBeTruthy(); - })); - - - it('should do nothing if newMsg is empty', function() { - logScope.addLog(''); - expect(logScope.logs.length).toBe(0); - }); - }); - - - describe('rmLog', function() { - - beforeEach(function() { - logScope.addLog('message1'); - logScope.addLog('message2'); - logScope.addLog('message3'); - logScope.addLog('message4'); - expect(logScope.logs.length).toBe(4); - }); - - - it('should delete a message identified by index', function() { - logScope.rmLog(logScope.logs[1]); - expect(logScope.logs.length).toBe(3); - - logScope.rmLog(logScope.logs[2]); - expect(logScope.logs.length).toBe(2); - expect(logScope.logs[0].msg).toBe('message1'); - expect(logScope.logs[1].msg).toBe('message3'); - }); - - - it('should update cookies when a log is deleted', inject(function($cookies) { - expect($cookies.logs).toMatch(/\[\{.*?\}(,\{.*?\}){3}\]/); - - logScope.rmLog(logScope.logs[1]); - expect($cookies.logs).toMatch(/\[\{.*?\}(,\{.*?\}){2}\]/); - - logScope.rmLog(logScope.logs[0]); - logScope.rmLog(logScope.logs[0]); - logScope.rmLog(logScope.logs[0]); - expect($cookies.logs).toMatch(/\[\]/); - })); - }); - - - describe('rmLogs', function() { - - beforeEach(function() { - logScope.addLog('message1'); - logScope.addLog('message2'); - logScope.addLog('message3'); - logScope.addLog('message4'); - expect(logScope.logs.length).toBe(4); - }); - - - it('should remove all logs', function() { - logScope.rmLogs(); - expect(logScope.logs).toEqual([]); - }); - - - it('should remove logs cookie', inject(function($cookies) { - expect($cookies.logs).toBeTruthy(); - logScope.rmLogs(); - expect($cookies.logs).not.toBeDefined(); - })); - }); -}); |
