Skip to content

Commit

Permalink
test: renaming variables after linter
Browse files Browse the repository at this point in the history
  • Loading branch information
satanTime committed Apr 10, 2022
1 parent feabc00 commit d87e1b8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
7 changes: 3 additions & 4 deletions tests/issue-455/abstract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ const injectableArgs = [
{
providedIn: 'root',
useFactory: () => {
const function_: InjectedAbstraction = (typeof jest ===
'undefined'
const fn: InjectedAbstraction = (typeof jest === 'undefined'
? jasmine.createSpy()
: jest.fn()) as any as InjectedAbstraction;
function_.hello =
fn.hello =
typeof jest === 'undefined' ? jasmine.createSpy() : jest.fn();

return function_;
return fn;
},
} as never,
];
Expand Down
58 changes: 29 additions & 29 deletions tests/issue-455/token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,42 @@ import {
ngMocks,
} from 'ng-mocks';

interface myInjectedFn {
interface InjectedAbstraction {
(): string;
hello: () => number;
}

const myInjectedFn: InjectionToken<myInjectedFn> =
const TOKEN: InjectionToken<InjectedAbstraction> =
new (InjectionToken as any)('InjectedFn', {
factory: () => {
const function_: any =
const fn: any =
typeof jest === 'undefined' ? jasmine.createSpy() : jest.fn();
function_.hello =
fn.hello =
typeof jest === 'undefined' ? jasmine.createSpy() : jest.fn();

return function_;
return fn;
},
providedIn: 'root',
});

@Component({ template: '' })
export class TestWithoutDecoratorComponent {
public constructor(
@Inject(myInjectedFn)
public myInjectedFn: myInjectedFn,
@Inject(TOKEN)
public token: InjectedAbstraction,
) {}
}

@Component({ template: '' })
export class TestWithDecoratorComponent {
public constructor(
@Inject(myInjectedFn)
public myInjectedFn: myInjectedFn,
@Inject(TOKEN)
public token: InjectedAbstraction,
) {}
}

ngMocks.defaultMock(
myInjectedFn,
TOKEN,
() =>
(typeof jest === 'undefined'
? jasmine.createSpy().and.returnValue('FOO')
Expand Down Expand Up @@ -88,11 +88,11 @@ describe('issue-455:token', () => {

it('should build properly but fails', () => {
const fixture = MockRender(TestWithoutDecoratorComponent);
expect(fixture.point.componentInstance.token()).toEqual(
'FOO',
);
expect(
fixture.point.componentInstance.myInjectedFn(),
).toEqual('FOO');
expect(
fixture.point.componentInstance.myInjectedFn,
fixture.point.componentInstance.token,
).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -102,7 +102,7 @@ describe('issue-455:token', () => {
beforeEach(() =>
MockBuilder(TestWithoutDecoratorComponent)
.mock(
myInjectedFn,
TOKEN,
(typeof jest === 'undefined'
? jasmine.createSpy().and.returnValue('BAR')
: jest.fn().mockReturnValue('BAR')) as any,
Expand All @@ -112,11 +112,11 @@ describe('issue-455:token', () => {

it('should build properly but fails', () => {
const fixture = MockRender(TestWithoutDecoratorComponent);
expect(fixture.point.componentInstance.token()).toEqual(
'BAR',
);
expect(
fixture.point.componentInstance.myInjectedFn(),
).toEqual('BAR');
expect(
fixture.point.componentInstance.myInjectedFn,
fixture.point.componentInstance.token,
).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -125,7 +125,7 @@ describe('issue-455:token', () => {
beforeEach(() =>
MockBuilder(TestWithoutDecoratorComponent)
.mock(
myInjectedFn as any,
TOKEN as any,
(typeof jest === 'undefined'
? jasmine.createSpy().and.returnValue('BAR')
: jest.fn().mockReturnValue('BAR')) as any,
Expand All @@ -136,11 +136,11 @@ describe('issue-455:token', () => {

it('should build properly and succeed', () => {
const fixture = MockRender(TestWithoutDecoratorComponent);
expect(fixture.point.componentInstance.token()).toEqual(
'BAR',
);
expect(
fixture.point.componentInstance.myInjectedFn(),
).toEqual('BAR');
expect(
fixture.point.componentInstance.myInjectedFn,
fixture.point.componentInstance.token,
).toHaveBeenCalledTimes(1);
});
});
Expand All @@ -151,7 +151,7 @@ describe('issue-455:token', () => {
describe('with provide', () => {
beforeEach(() =>
MockBuilder(TestWithDecoratorComponent).provide({
provide: myInjectedFn,
provide: TOKEN,
useFactory: () =>
typeof jest === 'undefined'
? jasmine.createSpy().and.returnValue('QUX')
Expand All @@ -161,11 +161,11 @@ describe('issue-455:token', () => {

it('should build properly and succeed', () => {
const fixture = MockRender(TestWithDecoratorComponent);
expect(fixture.point.componentInstance.token()).toEqual(
'QUX',
);
expect(
fixture.point.componentInstance.myInjectedFn(),
).toEqual('QUX');
expect(
fixture.point.componentInstance.myInjectedFn,
fixture.point.componentInstance.token,
).toHaveBeenCalledTimes(1);
});
});
Expand Down

0 comments on commit d87e1b8

Please sign in to comment.