Skip to content

Commit 5a0995a

Browse files
committed
added tests
1 parent 9f39734 commit 5a0995a

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Diff for: test/cronParser.ts

+4
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,9 @@ describe("CronParser", function () {
4444
it("dayOfWeek dangling comma", function () {
4545
assert.equal(new CronParser("*/5 * * * * ,2").parse()[5], "2");
4646
});
47+
48+
it("should parse cron @ expression", function () {
49+
assert.equal(new CronParser("@weekly").parse().length, 7);
50+
});
4751
});
4852
});

Diff for: test/cronstrue.ts

+30
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,36 @@ describe("Cronstrue", function () {
638638
});
639639
});
640640

641+
describe("@ expressions", function () {
642+
it("@yearly", function () {
643+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM, on day 1 of the month, only in January");
644+
});
645+
646+
it("@annually", function () {
647+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM, on day 1 of the month, only in January");
648+
});
649+
650+
it("@monthly", function () {
651+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM, on day 1 of the month");
652+
});
653+
654+
it("@weekly", function () {
655+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM, only on Sunday");
656+
});
657+
658+
it("@daily", function () {
659+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM");
660+
});
661+
662+
it("@midnight", function () {
663+
assert.equal(cronstrue.toString(this.test?.title as string), "At 12:00 AM");
664+
});
665+
666+
it("@hourly", function () {
667+
assert.equal(cronstrue.toString(this.test?.title as string), "Every hour");
668+
});
669+
});
670+
641671
describe("verbose", function () {
642672
it("30 4 1 * *", function () {
643673
assert.equal(cronstrue.toString(this.test?.title as string, { verbose: true }), "At 04:30 AM, on day 1 of the month");

0 commit comments

Comments
 (0)