MOBILE-4017 testing utils: make error path agnostic and set default eol
as LF in vscode settingsmain
parent
c139683631
commit
f27282a633
|
@ -0,0 +1,2 @@
|
||||||
|
* text=auto
|
||||||
|
*.ts eol=lf
|
|
@ -11,6 +11,7 @@
|
||||||
"eslint.format.enable": true,
|
"eslint.format.enable": true,
|
||||||
"html.format.endWithNewline": true,
|
"html.format.endWithNewline": true,
|
||||||
"html.format.wrapLineLength": 140,
|
"html.format.wrapLineLength": 140,
|
||||||
|
"files.eol": "\n",
|
||||||
"files.trimFinalNewlines": true,
|
"files.trimFinalNewlines": true,
|
||||||
"files.insertFinalNewline": true,
|
"files.insertFinalNewline": true,
|
||||||
"files.trimTrailingWhitespace": true,
|
"files.trimTrailingWhitespace": true,
|
||||||
|
|
|
@ -16,6 +16,8 @@ import Faker from 'faker';
|
||||||
|
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
|
|
||||||
|
import { agnosticPath } from '@/testing/utils';
|
||||||
|
|
||||||
describe('CoreError', () => {
|
describe('CoreError', () => {
|
||||||
|
|
||||||
it('behaves like an error', () => {
|
it('behaves like an error', () => {
|
||||||
|
@ -38,7 +40,7 @@ describe('CoreError', () => {
|
||||||
expect(error!.name).toEqual('CoreError');
|
expect(error!.name).toEqual('CoreError');
|
||||||
expect(error!.message).toEqual(message);
|
expect(error!.message).toEqual(message);
|
||||||
expect(error!.stack).not.toBeNull();
|
expect(error!.stack).not.toBeNull();
|
||||||
expect(error!.stack).toContain('src/core/classes/tests/error.test.ts');
|
expect(error!.stack).toContain(agnosticPath('src/core/classes/tests/error.test.ts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be subclassed', () => {
|
it('can be subclassed', () => {
|
||||||
|
@ -70,7 +72,7 @@ describe('CoreError', () => {
|
||||||
expect(error!.name).toEqual('CustomCoreError');
|
expect(error!.name).toEqual('CustomCoreError');
|
||||||
expect(error!.message).toEqual(`Custom message: ${message}`);
|
expect(error!.message).toEqual(`Custom message: ${message}`);
|
||||||
expect(error!.stack).not.toBeNull();
|
expect(error!.stack).not.toBeNull();
|
||||||
expect(error!.stack).toContain('src/core/classes/tests/error.test.ts');
|
expect(error!.stack).toContain(agnosticPath('src/core/classes/tests/error.test.ts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { AbstractType, Component, CUSTOM_ELEMENTS_SCHEMA, Type, ViewChild } from
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
import { sep } from 'path';
|
||||||
|
|
||||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||||
import { CoreSingletonProxy, Network, Platform } from '@singletons';
|
import { CoreSingletonProxy, Network, Platform } from '@singletons';
|
||||||
|
@ -245,3 +246,13 @@ export async function renderWrapperComponent<T>(
|
||||||
|
|
||||||
return renderTemplate(component, `<${tag} ${inputAttributes}></${tag}>`, config);
|
return renderTemplate(component, `<${tag} ${inputAttributes}></${tag}>`, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the provided path into a cross-platform path.
|
||||||
|
*
|
||||||
|
* @param unixPath path in unix format.
|
||||||
|
* @returns cross-platform path.
|
||||||
|
*/
|
||||||
|
export function agnosticPath(unixPath: string): string {
|
||||||
|
return unixPath.replace(/\//g, sep);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue