Add tests

This commit is contained in:
Dolan
2022-10-26 23:43:51 +01:00
parent 522b21862b
commit d2c0e656d0

View File

@ -1,4 +1,5 @@
import { expect } from "chai";
import * as sinon from "sinon";
import { Formatter } from "@export/formatter";
import { Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments } from "./comment-run";
@ -40,6 +41,17 @@ describe("CommentReference", () => {
});
describe("Comment", () => {
let clock: sinon.SinonFakeTimers;
beforeEach(() => {
const now = new Date(1999, 0, 1);
clock = sinon.useFakeTimers(now.getTime());
});
afterEach(() => {
clock.restore();
});
describe("#constructor()", () => {
it("should create", () => {
const component = new Comment({
@ -72,6 +84,37 @@ describe("Comment", () => {
],
});
});
it("should create by using default date", () => {
const component = new Comment({
id: 0,
text: "test-comment",
});
const tree = new Formatter().format(component);
expect(tree).to.deep.equal({
"w:comment": [
{ _attr: { "w:id": 0, "w:date": "1999-01-01T00:00:00.000Z" } },
{
"w:p": [
{
"w:r": [
{
"w:t": [
{
_attr: {
"xml:space": "preserve",
},
},
"test-comment",
],
},
],
},
],
},
],
});
});
});
});