Sha256: 29733a8ec3c9d6578c5b3254f02b51534c946bc3e705e83d06b47b93cc78ec04

Contents?: true

Size: 1.22 KB

Versions: 11

Compression:

Stored size: 1.22 KB

Contents

"use strict";

var test = require("tap").test;
var fmt = require("../");

test("fmt", function(t) {
    t.equals(fmt("all your {0} are belong to {1}", "base", "us"),
        "all your base are belong to us");

    var obj = {
        toString: function() {
            return "yoyoma";
        },
    };

    t.equals(fmt("object is called {0} and is {1} ms old", obj, 1),
        "object is called yoyoma and is 1 ms old");

    t.equals(fmt("no arguments => no modifs {0} {1}"),
        "no arguments => no modifs {0} {1}");

    t.end();
});

test("fmt.obj", function(t) {
    var obj2 = {
        name: "yoyoma",
        age: 1,
    };

    t.equals(fmt.obj("object is called {name} and is {age} ms old", obj2),
        "object is called yoyoma and is 1 ms old");

    t.equals(fmt.obj("no matching properties => no modifs {0} {1} {name} {age}", {}),
        "no matching properties => no modifs {0} {1} {name} {age}");

    t.equals(fmt.obj("works for arrays too: [{2}, {1}, {0}]", ["one", "two", "three"]),
        "works for arrays too: [three, two, one]");

    t.end();
});

test("fmt.repeat", function(t) {
    t.equals(fmt.repeat("*", 3), "***");
    t.equals(fmt.repeat("*", 0), "");
    t.equals(fmt.repeat("", 3), "");

    t.end();
});

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/simple-fmt/test/simple-fmt-tests.js
ilog-0.4.0 node_modules/simple-fmt/test/simple-fmt-tests.js
ilog-0.3.3 node_modules/simple-fmt/test/simple-fmt-tests.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/simple-fmt/test/simple-fmt-tests.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/simple-fmt/test/simple-fmt-tests.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/simple-fmt/test/simple-fmt-tests.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/simple-fmt/test/simple-fmt-tests.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/simple-fmt/test/simple-fmt-tests.js
gulp_assets-1.0.0.pre.5 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-fmt/test/simple-fmt-tests.js
gulp_assets-1.0.0.pre.4 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-fmt/test/simple-fmt-tests.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/defs/node_modules/simple-fmt/test/simple-fmt-tests.js