-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba38bd9
commit b9ef10d
Showing
13 changed files
with
197 additions
and
74 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
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
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,22 @@ | ||
const Rools = require('../src'); | ||
const { frank } = require('./facts/users')(); | ||
const { rule1, rule2 } = require('./rules/availability'); | ||
require('./setup'); | ||
|
||
describe('Rules.evaluate() / async', () => { | ||
it('should call async action / action with async/await', async () => { | ||
const rools = new Rools({ logging: { debug: true } }); | ||
rools.register(rule1); | ||
const result = await rools.evaluate({ user: frank }); | ||
console.log(result); // eslint-disable-line no-console | ||
expect(result.products).to.shallowDeepEqual(['dsl', 'm4g', 'm3g']); | ||
}); | ||
|
||
it('should call async action / action with promises', async () => { | ||
const rools = new Rools({ logging: { debug: true } }); | ||
rools.register(rule2); | ||
const result = await rools.evaluate({ user: frank }); | ||
console.log(result); // eslint-disable-line no-console | ||
expect(result.products).to.shallowDeepEqual(['dsl', 'm4g', 'm3g']); | ||
}); | ||
}); |
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,14 +1,26 @@ | ||
const frank = { | ||
name: 'frank', | ||
stars: 347, | ||
dateOfBirth: new Date('1995-01-01'), | ||
address: { | ||
city: 'hamburg', | ||
street: 'redderkoppel', | ||
country: 'germany', | ||
}, | ||
}; | ||
|
||
const michael = { | ||
name: 'michael', | ||
stars: 156, | ||
dateOfBirth: new Date('1999-08-08'), | ||
address: { | ||
city: 'san Francisco', | ||
street: 'willard', | ||
country: 'usa', | ||
}, | ||
}; | ||
|
||
module.exports = () => ({ | ||
frank: { ...frank }, | ||
michael: { ...michael }, | ||
frank: JSON.parse(JSON.stringify(frank)), | ||
michael: JSON.parse(JSON.stringify(michael)), | ||
}); |
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,16 +1,20 @@ | ||
const good = { | ||
temperature: 20, | ||
humidity: 39, | ||
pressure: 1319, | ||
windy: true, | ||
rainy: false, | ||
}; | ||
|
||
const bad = { | ||
temperature: 9, | ||
humidity: 89, | ||
pressure: 1013, | ||
windy: true, | ||
rainy: true, | ||
}; | ||
|
||
module.exports = () => ({ | ||
good: { ...good }, | ||
bad: { ...bad }, | ||
good: JSON.parse(JSON.stringify(good)), | ||
bad: JSON.parse(JSON.stringify(bad)), | ||
}); |
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
Oops, something went wrong.