Skip to content

Commit

Permalink
fix(angular): @maskito/angular should not depend on @maskito/kit (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nsbarsukov authored Mar 23, 2023
1 parent 8b4d6e6 commit 0ae7b20
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions projects/angular/src/lib/maskito.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Component} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {FormControl, ReactiveFormsModule} from '@angular/forms';
import {MaskitoModule} from '@maskito/angular';
import {maskitoNumberOptionsGenerator} from '@maskito/kit';
import {MaskitoOptions} from '@maskito/core';

describe(`Maskito Angular package`, () => {
@Component({
Expand All @@ -17,7 +17,20 @@ describe(`Maskito Angular package`, () => {
})
class TestComponent {
readonly control = new FormControl();
readonly options = maskitoNumberOptionsGenerator({precision: 2});
readonly options: MaskitoOptions = {
mask: /^\d+(,\d{0,2})?$/,
preprocessor: ({elementState, data}) => {
const {value, selection} = elementState;

return {
elementState: {
selection,
value: value.replace('.', ','),
},
data: data.replace('.', ','),
};
},
};
}

let fixture: ComponentFixture<TestComponent>;
Expand All @@ -38,11 +51,11 @@ describe(`Maskito Angular package`, () => {
});

it(`Formats new control value`, () => {
fixture.componentInstance.control.setValue(12345.67);
fixture.componentInstance.control.setValue(12345.6789);
fixture.detectChanges();

expect(getText()).toBe(`12\u00A0345.67`);
expect(getValue()).toBe(`12\u00A0345.67`);
expect(getText()).toBe(`12345,67`);
expect(getValue()).toBe(`12345,67`);
});

function getText(): string {
Expand Down

0 comments on commit 0ae7b20

Please sign in to comment.