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) {
|
scrollToLine(lineFk) {
|
||||||
const hashFk = this.lineFk || lineFk;
|
this.$.$applyAsync(() => {
|
||||||
const hash = `vnItemDiary-${hashFk}`;
|
const hashFk = this.lineFk || lineFk;
|
||||||
this.$location.hash(hash);
|
const hash = `vnItemDiary-${hashFk}`;
|
||||||
this.$anchorScroll();
|
this.$location.hash(hash);
|
||||||
|
this.$anchorScroll();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showDescriptor(event, sale) {
|
showDescriptor(event, sale) {
|
||||||
|
|
|
@ -43,19 +43,27 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('scrollToLine ()', () => {
|
describe('scrollToLine ()', () => {
|
||||||
it('should assign $location then call anchorScroll using controller value', () => {
|
it('should assign $location then call anchorScroll using controller value', () => {
|
||||||
|
jest.spyOn(controller.$, '$applyAsync');
|
||||||
jest.spyOn(controller, '$anchorScroll');
|
jest.spyOn(controller, '$anchorScroll');
|
||||||
controller.lineFk = 1;
|
controller.lineFk = 1;
|
||||||
controller.scrollToLine('invalidValue');
|
controller.scrollToLine('invalidValue');
|
||||||
|
|
||||||
|
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
$scope.$apply();
|
||||||
|
|
||||||
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
||||||
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assign $location then call anchorScroll using received value', () => {
|
it('should assign $location then call anchorScroll using received value', () => {
|
||||||
|
jest.spyOn(controller.$, '$applyAsync');
|
||||||
jest.spyOn(controller, '$anchorScroll');
|
jest.spyOn(controller, '$anchorScroll');
|
||||||
controller.lineFk = undefined;
|
controller.lineFk = undefined;
|
||||||
controller.scrollToLine(1);
|
controller.scrollToLine(1);
|
||||||
|
|
||||||
|
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
$scope.$apply();
|
||||||
|
|
||||||
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`);
|
||||||
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
expect(controller.$anchorScroll).toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue