Skip to content

Commit 841488d

Browse files
committed
fix: Fix identation problems and improve grammar
1 parent 5093f2b commit 841488d

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

testing/unit-testing-jest/docs/angular-configuration.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Angular default test configuration
2-
When you create a new component, directive, service, etc. The default configuration of the tests file is something like this.
2+
When you create a new component, directive, service, etc. The default configuration of the tests file should be something like this.
3+
34
```ts
45
import { ComponentFixture, TestBed } from '@angular/core/testing';
56
import { ExampleComponent } from './example.component';
@@ -27,10 +28,10 @@ describe('ExampleComponent', () => {
2728
});
2829
```
2930

30-
This is the default configuration of a test file. As you can see, it uses a lot of what we already got on the top theory. Now let's go to understand the TestBed.
31+
This is the default configuration of a test file. As you can see, it uses a lot of what we already got on the top theory. Now let's understand the TestBed.
3132

3233
### Understanding TestBed :test_tube:
33-
TestBed is a utility of [Angular](https://angular.io/api/core/testing/TestBed). With this, we can configure all the environments of our tests.
34+
[TestBed](https://angular.io/api/core/testing/TestBed) is a utility of Angular. With this, we can configure all the environments of our tests.
3435

3536
Configure a testing module
3637
With this we can set all the dependencies for our tests, for example:
@@ -39,7 +40,7 @@ TestBed.configureTestingModule(
3940
{
4041
declarations: [ ExampleComponent, OtherComponents ... ],
4142
imports: [ PipesModule, RouterTestingModule, OtherModules... ],
42-
providers: [ ExampleService, DecimalPipe, ... ],
43+
providers: [ ExampleService, DecimalPipe, OtherProviders... ],
4344
},
4445
schemas: [CUSTOM_ELEMENTS_SCHEMA],
4546
);
@@ -68,5 +69,4 @@ order to update the DOM with the expected information.
6869

6970
### But why?
7071
According to Angular docs:
71-
> Delayed change detection is intentional and useful. It gives the tester an opportunity to inspect and change the state of the component before Angular initiates data binding and calls lifecycle hooks.
72-
See more information [here](https://angular.io/guide/testing-components-scenarios#detectchanges).
72+
> [Delayed change detection is intentional and useful. It gives the tester an opportunity to inspect and change the state of the component before Angular initiates data binding and calls lifecycle hooks.](https://angular.io/guide/testing-components-scenarios#detectchanges)

testing/unit-testing-jest/docs/getting-dom-elements.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ So, les's see how it works:
66
## Getting element
77
Consider the next element
88
<br>
9-
test.html
9+
``test.html``
1010
```html
1111
<button class="btn_login" (click)="login()">Login</button>
1212
```
1313

14-
test.spec.ts
14+
``test.spec.ts``
1515
```ts
1616
it('should call login function', () => {
1717
// as nativeElement
@@ -31,7 +31,7 @@ When using `triggerEventHandler` note that the second parameter is the actual ev
3131
You can see more about ```nativeElement vs debugElement``` on this [link](https://angular.io/guide/testing-components-basics), also note that in debugElement we use the css class from ```By``` to use this you need to import from ```import { By } from '@angular/platform-browser';``` an you can see more info about ```By``` on this [link](https://angular.io/api/platform-browser/By)
3232

3333
Consider the next elements
34-
test.html
34+
``test.html``
3535
```html
3636
<app-header-process
3737
[tabs]="data.tabs"
@@ -47,7 +47,7 @@ test.html
4747
</ul>
4848
```
4949
To get any of this elements we can use:
50-
test.spec.ts
50+
``test.spec.ts``
5151
```ts
5252
it('should render information', () => {
5353
// get component

testing/unit-testing-jest/docs/http-test.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ tests cases.
7777
it('return all users', (done) => {
7878
service.findAllUsers().subscribe((users) => {
7979
expect(users).toEqual(USERS);
80-
done();
81-
});
82-
const req = controller.expectOne('api/users');
83-
expect(req.request.method).toEqual('GET');
84-
req.flush(USERS);
80+
done();
8581
});
82+
const req = controller.expectOne('api/users');
83+
expect(req.request.method).toEqual('GET');
84+
req.flush(USERS);
85+
});
8686
```
8787
In this test, we subscribe to ```findAllUsers```. Then, inside we create the assertion to verify the response data. ```done()``` is used to indicate the successful finish of the subscription.
8888

testing/unit-testing-jest/docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Whats is testing? and why is important?
1+
## Whats is testing and why is important?
22
Testing is a method to check if the code is working as expected. Testing the code helps to detect bugs on time and prevent the appearance of new bugs in the future. Also, testing gives confidence to our code. We can expect that they don't find problems in QA tests.
33

44
## Benefits

testing/unit-testing-jest/docs/issues.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import '@angular/localize/init';
2323
```
2424

2525
### Navigator dependency
26-
Sometimes, when we are testing many problems dont let our test execute. Is so frustrating don't find a simple solution just checking the error console and understanding the problem. This is a collection of typical errors that you can get when you are testing. Hope that helps.
26+
Sometimes, when we are testing many problems don't let our test execute. Is so frustrating don't find a simple solution just checking the error console and understanding the problem. This is a collection of typical errors that you can get when you are testing. Hope that helps.
2727

2828
### Error with the navigator
2929
#### Issue:
3030
If we use the navigator router on the test files, maybe we get an error like this:
3131
![error navigator](./assets/NavigatorError.png "Error");
32-
This means we are using a specific path to test the routing. But we arent declaring on the environments file.
32+
This means we are using a specific path to test the routing. But we aren't declaring on the environments file.
3333

3434
For example, this component:
3535
```ts
@@ -116,7 +116,7 @@ describe('ExampleComponent', () => {
116116
const element = fixture.debugElement.query(By.css('tag'))
117117
expect(element).toBeTruthy();
118118
});
119-
}
119+
});
120120
```
121121
This solution came from [here](https://stackoverflow.com/questions/42656045/angular2-testing-and-resolved-data-how-to-test-ngoninit)
122122

testing/unit-testing-jest/docs/spy-local.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Component
88
selector: 'app-example',
99
templateUrl: `
1010
<div class="section" (click)="log('test')">
11-
Click me
11+
Click me
1212
</div>
1313
`
1414
})
1515
export class ExampleComponent {
16-
log(message: string): void {
17-
console.log(message);
18-
}
16+
log(message: string): void {
17+
console.log(message);
18+
}
1919
}
2020
````
2121

@@ -38,10 +38,10 @@ describe('ExampleComponent', () => {
3838
fixture.detectChanges();
3939
});
4040

41-
it('Should call log function when div is clicked', () => {
41+
it('Should call log function when div is clicked', () => {
4242
const spy = jest.spyOn(component, 'log');
4343
fixture.nativeElement.querySelector('.section').click();
4444
expect(spy).toHaveBeeCalledWith('test');
45-
});
45+
});
4646
});
4747
````

0 commit comments

Comments
 (0)