Skip to content

Commit

Permalink
async triggers (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
gagoar authored Jan 27, 2021
1 parent 8aaf8b4 commit 3066dfe
Show file tree
Hide file tree
Showing 12 changed files with 4,002 additions and 4,382 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/* linguist-generated linguist-vendored=true
src/rules.guard.ts linguist-generated linguist-vendored=true
52 changes: 26 additions & 26 deletions __tests__/rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('rules', () => {
});

describe('getMatchingRules', () => {
it('no matches', () => {
it('no matches', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -65,10 +65,10 @@ describe('rules', () => {
};
const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot('MatchingRules []');
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot('MatchingRules []');
});

it('Matches includes and eventJsonPath (using contains)', () => {
it('Matches includes and eventJsonPath (using contains)', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -92,7 +92,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, alterEvent)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, alterEvent)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -117,7 +117,7 @@ describe('rules', () => {
]
`);
});
it('Matches includes and eventJsonPath', () => {
it('Matches includes and eventJsonPath', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -138,7 +138,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event, [])).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event, [])).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -163,7 +163,7 @@ describe('rules', () => {
`);
});

it('matching includes/excludes combined', () => {
it('matching includes/excludes combined', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -189,7 +189,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -213,7 +213,7 @@ describe('rules', () => {
]
`);
});
it('matching includes (and not matching another rule)', () => {
it('matching includes (and not matching another rule)', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -237,7 +237,7 @@ describe('rules', () => {

const rules = new Rules(...rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -258,7 +258,7 @@ describe('rules', () => {
]
`);
});
it('does not match includesInPatch (with more than one pattern)', () => {
it('does not match includesInPatch (with more than one pattern)', async () => {
const files = [
{
filename: '/some/file.js',
Expand Down Expand Up @@ -286,14 +286,14 @@ describe('rules', () => {
const rules = new Rules(rule);

expect(
rules.getMatchingRules(files, event, [
await rules.getMatchingRules(files, event, [
'@@ -132,7 +132,7 @@ module simon @@ -1000,7 +1000,7 @@ module gago',
'@@ -132,7 +132,7 @@ module jon @@ -1000,7 +1000,7 @@ module heart',
])
).toMatchObject([]);
});

it('matching includesInPatch (with more than one pattern)', () => {
it('matching includesInPatch (with more than one pattern)', async () => {
const files = [
{
filename: '/some/file.js',
Expand Down Expand Up @@ -321,7 +321,7 @@ describe('rules', () => {
const rules = new Rules(rule);

expect(
rules.getMatchingRules(files, event, [
await rules.getMatchingRules(files, event, [
'@@ -132,7 +132,7 @@ module simon @@ -1000,7 +1000,7 @@ module gago',
'@@ -132,7 +132,7 @@ module jon @@ -1000,7 +1000,7 @@ module heart',
])
Expand Down Expand Up @@ -350,7 +350,7 @@ describe('rules', () => {
]
`);
});
it('matching includes (with more than one includes pattern)', () => {
it('matching includes (with more than one includes pattern)', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -376,7 +376,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -399,7 +399,7 @@ describe('rules', () => {
]
`);
});
it('matching includes (includes as string)', () => {
it('matching includes (includes as string)', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -415,7 +415,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -437,7 +437,7 @@ describe('rules', () => {
`);
});

it('does matches eventJsonPath when sender.type is Bot', () => {
it('does matches eventJsonPath when sender.type is Bot', async () => {
const files = [
{
filename: '/some/file.ts',
Expand All @@ -454,7 +454,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, botEvent)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, botEvent)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -478,7 +478,7 @@ describe('rules', () => {
]
`);
});
it('does not matches eventJsonPath because includes does not match', () => {
it('does not matches eventJsonPath because includes does not match', async () => {
const files = [
{
filename: '/some/file.ts',
Expand All @@ -496,9 +496,9 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchObject([]);
expect(await rules.getMatchingRules(files, event)).toMatchObject([]);
});
it('matches includes && eventJsonPath in the same rule', () => {
it('matches includes && eventJsonPath in the same rule', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -516,7 +516,7 @@ describe('rules', () => {

const rules = new Rules(rule);

expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand All @@ -542,7 +542,7 @@ describe('rules', () => {
]
`);
});
it('matching eventJsonPath', () => {
it('matching eventJsonPath', async () => {
const files = [
{
filename: '/some/file.js',
Expand All @@ -558,7 +558,7 @@ describe('rules', () => {
};

const rules = new Rules(rule);
expect(rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
expect(await rules.getMatchingRules(files, event)).toMatchInlineSnapshot(`
MatchingRules [
Object {
"action": "comment",
Expand Down
Loading

0 comments on commit 3066dfe

Please sign in to comment.