This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| while getopts "d" opt; do | |
| case $opt in | |
| d) dryRunOpt="--dry-run";; | |
| esac | |
| done | |
| # prune local "cache" of remote branches first: | |
| git fetch --prune origin | |
| # delete merged to master branches: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # these versions are current as of May 18th 2021 | |
| # info from https://www.npmjs.com/package/@angular/cli -> Versions | |
| #Angular 2: looks like this is the last RC version before switching to angular 4 | |
| npx -p @angular/cli@1.0.0-rc.2 ng new angular2app | |
| #Angular 4: the last CLI version before Angular 5 | |
| npx -p @angular/cli@1.4.10 ng new angular4app | |
| #Angular 5: the last CLI version before Angular 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Observable, isObservable } from 'rxjs'; | |
| import { takeUntil, take } from 'rxjs/operators'; | |
| /** | |
| * A helper function that subscribes to observable and aggregates the values and errors in an array for ease of use. | |
| * | |
| * @param to$ The observable to subscribe to | |
| * @param untilOrTimes The subscription ending count or other observable to signal the end of subscription | |
| * @example | |
| * // arrange |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('test my chart', () => { | |
| it('should draw the chart on ngAfterViewInit', () => { | |
| // arrange | |
| const c = setup().build(); | |
| // act | |
| c.ngAfterViewInit(); | |
| // assert | |
| expect(c.chart).toBeDefined(); | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function chartBuilder(item: ChartItem, options: ChartConfiguration) { | |
| return new Chart(item, options); | |
| } | |
| // The 👆 function and the Token 👇 | |
| const ChartBuilderToken = new InjectionToken<typeof chartBuilder>( | |
| 'The Chart.js instance builder' | |
| ); | |
| @Component({ | |
| ..., |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function setup() { | |
| // common | |
| const router = <Router>( | |
| (<unknown>jasmine.createSpyObj('router', ['navigate'])) | |
| ); | |
| const canvas = new ElementRef(document.createElement('canvas')); | |
| // the chart builder | |
| const chartBuilder = jasmine.createSpy('chart builder'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('when clicked on the second point should NOT navigate to show the selected point if it is NOT visible', () => { | |
| // arrange | |
| const r = mockRouter(); | |
| // arrange the onclick prerequisites | |
| const ch = jasmine.createSpy('chart builder'); | |
| let onClickCallback: Function = () => {}; | |
| ch.and.callFake((i, o) => { | |
| onClickCallback = o.options.onClick; | |
| return { | |
| // mock the isVisible method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('when clicked on the second point should navigate to show the selected point', () => { | |
| // arrange | |
| const r = mockRouter(); | |
| // arrange the onclick prerequisites | |
| const ch = jasmine.createSpy('chart builder'); | |
| let onClickCallback: Function = () => {}; | |
| ch.and.callFake((i, o) => { | |
| onClickCallback = o.options.onClick; | |
| return {}; // <-- mock needed chart methods and props here | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('should draw the chart on ngAfterViewInit with canvas and config', () => { | |
| // arrange | |
| const r = mockRouter(); | |
| const builderSpy = jasmine.createSpy('chart builder') | |
| builderSpy.and.returnValue('the chart'); | |
| const c = new ChartComponent(r, builderSpy); | |
| const canvas = document.createElement('canvas'); | |
| c.canvas = new ElementRef(canvas); | |
| // act | |
| c.ngAfterViewInit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| template: `<canvas #canvas width="200" height="200"></canvas>`, | |
| }) | |
| export class ChartComponent { | |
| @ViewChild('canvas') | |
| canvas: ElementRef | undefined; | |
| chart: Chart | undefined; | |
| constructor(private router: Router) {} | |
NewerOlder