-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix it * fix * fix it * add more tests * simplify combine API * refactor between API * refactor combine
- Loading branch information
Showing
11 changed files
with
128 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Build | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Semantic PR title | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
semantic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Test | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: '**/node_modules' | ||
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Test | ||
run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
import { at } from './at'; | ||
import { between } from './between'; | ||
import { inMonth } from './inMonth'; | ||
import { on } from './on'; | ||
|
||
describe('between', () => { | ||
it('should combine two minutes', () => { | ||
it('should provide minutes range', () => { | ||
expect(between(at.minute(23), at.minute(33)).toString()).toBe( | ||
'23-33 * * * *' | ||
); | ||
}); | ||
|
||
it('hour range', () => { | ||
it('should provide hours range', () => { | ||
expect(between(at.hour(2), at.hour(11)).toString()).toBe('* 2-11 * * *'); | ||
}); | ||
|
||
it('monday to friday', () => { | ||
expect(between(at.dayOfTheWeek(0), at.dayOfTheWeek(4)).toString()).toBe( | ||
it('should provide month range', () => { | ||
expect(between(inMonth(2), inMonth(11)).toString()).toBe('* * * 2-11 *'); | ||
}); | ||
|
||
it('should provide days of the week, monday to friday', () => { | ||
expect(between(on.dayOfTheWeek(0), on.dayOfTheWeek(4)).toString()).toBe( | ||
'* * * * 0-4' | ||
); | ||
}); | ||
|
||
it('should throw an error if different types', () => { | ||
expect(() => | ||
between(on.dayOfTheWeek(0), on.dayOfTheMonth(4)).toString() | ||
).toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,38 @@ | ||
import { at } from './at'; | ||
import { combine } from './combine'; | ||
import { every } from './every'; | ||
import { inMonth } from './inMonth'; | ||
import { on } from './on'; | ||
|
||
describe('combine', () => { | ||
it('every hour at 30 minutes', () => { | ||
expect( | ||
combine( | ||
every.dayOfTheWeek(), | ||
every.month(), | ||
every.dayOfTheMonth(), | ||
every.hours(2), | ||
at.minute(30) | ||
).toString() | ||
).toBe('30 */2 * * *'); | ||
it('should provide every hour at 30 minutes', () => { | ||
expect(combine(every.hours(2), at.minute(30)).toString()).toBe( | ||
'30 */2 * * *' | ||
); | ||
}); | ||
|
||
it('every day at midnight', () => { | ||
it('should provide every day at midnight', () => { | ||
expect(combine(at.hour(0), at.minute(0)).toString()).toBe('0 0 * * *'); | ||
}); | ||
|
||
it('should provide every Thursday at midnight in July', () => { | ||
expect( | ||
combine( | ||
every.dayOfTheWeek(), | ||
every.month(), | ||
every.dayOfTheMonth(), | ||
on.dayOfTheWeek(5), | ||
at.hour(0), | ||
inMonth(7), | ||
at.minute(0) | ||
).toString() | ||
).toBe('0 0 * * *'); | ||
).toBe('0 0 * 7 5'); | ||
}); | ||
|
||
it('every day at 2am', () => { | ||
expect( | ||
combine( | ||
every.dayOfTheWeek(), | ||
every.month(), | ||
every.dayOfTheMonth(), | ||
at.hour(2), | ||
at.minute(0) | ||
).toString() | ||
).toBe('0 2 * * *'); | ||
it('should provide every day at 2am', () => { | ||
expect(combine(at.hour(2), at.minute(0)).toString()).toBe('0 2 * * *'); | ||
}); | ||
|
||
it('every sunday at 2am', () => { | ||
it('should provide every sunday at 2am', () => { | ||
expect( | ||
combine( | ||
on.dayOfTheWeek(6), | ||
every.month(), | ||
every.dayOfTheMonth(), | ||
at.hour(2), | ||
at.minute(0) | ||
).toString() | ||
combine(on.dayOfTheWeek(6), at.hour(2), at.minute(0)).toString() | ||
).toBe('0 2 * * 6'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
import { every } from './every'; | ||
|
||
describe('every', () => { | ||
it('every minute', () => { | ||
it('should provide every minute', () => { | ||
expect(every.minute().toString()).toBe('* * * * *'); | ||
}); | ||
|
||
it('every 2 minutes', () => { | ||
it('should provide every 2 minutes', () => { | ||
expect(every.minutes(2).toString()).toBe('*/2 * * * *'); | ||
}); | ||
|
||
it('every even minute', () => { | ||
it('should provide every even minute', () => { | ||
expect(every.minutes(2).toString()).toBe('*/2 * * * *'); | ||
}); | ||
|
||
it('every 5 minutes', () => { | ||
it('should provide every 5 minutes', () => { | ||
expect(every.minutes(5).toString()).toBe('*/5 * * * *'); | ||
}); | ||
|
||
it('every quarter hour', () => { | ||
it('should provide every quarter hour', () => { | ||
expect(every.minutes(15).toString()).toBe('*/15 * * * *'); | ||
}); | ||
|
||
it('every half hour', () => { | ||
it('should provide every half hour', () => { | ||
expect(every.minutes(30).toString()).toBe('*/30 * * * *'); | ||
}); | ||
|
||
it('every hour', () => { | ||
it('should provide every hour', () => { | ||
expect(every.hour().toString()).toBe('0 * * * *'); | ||
}); | ||
|
||
it('every 1 hour', () => { | ||
it('should provide every 1 hour', () => { | ||
expect(every.hours(1).toString()).toBe('0 */1 * * *'); | ||
}); | ||
|
||
it('every 2 hours', () => { | ||
it('should provide every 2 hours', () => { | ||
expect(every.hours(2).toString()).toBe('0 */2 * * *'); | ||
}); | ||
|
||
it('every day', () => { | ||
it('should provide every day', () => { | ||
expect(every.dayOfTheWeek().toString()).toBe('0 0 * * *'); | ||
}); | ||
|
||
it('every sunday', () => { | ||
it('should provide every sunday', () => { | ||
expect(every.dayOfTheWeek(6).toString()).toBe('0 0 * * */6'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { inMonth } from './inMonth'; | ||
|
||
describe('inMonth', () => { | ||
it('in January', () => { | ||
it('should provide in January', () => { | ||
expect(inMonth(1).toString()).toBe('* * * 1 *'); | ||
}); | ||
|
||
it('in January and December', () => { | ||
it('should provide in January and December', () => { | ||
expect(inMonth([1, 12]).toString()).toBe('* * * 1,12 *'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { on } from './on'; | ||
|
||
describe('on', () => { | ||
it('on Sunday', () => { | ||
it('should provide on Sunday', () => { | ||
expect(on.dayOfTheWeek(6).toString()).toBe('0 0 * * 6'); | ||
}); | ||
|
||
it('on 3rd day of the month', () => { | ||
it('should provide on 3rd day of the month', () => { | ||
expect(on.dayOfTheMonth(3).toString()).toBe('0 0 3 * *'); | ||
}); | ||
}); |