This guide was created by VTEX for internal purposes inspired by Shopify's GraphQL API Tutorial.
There is no official GraphQL guidelines for handling errors, so we are stabilishing our own.
const twoFactorMachine = { | |
two_factor: { | |
id: 'two_factor', | |
onEntry: ['checkTwoFactorSettings'], | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'setup', cond: 'needsToSetupTwoFactor' }, |
const twoFactorMachine = { | |
two_factor: { | |
id: 'two_factor', | |
onEntry: ['checkTwoFactorSettings'], | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'setup', cond: 'needsToSetupTwoFactor' }, |
const twoFactorMachine = { | |
two_factor: { | |
id: 'two_factor', | |
onEntry: ['checkTwoFactorSettings'], | |
initial: 'unknown', | |
states: { | |
unknown: { | |
on: { | |
'': [ | |
{ target: 'setup', cond: 'needsToSetupTwoFactor' }, |
#!/bin/bash | |
CHANGED_FILES=`git diff origin/master...HEAD --name-only` | |
node_modules/eslint/bin/eslint.js -f json $CHANGED_FILES --quiet | node_modules/eslines/index.js --quiet | |
if [[ $? != 0 ]] ; then | |
echo "Fix style violations" | |
exit 1 | |
fi | |
echo "All changed files are good" |
This guide was created by VTEX for internal purposes inspired by Shopify's GraphQL API Tutorial.
There is no official GraphQL guidelines for handling errors, so we are stabilishing our own.
http://angular.github.io/protractor/#/api
Note: Most commands return promises, so you only resolve their values through using jasmine expect API or using .then(function()) structure
Based on this post: https://spagettikoodi.wordpress.com/2015/01/14/angular-testing-cheat-sheet/ by @crystoll
browser.get('yoururl'); // Load address, can also use '#yourpage'
Learn from live example how to test a $resource factory. What to test? What /not/ to test? When to use $resource? These questions will be answered here.
Let's start with a brief review.
The $resource
is an Angular Service that makes it really easy to setup CRUD operations with RESTful APIs. If you have a /api/posts/ , this is all the code you need to setup http operations for POST, PUT, DELETE and GET:
# Testing an Angular $resource factory | |
#angular #medium | |
Learn from live example how to test a $resource factory. What to test? What /not/ to test? When to use $resource? These questions will be answered here. | |
[DEMO LINK](https://gist.run/?id=38949509eed11e6c1527218385579f80) | |
Let's start with a brief review. | |
## What is $resource and when to use it? |
This is an example of how to test an Angular Resource created with $resource
.
Important take aways:
$resource
for Angular Cached Resource) without needing toi go change all previous tests.transformResponse
action property of a $resource
, you replace the default angular parser that is transforming backend response from string to JSON. It has some logic to ensure that the response is a JSON and can be parsed securely. You can use it by injecting $http
into your factory and using `$http.defaults.transformRespon// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |