aboutsummaryrefslogtreecommitdiffstats
path: root/lib/jasmine-1.0.1/index.js
diff options
context:
space:
mode:
authorVojta Jina2011-10-13 11:37:21 -0700
committerIgor Minar2011-10-13 17:36:11 -0700
commitab5df20dfa54d1d05f10d0aa7de5227e68cc37a8 (patch)
tree981d0ce0198c11211450c477f0bcf1879fd94ec5 /lib/jasmine-1.0.1/index.js
parentd83a92c12138ab53d1a6c6eae7d0cf9300514e8c (diff)
downloadangular.js-ab5df20dfa54d1d05f10d0aa7de5227e68cc37a8.tar.bz2
chore(libs): update libs (jasmine, jstd, jasmine-jstd adapter)
Diffstat (limited to 'lib/jasmine-1.0.1/index.js')
-rw-r--r--lib/jasmine-1.0.1/index.js181
1 files changed, 0 insertions, 181 deletions
diff --git a/lib/jasmine-1.0.1/index.js b/lib/jasmine-1.0.1/index.js
deleted file mode 100644
index 219f4238..00000000
--- a/lib/jasmine-1.0.1/index.js
+++ /dev/null
@@ -1,181 +0,0 @@
-var fs = require('fs');
-var sys = require('sys');
-var path = require('path');
-var vm = require('vm');
-
-var filename = __dirname + '/jasmine.js';
-global.window = {
- setTimeout: setTimeout,
- clearTimeout: clearTimeout,
- setInterval: setInterval,
- clearInterval: clearInterval
-};
-var src = fs.readFileSync(filename);
-var jasmine = vm.runInThisContext(src + '\njasmine;', filename);
-delete global.window;
-
-function noop(){}
-
-jasmine.executeSpecsInFolder = function(folder, done, isVerbose, showColors, matcher){
- var log = [];
- var columnCounter = 0;
- var start = 0;
- var elapsed = 0;
- var verbose = isVerbose || false;
- var fileMatcher = new RegExp(matcher || "\.js$");
- var colors = showColors || false;
- var specs = jasmine.getAllSpecFiles(folder, fileMatcher);
-
- var ansi = {
- green: '\033[32m',
- red: '\033[31m',
- yellow: '\033[33m',
- none: '\033[0m'
- };
-
- for (var i = 0, len = specs.length; i < len; ++i){
- var filename = specs[i];
- require(filename.replace(/\.*$/, ""));
- }
-
- var jasmineEnv = jasmine.getEnv();
- jasmineEnv.reporter = {
- log: function(str){
- },
-
- reportSpecStarting: function(runner) {
- },
-
- reportRunnerStarting: function(runner) {
- sys.puts('Started');
- start = Number(new Date);
- },
-
- reportSuiteResults: function(suite) {
- var specResults = suite.results();
- var path = [];
- while(suite) {
- path.unshift(suite.description);
- suite = suite.parentSuite;
- }
- var description = path.join(' ');
-
- if (verbose)
- log.push('Spec ' + description);
-
- specResults.items_.forEach(function(spec){
- if (spec.failedCount > 0 && spec.description) {
- if (!verbose)
- log.push(description);
- log.push(' it ' + spec.description);
- spec.items_.forEach(function(result){
- log.push(' ' + result.trace.stack + '\n');
- });
- }
- });
- },
-
- reportSpecResults: function(spec) {
- var result = spec.results();
- var msg = '';
- if (result.passed())
- {
- msg = (colors) ? (ansi.green + '.' + ansi.none) : '.';
-// } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec?
-// msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*';
- } else {
- msg = (colors) ? (ansi.red + 'F' + ansi.none) : 'F';
- }
- sys.print(msg);
- if (columnCounter++ < 50) return;
- columnCounter = 0;
- sys.print('\n');
- },
-
-
- reportRunnerResults: function(runner) {
- elapsed = (Number(new Date) - start) / 1000;
- sys.puts('\n');
- log.forEach(function(log){
- sys.puts(log);
- });
- sys.puts('Finished in ' + elapsed + ' seconds');
-
- var summary = jasmine.printRunnerResults(runner);
- if(colors)
- {
- if(runner.results().failedCount === 0 )
- sys.puts(ansi.green + summary + ansi.none);
- else
- sys.puts(ansi.red + summary + ansi.none);
- } else {
- sys.puts(summary);
- }
- (done||noop)(runner, log);
- }
- };
- jasmineEnv.execute();
-};
-
-jasmine.getAllSpecFiles = function(dir, matcher){
- var specs = [];
-
- if (fs.statSync(dir).isFile() && dir.match(matcher)) {
- specs.push(dir);
- } else {
- var files = fs.readdirSync(dir);
- for (var i = 0, len = files.length; i < len; ++i){
- var filename = dir + '/' + files[i];
- if (fs.statSync(filename).isFile() && filename.match(matcher)){
- specs.push(filename);
- }else if (fs.statSync(filename).isDirectory()){
- var subfiles = this.getAllSpecFiles(filename, matcher);
- subfiles.forEach(function(result){
- specs.push(result);
- });
- }
- }
- }
-
- return specs;
-};
-
-jasmine.printRunnerResults = function(runner){
- var results = runner.results();
- var suites = runner.suites();
- var msg = '';
- msg += suites.length + ' test' + ((suites.length === 1) ? '' : 's') + ', ';
- msg += results.totalCount + ' assertion' + ((results.totalCount === 1) ? '' : 's') + ', ';
- msg += results.failedCount + ' failure' + ((results.failedCount === 1) ? '' : 's') + '\n';
- return msg;
-};
-
-function now(){
- return new Date().getTime();
-}
-
-jasmine.asyncSpecWait = function(){
- var wait = jasmine.asyncSpecWait;
- wait.start = now();
- wait.done = false;
- (function innerWait(){
- waits(10);
- runs(function() {
- if (wait.start + wait.timeout < now()) {
- expect('timeout waiting for spec').toBeNull();
- } else if (wait.done) {
- wait.done = false;
- } else {
- innerWait();
- }
- });
- })();
-};
-jasmine.asyncSpecWait.timeout = 4 * 1000;
-jasmine.asyncSpecDone = function(){
- jasmine.asyncSpecWait.done = true;
-};
-
-for ( var key in jasmine) {
- exports[key] = jasmine[key];
-} \ No newline at end of file
atter.number * * @description * Use number formatter if you wish to convert the user entered string to a number. * * @returns {number} Number from the parsed string. * * @example <doc:example> <doc:source> Enter valid number: <input type="text" name="value" ng:format="number" value="1234"/> <pre>value={{value}}</pre> </doc:source> <doc:scenario> it('should format numbers', function(){ expect(binding('value')).toEqual('value=1234'); input('value').enter('5678'); expect(binding('value')).toEqual('value=5678'); }); </doc:scenario> </doc:example> */ angularFormatter.number = formatter(toString, function(obj){ if (obj == null || NUMBER.exec(obj)) { return obj===null || obj === '' ? null : 1*obj; } else { throw "Not a number"; } }); /** * @workInProgress * @ngdoc formatter * @name angular.formatter.list * * @description * Use list formatter if you wish to convert the user entered string to an array. * * @returns {Array} Array parsed from the entered string. * * @example <doc:example> <doc:source> Enter a list of items: <input type="text" name="value" ng:format="list" value=" chair ,, table"/> <input type="text" name="value" ng:format="list"/> <pre>value={{value}}</pre> </doc:source> <doc:scenario> it('should format lists', function(){ expect(binding('value')).toEqual('value=["chair","table"]'); this.addFutureAction('change to XYZ', function($window, $document, done){ $document.elements('.doc-example-live :input:last').val(',,a,b,').trigger('change'); done(); }); expect(binding('value')).toEqual('value=["a","b"]'); }); </doc:scenario> </doc:example> */ angularFormatter.list = formatter( function(obj) { return obj ? obj.join(", ") : obj; }, function(value) { var list = []; forEach((value || '').split(','), function(item){ item = trim(item); if (item) list.push(item); }); return list; } ); /** * @workInProgress * @ngdoc formatter * @name angular.formatter.trim * * @description * Use trim formatter if you wish to trim extra spaces in user text. * * @returns {String} Trim excess leading and trailing space. * * @example <doc:example> <doc:source> Enter text with leading/trailing spaces: <input type="text" name="value" ng:format="trim" value=" book "/> <input type="text" name="value" ng:format="trim"/> <pre>value={{value|json}}</pre> </doc:source> <doc:scenario> it('should format trim', function(){ expect(binding('value')).toEqual('value="book"'); this.addFutureAction('change to XYZ', function($window, $document, done){ $document.elements('.doc-example-live :input:last').val(' text ').trigger('change'); done(); }); expect(binding('value')).toEqual('value="text"'); }); </doc:scenario> </doc:example> */ angularFormatter.trim = formatter( function(obj) { return obj ? trim("" + obj) : ""; } ); /** * @workInProgress * @ngdoc formatter * @name angular.formatter.index * @description * Index formatter is meant to be used with `select` input widget. It is useful when one needs * to select from a set of objects. To create pull-down one can iterate over the array of object * to build the UI. However the value of the pull-down must be a string. This means that when on * object is selected form the pull-down, the pull-down value is a string which needs to be * converted back to an object. This conversion from string to on object is not possible, at best * the converted object is a copy of the original object. To solve this issue we create a pull-down * where the value strings are an index of the object in the array. When pull-down is selected the * index can be used to look up the original user object. * * @inputType select * @param {array} array to be used for selecting an object. * @returns {object} object which is located at the selected position. * * @example <doc:example> <doc:source> <script> function DemoCntl(){ this.users = [ {name:'guest', password:'guest'}, {name:'user', password:'123'}, {name:'admin', password:'abc'} ]; } </script> <div ng:controller="DemoCntl"> User: <select name="currentUser" ng:format="index:users"> <option ng:repeat="user in users" value="{{$index}}">{{user.name}}</option> </select> <select name="currentUser" ng:format="index:users"> <option ng:repeat="user in users" value="{{$index}}">{{user.name}}</option> </select> user={{currentUser.name}}<br/> password={{currentUser.password}}<br/> </doc:source> <doc:scenario> it('should retrieve object by index', function(){ expect(binding('currentUser.password')).toEqual('guest'); select('currentUser').option('2'); expect(binding('currentUser.password')).toEqual('abc'); }); </doc:scenario> </doc:example> */ angularFormatter.index = formatter( function(object, array){ return '' + indexOf(array || [], object); }, function(index, array){ return (array||[])[index]; } );