This file contains 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 { DebugElement } from '@angular/core'; | |
import { ComponentFixture } from '@angular/core/testing'; | |
import { By } from '@angular/platform-browser'; | |
/** Find an element by integration test id | |
* @return a debugElement or null when not found | |
*/ | |
export function findByIntId<T>(fixture: ComponentFixture<T> , intId: string): DebugElement | null { | |
return fixture.debugElement.query(By.css(`[data-int=${intId}]`)); | |
} |
This file contains 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
/** Download a file from Blob and clean up memory */ | |
export function downloadBlob(blob: Blob, filename: string | null = null): void { | |
const url = window.URL.createObjectURL(blob); | |
const a = document.createElement('a'); | |
a.setAttribute('href', url); | |
a.setAttribute('download', filename || 'download'); | |
document.body.appendChild(a); | |
// Prevent E2E from actually downloading files during test runs | |
if (!isE2ETesting()) { |
This file contains 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
const path = require('path'); | |
const jest = require('jest'); | |
/** | |
* Object props is a more extensible solution when we have a lot of props | |
*/ | |
function buildModule({ pathname }) { | |
return ` | |
module.exports = { | |
__esModule: true, |
This file contains 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
/** | |
Usage: | |
@Action(nameOf<ActionFn>('myAction'), { namespace: 'my-module'}) | |
loadGraph!: ActionType<'myAction'>; | |
*/ | |
function _createActions() { | |
return { |
This file contains 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
/** Mocked location object. Includes the original to rollback to the native one */ | |
export interface MockedLocation { | |
/** The original location definition */ | |
original: Location; | |
/** Restore the original location object */ | |
clear(): void; | |
} |
This file contains 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
/** | |
* @see http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php | |
*/ | |
class Test { | |
constructor() { | |
this.FN = []; | |
this.FNDA = []; | |
this.DA = []; | |
this.BRDA = []; | |
} |
This file contains 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
/** | |
* This is a node script to merge cobertura reports in XML format. | |
* It requires `xml2js` : `npm i -D xml2js` | |
* | |
* Execute with: | |
* ``` | |
* node merge-cobertura.js coverage/file1.xml coverage/file2.xml to=coverage-final.xml | |
* ``` | |
* @see https://github.com/Leonidas-from-XIV/node-xml2js | |
* @author Jérémy Legros |
This file contains 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
/** | |
* This module aims to provides stubs Google Maps (Javascript API). | |
* It is not comprehensive, but a working solution that allows unit testing, without the async pain. | |
* @example | |
* import * as google from './google-maps.spec'; | |
* (<any>window).google = google; | |
*/ | |
export const google = { | |
maps: { | |
ControlPosition: { |
This file contains 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
blobToJson(blob: Blob): Observable<any> { | |
let loadend: Observable<any>; | |
if (blob.type === 'application/json') { | |
const reader = new FileReader(); | |
loadend = fromEvent(reader, 'loadend').pipe( | |
map((read: any) => { | |
this.logger.debug('blobToJson:loadend *', JSON.parse(read.target.result)); | |
return JSON.parse(read.target.result); | |
}) | |
); |
NewerOlder