Skip to content

Commit

Permalink
adding tests for SC.String#fmt KVO
Browse files Browse the repository at this point in the history
  • Loading branch information
mauritslamers authored and dcporter committed May 23, 2014
1 parent e436fd3 commit 21d7e25
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions frameworks/runtime/tests/system/string.js
Expand Up @@ -27,6 +27,19 @@ test("Passing named arguments", function() {
]), "Hello, World!");
});

test("Passing named arguments with a SC.Object instance", function() {
var t = SC.Object.create({
prop: 'Hello',
computedProp: function () {
return 'World';
}.property().cacheable(),
unknownProperty: function (key, value) {
if (key === "unknownProp") return "!";
}
});
equals(SC.String.fmt("%{prop}, %{computedProp}%{unknownProp}", [t]), "Hello, World!");
});

test("Passing incomplete named arguments", function() {
equals( SC.String.fmt("%{first}, %{last}%{punctuation}", [{first: 'Hello', punctuation: '!'}]), "Hello, %{last}!", "Formatting a string with an incomplete set of named arguments should leave unspecified named arguments in place." );
})
Expand All @@ -35,14 +48,14 @@ test("Passing arguments with formatters", function() {
var F = function(value) {
return "$" + value;
};

equals(SC.String.fmt("%{number}", [{ number: 12, numberFormatter: F }]), "$12", "Formatter was applied");
});

test("Passing formatting strings with formatters", function() {
var F = function(value, arg) {
return "$" + value + ";" + arg;
};

equals(SC.String.fmt("%{number:blah}", [{ number: 12, numberFormatter: F }]), "$12;blah", "Formatter was applied with argument");
});

0 comments on commit 21d7e25

Please sign in to comment.