-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { InputService } from './../src/input.service'; | ||
import { fakeAsync } from "@angular/core/testing"; | ||
import { expect } from "chai"; | ||
import { stub } from 'sinon'; | ||
import {CurrencyMaskConfig} from "../src/currency-mask.config"; | ||
|
||
describe('Testing InputService', () => { | ||
var options: CurrencyMaskConfig = { | ||
prefix: '', | ||
suffix: '', | ||
thousands: '.', | ||
decimal: ',', | ||
allowNegative: false, | ||
nullable: false, | ||
align: 'right', | ||
allowZero: true, | ||
precision: undefined, | ||
}; | ||
var inputService: InputService; | ||
|
||
describe('removeNumber', () => { | ||
it('should call updateFieldValue with 1 when deleting the first number followed by a .', () => { | ||
inputService = new InputService({ | ||
selectionStart: 0, | ||
selectionEnd: 0, | ||
}, options); | ||
|
||
inputService.inputManager.rawValue = '1.234,50'; | ||
inputService.updateFieldValue = stub(); | ||
inputService.removeNumber(46); | ||
expect(inputService.updateFieldValue).to.be.calledWith(1); | ||
}); | ||
|
||
it('should call updateFieldValue with 1 when backspacing the first number followed by a .', () => { | ||
inputService = new InputService({ | ||
selectionStart: 1, | ||
selectionEnd: 1, | ||
}, options); | ||
|
||
inputService.inputManager.rawValue = '1.234,50'; | ||
inputService.updateFieldValue = stub(); | ||
inputService.removeNumber(8); | ||
expect(inputService.updateFieldValue).to.be.calledWith(1); | ||
}); | ||
|
||
it('should call updateFieldValue with 2 less than the current position when backspacing any non-number character', () => { | ||
inputService = new InputService({ | ||
selectionStart: 6, | ||
selectionEnd: 6, | ||
}, options); | ||
|
||
inputService.inputManager.rawValue = '1.234,50'; | ||
inputService.updateFieldValue = stub(); | ||
inputService.removeNumber(8); | ||
expect(inputService.updateFieldValue).to.be.calledWith(4); | ||
}); | ||
}); | ||
}); |