chore: apply amnesty on existing not fixable issues (#32215)
* fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint line around directives issue * fix: eslint semi rule * fix: eslint newline per chain rule * fix: eslint space infix ops rule * fix: eslint space-in-parens issue * fix: eslint space before function paren issue * fix: eslint space before blocks issue * fix: eslint arrow body style issue * fix: eslint dot-location issue * fix: eslint quotes issue * fix: eslint quote props issue * fix: eslint operator assignment issue * fix: eslint new line after import issue * fix: indent issues * fix: operator assignment issue * fix: all autofixable eslint issues * fix: all react related fixable issues * fix: autofixable eslint issues * chore: remove all template literals * fix: remaining autofixable issues * chore: apply amnesty on all existing issues * fix: failing xss-lint issues * refactor: apply amnesty on remaining issues * refactor: apply amnesty on new issues * fix: remove file level suppressions * refactor: apply amnesty on new issues
This commit is contained in:
committed by
GitHub
parent
e94af3c2d3
commit
8480dbc228
@@ -13,43 +13,53 @@ describe('ViewedTracker', () => {
|
||||
it('calls the handlers when an element is viewed', () => {
|
||||
document.body.innerHTML = '<div id="d1"></div><div id="d2"></div><div id="d3"></div>';
|
||||
const tracker = new ViewedEventTracker();
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const element of document.getElementsByTagName('div')) {
|
||||
tracker.addElement(element, 1000);
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
const handlerSpy = jasmine.createSpy('handlerSpy');
|
||||
tracker.addHandler(handlerSpy);
|
||||
const elvIter = tracker.elementViewings.values();
|
||||
// Pick two elements, and mock them so that one has met the criteria to be viewed,
|
||||
// and the other hasn't.
|
||||
const viewed = elvIter.next().value;
|
||||
// eslint-disable-next-line no-undef
|
||||
spyOn(viewed, 'areViewedCriteriaMet').and.returnValue(true);
|
||||
viewed.checkIfViewed();
|
||||
expect(handlerSpy).toHaveBeenCalledWith(viewed.el, {
|
||||
elementHasBeenViewed: true,
|
||||
});
|
||||
const unviewed = elvIter.next().value;
|
||||
// eslint-disable-next-line no-undef
|
||||
spyOn(unviewed, 'areViewedCriteriaMet').and.returnValue(false);
|
||||
unviewed.checkIfViewed();
|
||||
// eslint-disable-next-line no-undef
|
||||
expect(handlerSpy).not.toHaveBeenCalledWith(unviewed.el, jasmine.anything());
|
||||
});
|
||||
});
|
||||
|
||||
describe('ElementViewing', () => {
|
||||
beforeEach(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
jasmine.clock().install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
jasmine.clock().uninstall();
|
||||
});
|
||||
|
||||
it('calls checkIfViewed when enough time has elapsed', () => {
|
||||
const viewing = new ElementViewing({}, 500, () => {});
|
||||
// eslint-disable-next-line no-undef
|
||||
spyOn(viewing, 'checkIfViewed').and.callThrough();
|
||||
viewing.seenForMs = 250;
|
||||
viewing.handleVisible();
|
||||
// eslint-disable-next-line no-undef
|
||||
jasmine.clock().tick(249);
|
||||
expect(viewing.checkIfViewed).not.toHaveBeenCalled();
|
||||
// eslint-disable-next-line no-undef
|
||||
jasmine.clock().tick(1);
|
||||
expect(viewing.checkIfViewed).toHaveBeenCalled();
|
||||
});
|
||||
@@ -57,6 +67,7 @@ describe('ElementViewing', () => {
|
||||
it('has been viewed after the specified number of milliseconds', () => {
|
||||
const viewing = new ElementViewing({}, 500, () => {});
|
||||
viewing.seenForMs = 250;
|
||||
// eslint-disable-next-line no-undef
|
||||
spyOn(Date, 'now').and.returnValue(750);
|
||||
viewing.handleVisible();
|
||||
viewing.markTopSeen();
|
||||
@@ -65,6 +76,7 @@ describe('ElementViewing', () => {
|
||||
viewing.checkIfViewed();
|
||||
expect(viewing.hasBeenViewed).toBeFalsy();
|
||||
Date.now.and.returnValue(1000);
|
||||
// eslint-disable-next-line no-undef
|
||||
jasmine.clock().tick(250);
|
||||
expect(viewing.hasBeenViewed).toBeTruthy();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user