Skip to content

Commit 0266a11

Browse files
authored
Merge pull request #334 from MurhafSousli/dev
v8.0.0
2 parents 187cd38 + e602964 commit 0266a11

File tree

6 files changed

+122
-43
lines changed

6 files changed

+122
-43
lines changed

.github/workflows/integrate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
node-version: 14
1818
- name: Install dependencies
19-
run: npm install
19+
run: npm ci
2020
- name: Build
2121
run: npm run build-lib
2222
- name: Test

.github/workflows/netlify.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ jobs:
1414
with:
1515
node-version: 14
1616
- name: Install dependencies
17-
run: npm install
18-
- name: Build and link library
19-
run: npm run build-lib && npm run link-lib
17+
run: npm ci
2018
- name: Build demo
2119
run: npm run build-demo
2220
- name: Deploy to Netlify

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 8.0.0
4+
5+
- feat: Add matcher feature to http module, closes [#254](https://github.com/MurhafSousli/ngx-progressbar/issues/254) in [a6ab70b](https://github.com/MurhafSousli/ngx-progressbar/pull/331/commits/a6ab70b3c2c9f15c2c0e71c45a88e9745f61202c) and [ce3c0d6](https://github.com/MurhafSousli/ngx-progressbar/pull/331/commits/ce3c0d6b86632c873689330cddea6a977aecf07a).
6+
- fix: Remove case-sensitive from `silentApis`, closes [#283](https://github.com/MurhafSousli/ngx-progressbar/issues/283) in [32da22c](https://github.com/MurhafSousli/ngx-progressbar/pull/331/commits/32da22c85e9d9ea8897f7cfb6f11ef1c69226a1a).
7+
- refactor: Change `zoom` to `transform: scale`, closes [#275](https://github.com/MurhafSousli/ngx-progressbar/issues/275) in [c78dff6](https://github.com/MurhafSousli/ngx-progressbar/pull/331/commits/c78dff66506aaedf41cd6d82e52944bbafa5748c).
8+
- Added unit tests
9+
10+
### Breaking changes
11+
12+
**Before:**
13+
14+
- `silentApis` used to check the url using `url.startsWith()`
15+
16+
**After:**
17+
18+
- `silentApis` checks the url using `url.includes()`
19+
20+
When `silentApis` is used along with `matcher` regex, it will check if the URL matches both cases, learn more at [wiki page](https://github.com/MurhafSousli/ngx-progressbar/wiki/HttpClient-requests).
21+
22+
323
## 7.0.0
424

525
- Upgrade to Angular 13, closes [#319](https://github.com/MurhafSousli/ngx-progressbar/issues/319) in [fdf89a2](https://github.com/MurhafSousli/ngx-progressbar/pull/325/commits/fdf89a216f3b137e00b6f6f303840f32ad9f30e8).

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"build-lib": "ng build ngx-progressbar --configuration production",
88
"test-lib": "ng test ngx-progressbar",
99
"test-lib-headless": "ng test ngx-progressbar --watch=false --no-progress --browsers=ChromeHeadless",
10-
"link-lib": "npm link dist/ngx-progressbar && npm link ngx-progressbar",
1110
"publish-lib": "npm publish dist/ngx-progressbar"
1211
},
1312
"private": true,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { TestBed } from '@angular/core/testing';
2+
import { RouterTestingModule } from '@angular/router/testing';
3+
import { Component } from '@angular/core';
4+
import { Router } from '@angular/router';
5+
6+
import { NgProgressModule, NgProgress, NgProgressRef } from 'ngx-progressbar';
7+
import { NgProgressRouterModule } from 'ngx-progressbar/router';
8+
9+
const CUSTOM_PROGRESS_ID: string = 'my-custom-progress';
10+
const CUSTOM_PROGRESS_DELAY: number = 200;
11+
12+
@Component({
13+
selector: 'page-1',
14+
template: ''
15+
})
16+
export class Page1 {
17+
}
18+
19+
@Component({
20+
selector: 'page-2',
21+
template: ''
22+
})
23+
export class Page2 {
24+
}
25+
26+
describe(`NgProgressRouter`, () => {
27+
let ngProgress: NgProgress;
28+
let router: Router;
29+
30+
beforeEach(async () => {
31+
await TestBed.configureTestingModule({
32+
imports: [
33+
NgProgressModule,
34+
NgProgressRouterModule.withConfig({
35+
id: CUSTOM_PROGRESS_ID,
36+
delay: CUSTOM_PROGRESS_DELAY
37+
}),
38+
RouterTestingModule.withRoutes([
39+
{ path: '', component: Page1 },
40+
{ path: 'page2', component: Page2 }
41+
])
42+
],
43+
declarations: [Page1, Page2]
44+
}).compileComponents();
45+
46+
ngProgress = TestBed.inject(NgProgress);
47+
router = TestBed.inject(Router);
48+
});
49+
50+
it('should start/complete the progress bar on route change', (done: DoneFn) => {
51+
const progressRef: NgProgressRef = ngProgress.ref(CUSTOM_PROGRESS_ID);
52+
spyOn(progressRef, 'start');
53+
spyOn(progressRef, 'complete');
54+
55+
router.navigate(['page2']).then(() => {
56+
setTimeout(() => {
57+
expect(progressRef.complete).toHaveBeenCalled();
58+
done();
59+
}, CUSTOM_PROGRESS_DELAY);
60+
});
61+
62+
expect(progressRef.start).toHaveBeenCalled();
63+
});
64+
});
Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,18 @@
1-
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2-
import { RouterTestingModule } from '@angular/router/testing';
3-
import { of } from 'rxjs';
4-
import { NgProgressComponent } from './ng-progress.component';
5-
import { NgProgress } from './ng-progress.service';
6-
7-
class NgProgressStub {
8-
config = {};
9-
10-
ref() {
11-
return {
12-
state: of(
13-
{
14-
active: true,
15-
value: 5
16-
}
17-
)
18-
};
19-
}
20-
}
21-
22-
describe('NgProgressComponent', () => {
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
import { NgProgress, NgProgressComponent, NgProgressModule } from 'ngx-progressbar';
3+
4+
describe('NgProgress Component', () => {
235
let component: NgProgressComponent;
6+
let ngProgress: NgProgress;
247
let fixture: ComponentFixture<NgProgressComponent>;
258

26-
beforeEach(waitForAsync(() => {
9+
beforeEach(() => {
2710
TestBed.configureTestingModule({
28-
declarations: [NgProgressComponent],
29-
imports: [
30-
RouterTestingModule
31-
],
32-
providers: [
33-
{ provide: NgProgress, useClass: NgProgressStub }
34-
]
35-
}).compileComponents();
36-
}));
11+
imports: [NgProgressModule]
12+
});
13+
14+
ngProgress = TestBed.inject(NgProgress);
15+
});
3716

3817
beforeEach(() => {
3918
fixture = TestBed.createComponent(NgProgressComponent);
@@ -44,10 +23,29 @@ describe('NgProgressComponent', () => {
4423
expect(component).toBeDefined();
4524
});
4625

47-
// it('should destroy component without errors', () => {
48-
// const ngOnDestroySpy = spyOn(component, 'ngOnDestroy');
49-
// fixture.destroy();
50-
// component.ngOnDestroy();
51-
// expect(ngOnDestroySpy).toHaveBeenCalled();
52-
// });
26+
it('should start/complete the progress using the start/complete functions', (done: DoneFn) => {
27+
const progressRef = ngProgress.ref();
28+
spyOn(progressRef, 'start');
29+
spyOn(progressRef, 'complete');
30+
component.ngOnInit();
31+
32+
component.start();
33+
expect(progressRef.start).toHaveBeenCalled();
34+
35+
setTimeout(() => {
36+
component.complete();
37+
expect(progressRef.complete).toHaveBeenCalled();
38+
done();
39+
}, 200);
40+
});
41+
42+
it('should get true on isStarted when progress is started', (done: DoneFn) => {
43+
component.ngOnInit();
44+
component.start();
45+
46+
setTimeout(() => {
47+
expect(component.isStarted).toBeTrue();
48+
done();
49+
});
50+
});
5351
});

0 commit comments

Comments
 (0)