-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add jest matcher #150
Merged
Merged
Add jest matcher #150
Commits on May 9, 2018
-
Adding jest matchers to conveniently use targaryen with jest. Usage: ``` const { getDatabase, toAllowRead, toAllowUpdate, toAllowWrite, json } = require('targaryen/plugins/jest'); expect.extend({ toAllowRead, toAllowUpdate, toAllowWrite, }); const RULES_PATH = 'database.rules.json'; const rules = json.loadSync(RULES_PATH); const initialData = {}; const database = getDatabase(rules, initialData); test('basic', () => { expect(database.as(null)).not.toAllowRead('/user'); expect(database.as(null)).toAllowRead('/public'); expect(database.as({ uid: '1234'})).toAllowWrite('/user/1234', { name: 'Anna', }); }); ``` or using the generic matcher: ``` const { getDebugDatabase, toBeAllowed, json } = require('targaryen/plugins/jest'); expect.extend({ toBeAllowed, }); const RULES_PATH = 'database.rules.json'; const rules = json.loadSync(RULES_PATH); const initialData = {}; // NOTE: Create a database with debug set to true for detailed errors const database = getDebugDatabase(rules, initialData); test('generic', () => { expect(database.as(null).read('/user')).not.toBeAllowed(); expect(database.as({ uid: '1234' }).write('/user/1234', { name: 'Anna', })).toBeAllowed(); }); ```
Configuration menu - View commit details
-
Copy full SHA for 4f3fc3b - Browse repository at this point
Copy the full SHA 4f3fc3bView commit details
Commits on May 10, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 4ba2c43 - Browse repository at this point
Copy the full SHA 4ba2c43View commit details -
Configuration menu - View commit details
-
Copy full SHA for 47a92c5 - Browse repository at this point
Copy the full SHA 47a92c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for d417e7c - Browse repository at this point
Copy the full SHA d417e7cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 170e1a7 - Browse repository at this point
Copy the full SHA 170e1a7View commit details -
Run jest plugin tests on travis
As jest requires node v6+ don't run tests if a version lower than 6 is detected.
Configuration menu - View commit details
-
Copy full SHA for e9db456 - Browse repository at this point
Copy the full SHA e9db456View commit details
Commits on May 11, 2018
-
Use grep to check node version
Using grep is less future-proof but the better option, as comparing using `<` can be incorrect.
Configuration menu - View commit details
-
Copy full SHA for 396bd0d - Browse repository at this point
Copy the full SHA 396bd0dView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.