Permalink
Browse files

Use the oxford comma in format list

  • Loading branch information...
1 parent 2bcb397 commit 5d4c5cfd229eddea0e6fbc232fa58647ff79bf62 @laktek committed Sep 10, 2012
Showing with 27 additions and 29 deletions.
  1. +1 −1 lib/helpers/list_helper.js
  2. +6 −6 spec/helpers/list_helper.spec.js
  3. +20 −22 spec/helpers/text_helper.spec.js
@@ -20,7 +20,7 @@ var block_helpers = {
if(arr.length > 1){
var last_value = arr.pop();
- return arr.join(", ") + " & " + last_value;
+ return arr.join(", ") + ", & " + last_value;
} else {
return arr.join("");
}
@@ -12,11 +12,11 @@ describe("format list", function(){
});
it("return a formatted string for an array literal", function(){
- expect(list_helper.format_list([ "Peter", "John", "Andrew" ])).toEqual("Peter, John & Andrew");
+ expect(list_helper.format_list([ "Peter", "John", "Andrew" ])).toEqual("Peter, John, & Andrew");
});
it("return a formatted string for an array literal as a string", function(){
- expect(list_helper.format_list("Peter,John,Andrew")).toEqual("Peter, John & Andrew");
+ expect(list_helper.format_list("Peter,John,Andrew")).toEqual("Peter, John, & Andrew");
});
});
@@ -31,11 +31,11 @@ describe("first item of the list", function(){
expect(list_helper.first("hello")).toEqual("hello");
});
- it("return a formatted string for an array literal", function(){
+ it("return the first item for an array literal", function(){
expect(list_helper.first(["Peter", "John", "Andrew"])).toEqual("Peter");
});
- it("return a formatted string for an array literal as a string", function(){
+ it("return the first item for an array literal as a string", function(){
expect(list_helper.first("Peter,John,Andrew")).toEqual("Peter");
});
@@ -51,11 +51,11 @@ describe("last item of the list", function(){
expect(list_helper.last("hello")).toEqual("hello");
});
- it("return a formatted string for an array literal", function(){
+ it("return the last item for an array literal", function(){
expect(list_helper.last(["Peter", "John", "Andrew"])).toEqual("Andrew");
});
- it("return a formatted string for an array literal as a string", function(){
+ it("return the last item for an array literal as a string", function(){
expect(list_helper.last("Peter,John,Andrew")).toEqual("Andrew");
});
@@ -4,114 +4,112 @@ var text_helper = text_helper_obj.directAccess()["block_helpers"];
describe("upcase", function(){
it("change whole text to uppercase", function(){
- expect(text_helper.upcase("hello")).toEqual("HELLO");
+ expect(text_helper.upcase("hello")).toEqual("HELLO");
});
it("return an empty string for null values", function() {
- expect(text_helper.upcase(null)).toEqual("");
+ expect(text_helper.upcase(null)).toEqual("");
});
});
describe("downcase", function(){
it("change whole text to lowercase", function(){
- expect(text_helper.downcase("HELlo")).toEqual("hello");
+ expect(text_helper.downcase("HELlo")).toEqual("hello");
});
it("return an empty string for null values", function() {
- expect(text_helper.downcase(null)).toEqual("");
+ expect(text_helper.downcase(null)).toEqual("");
});
});
describe("capitalize", function(){
it("make the first letter upper case", function(){
- expect(text_helper.capitalize("hello")).toEqual("Hello");
+ expect(text_helper.capitalize("hello")).toEqual("Hello");
});
it("make other letters lower case", function(){
- expect(text_helper.capitalize("HeLLo")).toEqual("Hello");
+ expect(text_helper.capitalize("HeLLo")).toEqual("Hello");
});
it("return an empty string for null values", function() {
- expect(text_helper.capitalize(null)).toEqual("");
+ expect(text_helper.capitalize(null)).toEqual("");
});
});
describe("titleize", function(){
it("capitalize each word", function(){
- expect(text_helper.titleize("hello my DEAR People")).toEqual("Hello My Dear People");
+ expect(text_helper.titleize("hello my DEAR People")).toEqual("Hello My Dear People");
});
it("return an empty string for null values", function() {
- expect(text_helper.titleize(null)).toEqual("");
+ expect(text_helper.titleize(null)).toEqual("");
});
});
describe("trim", function(){
it("removes whitespace in the beginning and end of the text", function(){
- expect(text_helper.trim(" hello my dear people ")).toEqual("hello my dear people");
+ expect(text_helper.trim(" hello my dear people ")).toEqual("hello my dear people");
});
it("return an empty string for null values", function() {
- expect(text_helper.trim(null)).toEqual("");
+ expect(text_helper.trim(null)).toEqual("");
});
});
describe("humanize", function(){
- it("removes dashes and undersocres", function(){
- expect(text_helper.humanize("hello-my_dear_people")).toEqual("Hello my dear people");
+ it("removes dashes and underscores", function(){
+ expect(text_helper.humanize("hello-my_dear_people")).toEqual("Hello my dear people");
});
it("capitalize the sentence", function(){
- expect(text_helper.humanize("hello-my-dear-people")).toEqual("Hello my dear people");
+ expect(text_helper.humanize("hello-my-dear-people")).toEqual("Hello my dear people");
});
it("return an empty string for null values", function() {
- expect(text_helper.humanize(null)).toEqual("");
+ expect(text_helper.humanize(null)).toEqual("");
});
-
});
describe("dasherize", function() {
it("return the dasherized output", function() {
- expect(text_helper.dasherize("hello my dear people ")).toEqual("hello-my-dear-people");
+ expect(text_helper.dasherize("hello my dear people ")).toEqual("hello-my-dear-people");
});
it("return an empty string for null values", function() {
- expect(text_helper.dasherize(null)).toEqual("");
+ expect(text_helper.dasherize(null)).toEqual("");
});
-
});
describe("underscored", function(){
it("return the underscored output", function() {
- expect(text_helper.underscored("hello my dear people ")).toEqual("hello_my_dear_people");
+ expect(text_helper.underscored("hello my dear people ")).toEqual("hello_my_dear_people");
});
it("return an empty string for null values", function() {
- expect(text_helper.underscored(null)).toEqual("");
+ expect(text_helper.underscored(null)).toEqual("");
});
});
describe("invalid parameters", function(){
it("throw an error if invalid parameters were passed", function() {
- expect(function() { text_helper.underscored("hello my dear people ", function(){ } ) }).toThrow();
+ expect(function() { text_helper.underscored("hello my dear people ", function(){ } ) }).toThrow();
});
});

0 comments on commit 5d4c5cf

Please sign in to comment.