Skip to content

Commit

Permalink
Use jest.useFakeTimer instead of sinon module
Browse files Browse the repository at this point in the history
  • Loading branch information
kjirou committed Mar 10, 2024
1 parent fec6131 commit be50d77
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from "fs-extra";
import path from "path";
import sinon from "sinon";

import {
UbwSettings,
Expand Down Expand Up @@ -44,14 +43,13 @@ describe("executeHelp", () => {
});

describe("executeNow", () => {
let clock: any;

beforeEach(() => {
clock = sinon.useFakeTimers(new Date("2019-01-01 00:00:00+0000"));
jest.useFakeTimers();
jest.setSystemTime(new Date("2019-01-01 00:00:00+0000"));
});

afterEach(() => {
clock.restore();
jest.useRealTimers();
});

it("should return a date-time string formatted with UTC", () => {
Expand Down Expand Up @@ -81,16 +79,14 @@ describe("executeInit", () => {

describe("executeArticleNew", () => {
describe("when after `executeInit`", () => {
let clock: any;

beforeEach(() => {
clock = sinon.useFakeTimers(new Date("2019-01-01 00:00:00+0000"));

jest.useFakeTimers();
jest.setSystemTime(new Date("2019-01-01 00:00:00+0000"));
return executeInit(workspaceRoot);
});

afterEach(() => {
clock.restore();
jest.useRealTimers();
});

it("can create a source file of an article", () => {
Expand All @@ -110,11 +106,11 @@ describe("executeArticleNew", () => {

describe("executeCompile, executeCompileWithSettings", () => {
describe("when after `executeInit` and `executeArticleNew`", () => {
let clock: any;
let configFilePath: string;

beforeEach(() => {
clock = sinon.useFakeTimers(new Date("2019-01-01 00:00:00+0000"));
jest.useFakeTimers();
jest.setSystemTime(new Date("2019-01-01 00:00:00+0000"));
configFilePath = path.join(workspaceRoot, "ubw-configs.js");

return executeInit(workspaceRoot)
Expand All @@ -128,7 +124,7 @@ describe("executeCompile, executeCompileWithSettings", () => {
});

afterEach(() => {
clock.restore();
jest.useRealTimers();
});

describe("basic specification of `executeCompile`", () => {
Expand Down

0 comments on commit be50d77

Please sign in to comment.