From 6f91ffeb914e3a3670d675397cbdbff5cf590edd Mon Sep 17 00:00:00 2001
From: Vojta Jina
Date: Tue, 3 Jan 2012 14:49:41 -0800
Subject: style: prefer single quotes + some whitespaces
---
test/BinderSpec.js | 84 +++++++++++++++++++++++++++---------------------------
test/JsonSpec.js | 76 ++++++++++++++++++++++++------------------------
2 files changed, 80 insertions(+), 80 deletions(-)
diff --git a/test/BinderSpec.js b/test/BinderSpec.js
index 34504b30..efe7215b 100644
--- a/test/BinderSpec.js
+++ b/test/BinderSpec.js
@@ -49,50 +49,50 @@ describe('Binder', function() {
}));
it('ReplaceBindingInTextWithSpan preserve surounding text', function() {
- expect(this.compileToHtml("a{{b}}c")).toBe('ac');
+ expect(this.compileToHtml('a{{b}}c')).toBe('ac');
});
it('ReplaceBindingInTextWithSpan', function() {
- expect(this.compileToHtml("{{b}}")).toBe('');
+ expect(this.compileToHtml('{{b}}')).toBe('');
});
it('BindingSpaceConfusesIE', inject(function($rootScope, $compile) {
if (!msie) return;
- var span = document.createElement("span");
+ var span = document.createElement('span');
span.innerHTML = ' ';
var nbsp = span.firstChild.nodeValue;
- expect(this.compileToHtml("{{a}} {{b}}")).
+ expect(this.compileToHtml('{{a}} {{b}}')).
toBe('' + nbsp + '');
dealoc(($rootScope));
- expect(this.compileToHtml("{{A}} x {{B}} ({{C}})")).
+ expect(this.compileToHtml('{{A}} x {{B}} ({{C}})')).
toBe('' + nbsp + 'x ' +
'' + nbsp + '()');
}));
it('BindingOfAttributes', inject(function($rootScope, $compile) {
- var element = $compile("")($rootScope);
- var attrbinding = element.attr("ng:bind-attr");
+ var element = $compile('')($rootScope);
+ var attrbinding = element.attr('ng:bind-attr');
var bindings = fromJson(attrbinding);
- expect(decodeURI(bindings.href)).toBe("http://s/a{{b}}c");
+ expect(decodeURI(bindings.href)).toBe('http://s/a{{b}}c');
expect(bindings.foo).toBeFalsy();
}));
it('MarkMultipleAttributes', inject(function($rootScope, $compile) {
var element = $compile('')($rootScope);
- var attrbinding = element.attr("ng:bind-attr");
+ var attrbinding = element.attr('ng:bind-attr');
var bindings = fromJson(attrbinding);
- expect(bindings.foo).toBe("{{d}}");
- expect(decodeURI(bindings.href)).toBe("http://s/a{{b}}c");
+ expect(bindings.foo).toBe('{{d}}');
+ expect(decodeURI(bindings.href)).toBe('http://s/a{{b}}c');
}));
it('AttributesNoneBound', inject(function($rootScope, $compile) {
- var a = $compile("")($rootScope);
- expect(a[0].nodeName).toBe("A");
- expect(a.attr("ng:bind-attr")).toBeFalsy();
+ var a = $compile('')($rootScope);
+ expect(a[0].nodeName).toBe('A');
+ expect(a.attr('ng:bind-attr')).toBeFalsy();
}));
it('ExistingAttrbindingIsAppended', inject(function($rootScope, $compile) {
- var a = $compile("")($rootScope);
+ var a = $compile('')($rootScope);
expect(a.attr('ng:bind-attr')).toBe('{"b":"{{def}}","href":"http://s/{{abc}}"}');
}));
@@ -117,7 +117,7 @@ describe('Binder', function() {
}));
it('InputTypeButtonActionExecutesInScope2', inject(function($rootScope, $compile) {
- var log = "";
+ var log = '';
var element = $compile('')($rootScope);
$rootScope.action = function() {
log += 'click;';
@@ -143,8 +143,8 @@ describe('Binder', function() {
'
')($rootScope);
- var items = [{a:"A"}, {a:"B"}];
- $rootScope.model = {items:items};
+ var items = [{a: 'A'}, {a: 'B'}];
+ $rootScope.model = {items: items};
$rootScope.$apply();
expect(sortedHtml(form)).toBe(
@@ -154,7 +154,7 @@ describe('Binder', function() {
'B' +
'');
- items.unshift({a:'C'});
+ items.unshift({a: 'C'});
$rootScope.$apply();
expect(sortedHtml(form)).toBe(
'' +
@@ -183,7 +183,7 @@ describe('Binder', function() {
'')($rootScope);
- $rootScope.model = {items:[{a:"A"}]};
+ $rootScope.model = {items: [{a: 'A'}]};
$rootScope.$apply();
expect(sortedHtml(element)).toBe(
'' +
@@ -199,7 +199,7 @@ describe('Binder', function() {
it('RepeaterAdd', inject(function($rootScope, $compile, $browser) {
var element = $compile('')($rootScope);
- $rootScope.items = [{x:'a'}, {x:'b'}];
+ $rootScope.items = [{x: 'a'}, {x: 'b'}];
$rootScope.$apply();
var first = childNode(element, 1);
var second = childNode(element, 2);
@@ -220,7 +220,7 @@ describe('Binder', function() {
$rootScope.$apply();
expect(element[0].childNodes.length - 1).toEqual(0);
- items.name = "misko";
+ items.name = 'misko';
$rootScope.$apply();
expect(element[0].childNodes.length - 1).toEqual(1);
@@ -238,16 +238,16 @@ describe('Binder', function() {
var errorLogs = $exceptionHandler.errors;
$rootScope.error = {
- 'throw': function() {throw "ErrorMsg1";}
+ 'throw': function() {throw 'ErrorMsg1';}
};
$rootScope.$apply();
- $rootScope.error['throw'] = function() {throw "MyError";};
+ $rootScope.error['throw'] = function() {throw 'MyError';};
errorLogs.length = 0;
$rootScope.$apply();
expect(errorLogs.shift()).toBe('MyError');
- $rootScope.error['throw'] = function() {return "ok";};
+ $rootScope.error['throw'] = function() {return 'ok';};
$rootScope.$apply();
expect(errorLogs.length).toBe(0);
})
@@ -261,7 +261,7 @@ describe('Binder', function() {
var count = 0;
$rootScope.error = {
- 'throw': function() {throw new Error("ErrorMsg" + (++count));}
+ 'throw': function() {throw new Error('ErrorMsg' + (++count));}
};
$rootScope.$apply();
expect(errorLogs.length).not.toEqual(0);
@@ -389,7 +389,7 @@ describe('Binder', function() {
$rootScope.$eval('style={height: "10px"}');
$rootScope.$apply();
- expect(element.css('height')).toBe("10px");
+ expect(element.css('height')).toBe('10px');
$rootScope.$eval('style={}');
$rootScope.$apply();
@@ -411,11 +411,11 @@ describe('Binder', function() {
it('ShoulIgnoreVbNonBindable', inject(function($rootScope, $compile) {
var element = $compile(
- "{{a}}" +
- "
{{a}}
" +
- "
{{b}}
" +
- "
{{c}}
" +
- "
")($rootScope);
+ '{{a}}' +
+ '
{{a}}
' +
+ '
{{b}}
' +
+ '
{{c}}
' +
+ '
')($rootScope);
$rootScope.a = 123;
$rootScope.$apply();
expect(element.text()).toBe('123{{a}}{{b}}{{c}}');
@@ -423,7 +423,7 @@ describe('Binder', function() {
it('ShouldTemplateBindPreElements', inject(function ($rootScope, $compile) {
var element = $compile('
Hello {{name}}!')($rootScope);
- $rootScope.name = "World";
+ $rootScope.name = 'World';
$rootScope.$apply();
expect( sortedHtml(element)).toBe(
@@ -492,7 +492,7 @@ describe('Binder', function() {
var errorLogs = $log.error.logs;
browserTrigger(first, 'click');
- expect($rootScope.greeting).toBe("ABC");
+ expect($rootScope.greeting).toBe('ABC');
expect(errorLogs).toEqual([]);
browserTrigger(second, 'click');
@@ -511,16 +511,16 @@ describe('Binder', function() {
var male = jqLite(element[0].childNodes[1]);
browserTrigger(female);
- expect($rootScope.sex).toBe("female");
+ expect($rootScope.sex).toBe('female');
expect(female[0].checked).toBe(true);
expect(male[0].checked).toBe(false);
- expect(female.val()).toBe("female");
+ expect(female.val()).toBe('female');
browserTrigger(male);
- expect($rootScope.sex).toBe("male");
+ expect($rootScope.sex).toBe('male');
expect(female[0].checked).toBe(false);
expect(male[0].checked).toBe(true);
- expect(male.val()).toBe("male");
+ expect(male.val()).toBe('male');
}));
it('ItShouldRepeatOnHashes', inject(function($rootScope, $compile) {
@@ -539,9 +539,9 @@ describe('Binder', function() {
it('ItShouldFireChangeListenersBeforeUpdate', inject(function($rootScope, $compile) {
var element = $compile('')($rootScope);
- $rootScope.name = "";
- $rootScope.$watch("watched", "name=123");
- $rootScope.watched = "change";
+ $rootScope.name = '';
+ $rootScope.$watch('watched', 'name=123');
+ $rootScope.watched = 'change';
$rootScope.$apply();
expect($rootScope.name).toBe(123);
expect(sortedHtml(element)).toBe('123
');
@@ -550,7 +550,7 @@ describe('Binder', function() {
it('ItShouldHandleMultilineBindings', inject(function($rootScope, $compile) {
var element = $compile('{{\n 1 \n + \n 2 \n}}
')($rootScope);
$rootScope.$apply();
- expect(element.text()).toBe("3");
+ expect(element.text()).toBe('3');
}));
});
diff --git a/test/JsonSpec.js b/test/JsonSpec.js
index 3329c223..df1e428a 100644
--- a/test/JsonSpec.js
+++ b/test/JsonSpec.js
@@ -6,9 +6,9 @@ describe('json', function() {
expect(toJson(null)).toEqual('null');
expect(toJson(true)).toEqual('true');
expect(toJson(false)).toEqual('false');
- expect(toJson(123.45)).toEqual("123.45");
- expect(toJson("abc")).toEqual('"abc"');
- expect(toJson("a \t \n \r b \\")).toEqual('"a \\t \\n \\r b \\\\"');
+ expect(toJson(123.45)).toEqual('123.45');
+ expect(toJson('abc')).toEqual('"abc"');
+ expect(toJson('a \t \n \r b \\')).toEqual('"a \\t \\n \\r b \\\\"');
});
it('should not serialize $$properties', function() {
@@ -24,25 +24,25 @@ describe('json', function() {
});
it('should serialize objects', function() {
- expect(toJson({a:1,b:2})).toEqual('{"a":1,"b":2}');
- expect(toJson({a:{b:2}})).toEqual('{"a":{"b":2}}');
- expect(toJson({a:{b:{c:0}}})).toEqual('{"a":{"b":{"c":0}}}');
- expect(toJson({a:{b:0/0}})).toEqual('{"a":{"b":null}}');
+ expect(toJson({a: 1, b: 2})).toEqual('{"a":1,"b":2}');
+ expect(toJson({a: {b: 2}})).toEqual('{"a":{"b":2}}');
+ expect(toJson({a: {b: {c: 0}}})).toEqual('{"a":{"b":{"c":0}}}');
+ expect(toJson({a: {b: 0/0}})).toEqual('{"a":{"b":null}}');
});
it('should format objects pretty', function() {
- expect(toJson({a:1,b:2}, true)).toEqual('{\n "a":1,\n "b":2}');
- expect(toJson({a:{b:2}}, true)).toEqual('{\n "a":{\n "b":2}}');
+ expect(toJson({a: 1, b: 2}, true)).toEqual('{\n "a":1,\n "b":2}');
+ expect(toJson({a: {b: 2}}, true)).toEqual('{\n "a":{\n "b":2}}');
});
it('should serialize array', function() {
expect(toJson([])).toEqual('[]');
- expect(toJson([1,"b"])).toEqual('[1,"b"]');
+ expect(toJson([1, 'b'])).toEqual('[1,"b"]');
});
it('should serialize RegExp', function() {
expect(toJson(/foo/)).toEqual('"/foo/"');
- expect(toJson([1,new RegExp("foo")])).toEqual('[1,"/foo/"]');
+ expect(toJson([1, new RegExp('foo')])).toEqual('[1,"/foo/"]');
});
it('should ignore functions', function() {
@@ -51,34 +51,34 @@ describe('json', function() {
});
it('should parse null', function() {
- expect(fromJson("null")).toBeNull();
+ expect(fromJson('null')).toBeNull();
});
it('should parse boolean', function() {
- expect(fromJson("true")).toBeTruthy();
- expect(fromJson("false")).toBeFalsy();
+ expect(fromJson('true')).toBeTruthy();
+ expect(fromJson('false')).toBeFalsy();
});
it('should serialize array with empty items', function() {
var a = [];
- a[1] = "X";
+ a[1] = 'X';
expect(toJson(a)).toEqual('[null,"X"]');
});
it('should escape unicode', function() {
- expect("\u00a0".length).toEqual(1);
- expect(toJson("\u00a0").length).toEqual(8);
- expect(fromJson(toJson("\u00a0")).length).toEqual(1);
+ expect('\u00a0'.length).toEqual(1);
+ expect(toJson('\u00a0').length).toEqual(8);
+ expect(fromJson(toJson('\u00a0')).length).toEqual(1);
});
it('should serialize UTC dates', function() {
- var date = jsonStringToDate("2009-10-09T01:02:03.027Z");
+ var date = jsonStringToDate('2009-10-09T01:02:03.027Z');
expect(toJson(date)).toEqual('"2009-10-09T01:02:03.027Z"');
expect(fromJson('"2009-10-09T01:02:03.027Z"').getTime()).toEqual(date.getTime());
});
it('should prevent recursion', function() {
- var obj = {a:'b'};
+ var obj = {a: 'b'};
obj.recursion = obj;
expect(angular.toJson(obj)).toEqual('{"a":"b","recursion":RECURSION}');
});
@@ -212,48 +212,48 @@ describe('json', function() {
});
it('should not allow assignments', function() {
- expect(function() {fromJson("{a:1, b:[1]=1, c:1}");}).toThrow();
- expect(function() {fromJson("{a:1, b:=1, c:1}");}).toThrow();
- expect(function() {fromJson("{a:1, b:x=1, c:1}");}).toThrow();
+ expect(function() {fromJson('{a:1, b:[1]=1, c:1}');}).toThrow();
+ expect(function() {fromJson('{a:1, b:=1, c:1}');}).toThrow();
+ expect(function() {fromJson('{a:1, b:x=1, c:1}');}).toThrow();
});
});
it('should read/write to date', function() {
- var date = new Date("Sep 10 2003 13:02:03 GMT");
- expect(jsonDateToString(date)).toBe("2003-09-10T13:02:03.000Z");
+ var date = new Date('Sep 10 2003 13:02:03 GMT');
+ expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
expect(jsonStringToDate(jsonDateToString(date)).getTime()).toBe(date.getTime());
});
it('should convert to date', function() {
//full ISO8061
- expect(jsonStringToDate("2003-09-10T13:02:03.000Z")).
- toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
+ expect(jsonStringToDate('2003-09-10T13:02:03.000Z')).
+ toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
//no millis
- expect(jsonStringToDate("2003-09-10T13:02:03Z")).
- toEqual(new Date("Sep 10 2003 13:02:03 GMT"));
+ expect(jsonStringToDate('2003-09-10T13:02:03Z')).
+ toEqual(new Date('Sep 10 2003 13:02:03 GMT'));
//no seconds
- expect(jsonStringToDate("2003-09-10T13:02Z")).
- toEqual(new Date("Sep 10 2003 13:02:00 GMT"));
+ expect(jsonStringToDate('2003-09-10T13:02Z')).
+ toEqual(new Date('Sep 10 2003 13:02:00 GMT'));
//no minutes
- expect(jsonStringToDate("2003-09-10T13Z")).
- toEqual(new Date("Sep 10 2003 13:00:00 GMT"));
+ expect(jsonStringToDate('2003-09-10T13Z')).
+ toEqual(new Date('Sep 10 2003 13:00:00 GMT'));
//no time
- expect(jsonStringToDate("2003-09-10")).
- toEqual(new Date("Sep 10 2003 00:00:00 GMT"));
+ expect(jsonStringToDate('2003-09-10')).
+ toEqual(new Date('Sep 10 2003 00:00:00 GMT'));
});
it('should parse date', function() {
- var date = jsonStringToDate("2003-09-10T13:02:03.000Z");
- expect(jsonDateToString(date)).toBe("2003-09-10T13:02:03.000Z");
- expect(jsonStringToDate("str")).toBe("str");
+ var date = jsonStringToDate('2003-09-10T13:02:03.000Z');
+ expect(jsonDateToString(date)).toBe('2003-09-10T13:02:03.000Z');
+ expect(jsonStringToDate('str')).toBe('str');
});
--
cgit v1.2.3