fix(item_diary): apply async scroll
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b8910e38ea
commit
968ecab9b2
|
@ -52,10 +52,12 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
scrollToLine(lineFk) {
|
||||
const hashFk = this.lineFk || lineFk;
|
||||
const hash = `vnItemDiary-${hashFk}`;
|
||||
this.$location.hash(hash);
|
||||
this.$anchorScroll();
|
||||
this.$.$applyAsync(() => {
|
||||
const hashFk = this.lineFk || lineFk;
|
||||
const hash = `vnItemDiary-${hashFk}`;
|
||||
this.$location.hash(hash);
|
||||
this.$anchorScroll();
|
||||
});
|
||||
}
|
||||
|
||||
showDescriptor(event, sale) {
|
||||
|
|
|
@ -43,19 +43,27 @@ describe('Item', () => {
|
|||
|
||||
describe('scrollToLine ()', () => {
|
||||
it('should assign $location then call anchorScroll using controller value', () => {
|
||||
jest.spyOn(controller.$, '$applyAsync');
|
||||
jest.spyOn(controller, '$anchorScroll');
|
||||
controller.lineFk = 1;
|
||||
controller.scrollToLine('invalidValue');
|
||||
|
||||
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
$scope.$apply();
|
||||
|
||||
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
||||
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
||||
});
|
||||
|
||||
it('should assign $location then call anchorScroll using received value', () => {
|
||||
jest.spyOn(controller.$, '$applyAsync');
|
||||
jest.spyOn(controller, '$anchorScroll');
|
||||
controller.lineFk = undefined;
|
||||
controller.scrollToLine(1);
|
||||
|
||||
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
$scope.$apply();
|
||||
|
||||
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
||||
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue