diff options
Diffstat (limited to 'desktop/modules/user/test_user.js')
| -rw-r--r-- | desktop/modules/user/test_user.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/desktop/modules/user/test_user.js b/desktop/modules/user/test_user.js index 3f1a73d..cf38609 100644 --- a/desktop/modules/user/test_user.js +++ b/desktop/modules/user/test_user.js @@ -18,7 +18,7 @@ const assert = require("assert"); const src = fs.readFileSync(__dirname + "/User.js", "utf8") .replace(/^\.pragma library$/m, ""); -const U = new Function(src + "\nreturn { parse, keys, locales, gitName, places };")(); +const U = new Function(src + "\nreturn { parse, keys, locales, gitName, places, greeting };")(); // parse: key=value lines; a value may itself hold "=". assert.deepStrictEqual(U.parse("name=Jane Doèr\nlocation=a=b\n\n"), @@ -64,4 +64,12 @@ assert.deepStrictEqual(U.places(nominatim), [ assert.deepStrictEqual(U.places(""), []); assert.deepStrictEqual(U.places("<html>rate limited</html>"), []); + +// greeting: comments and blanks skipped, {user} filled, never the same twice +// running, and the built-in set when the file has nothing. +assert.strictEqual(U.greeting("# c\n\n Yo {user} \n", "jd", 0), "Yo jd"); +assert.strictEqual(U.greeting("a\nb", "jd", 0), "b"); +assert.strictEqual(U.greeting("a\nb", "jd", 0), "a"); +assert.ok(U.greeting("", "jd", 0).endsWith("jd")); + console.log("test_user: ok"); |
