From af70cf95d9d010f27da1c1c8987c807ee3255a10 Mon Sep 17 00:00:00 2001 From: HO-COOH <42881734+HO-COOH@users.noreply.github.com> Date: Sat, 15 May 2021 00:14:36 +0800 Subject: Refactor, add {file} template (#221) * Refactor, add {file} template * Add test for {file} expansion --- src/test/CppTests/Config.test.ts | 8 +++++--- src/test/CppTests/FileDescription.test.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/test') diff --git a/src/test/CppTests/Config.test.ts b/src/test/CppTests/Config.test.ts index 1afbef3..f6ec573 100644 --- a/src/test/CppTests/Config.test.ts +++ b/src/test/CppTests/Config.test.ts @@ -11,6 +11,7 @@ import * as assert from "assert"; import * as moment from "moment"; import * as vscode from "vscode"; import { Config } from "../../Config"; +import GitConfig from "../../GitConfig"; import TestSetup from "./TestSetup"; // Defines a Mocha test suite to group tests of similar kind together @@ -242,11 +243,12 @@ suite("C++ - Configuration Tests", () => { "@author {author}", "@date {date}", "@note {email}", + "@file {file}", ]; - testSetup.cfg.Generic.useGitUserName = true; - testSetup.cfg.Generic.useGitUserEmail = true; const result = testSetup.SetLine("void foo();").GetResult(); - assert.notStrictEqual(result, "/**\n * @author {author}\n * @date {date}\n * @note {email}\n */"); + const date = moment().format("YYYY-MM-DD"); + assert.strictEqual(result, `/**\n * @author your name\n * @date ${date}\n * @note you@domain.com\n` + + ` * @file MockDocument.h\n */`); }); test("Env variable", () => { diff --git a/src/test/CppTests/FileDescription.test.ts b/src/test/CppTests/FileDescription.test.ts index 2e0bb7e..ec0034d 100644 --- a/src/test/CppTests/FileDescription.test.ts +++ b/src/test/CppTests/FileDescription.test.ts @@ -78,9 +78,9 @@ suite("File Description Tests", () => { test("custom block", () => { testSetup.cfg.File.fileOrder = ["custom"]; testSetup.cfg.File.customTag = ["First Line", "{year} Year Line", "{date} Date Line", - "{author} Author Line", "{email} Email Line"]; + "{author} Author Line", "{email} Email Line", "{file} File Line"]; const result = testSetup.SetLine("").GetResult(); assert.strictEqual(result, "/**\n * First Line\n * " + year + " Year Line\n * " + date + " Date Line\n" + - " * your name Author Line\n * you@domain.com Email Line\n */"); + " * your name Author Line\n * you@domain.com Email Line\n" + " * MockDocument.h File Line\n */"); }); }); -- cgit v1.2.3