Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: MockRender and pipes #2398

Closed
satanTime opened this issue May 7, 2022 · 1 comment · Fixed by #2399
Closed

Bug: MockRender and pipes #2398

satanTime opened this issue May 7, 2022 · 1 comment · Fixed by #2399
Assignees
Labels
bug Something isn't working released v13.5.1

Comments

@satanTime
Copy link
Member

import {MockBuilder, MockRender, ngMocks} from 'ng-mocks';

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'phone'
})
export class PhonePipe implements PipeTransform {

  transform(value: any, args?: any): any {
    const inputVal = value.toString();
    const slice1 = inputVal.slice(0, 3);
    const slice2 = inputVal.slice(3, 6);
    const slice3 = inputVal.slice(6)
    return `+1(${slice1})-${slice2}-${slice3}`;
  }
}

describe('Phone Pipe', () => {
  beforeEach(() => {
    return MockBuilder(PhonePipe).provide(PhonePipe)
  })
  it('should be defined', () => {
    const fixture = MockRender(PhonePipe);
    expect(fixture.point.componentInstance).toBeDefined();
  })
  it('should test the transform value', () => {
    const fixture = MockRender('{{ "4161234567" | phone }}');
    expect(ngMocks.formatText(fixture)).toBe('+1(416)-123-4567');
  })
})
@satanTime satanTime added the bug Something isn't working label May 7, 2022
@satanTime satanTime self-assigned this May 7, 2022
satanTime added a commit to satanTime/ng-mocks that referenced this issue May 7, 2022
satanTime added a commit to satanTime/ng-mocks that referenced this issue May 7, 2022
satanTime added a commit that referenced this issue May 7, 2022
fix(MockRender): renders pipes with $implicit param #2398
@satanTime
Copy link
Member Author

v13.5.1 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released v13.5.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant