8000 Dos section · mcibique/vue-testing-examples@3f98d65 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3f98d65

Browse files
committed
Dos section
1 parent b78f16b commit 3f98d65

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ npm run serve --stub
10551055

10561056
### Dos
10571057

1058-
* You can reuse any logic from real implementation in your stub by inheriting the stub from a real one. In this example, you can see the stub not completely overriding existing code, but rather mocking API call based on the username and password. The advantage is that logic inside real implementation is now running too, which might be important for you. Also, mocking axios is better than returning resolved promises because you might have registered an error interceptor (or any other interceptor) which you would like to see running too.
1058+
* You can reuse any logic from a real implementation in your stub by creating the stub based on the real code. In this example, you can see that the real implementation is not completely overrided by the stub, instead, it is mocking API calls based on the username and password. The advantage of this approach, is that the logic inside the real implementation can run alongside the stub, which might be important for you. Also, mocking axios is better than returning resolved promises because you might have registered an error interceptor (or any other interceptor) which you would like to see running too.
10591059

10601060
```js
10611061
import axios from 'axios';
@@ -1069,7 +1069,7 @@ export { AUTH_SERVICE_ID };
10691069
@Override(AUTH_SERVICE_ID)
10701070
export default class AuthServiceStub extends AuthService {
10711071
login (username, password) {
1072-
let axiosMock = new AxiosMockAdapter(axios);
1072+
const axiosMock = new AxiosMockAdapter(axios);
10731073
if (username === password) {
10741074
axiosMock.onPost('/api/login', { username, password }).replyOnce(200, 'random_token');
10751075
} else {

0 commit comments

Comments
 (0)
0