-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve highlighter - fix tests and cleanup
- Loading branch information
Showing
15 changed files
with
486 additions
and
493 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
76 changes: 34 additions & 42 deletions
76
packages/core/src/highlighter/HighlightFunctionsInitializer.test.ts
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 |
---|---|---|
@@ -1,48 +1,40 @@ | ||
describe('place', () => { | ||
it('holder', () => { | ||
// pass | ||
}); | ||
}); | ||
jest.dontMock('./HighlightFunctionsInitializer'); | ||
jest.dontMock('../services/DependencyService'); | ||
|
||
// jest.dontMock('./HighlightFunctionsInitializer'); | ||
// jest.dontMock('../services/DependencyService'); | ||
import { HighlightFunctionsInitializer } from './HighlightFunctionsInitializer'; | ||
import { ElementWithMeta } from '../types'; | ||
import { DependencyService } from '../services/DependencyService'; | ||
|
||
// import { HighlightFunctionsInitializer } from './HighlightFunctionsInitializer'; | ||
// import { getMockedInstance } from '@testFixtures/mocked'; | ||
// import { Properties } from '../Properties'; | ||
// import { ElementWithMeta } from '../types'; | ||
// import { DependencyService } from '../services/DependencyService'; | ||
describe('HighlightFunctionsInitializer', () => { | ||
let highlightFunctionInitializer: HighlightFunctionsInitializer; | ||
let mockedElement: ElementWithMeta; | ||
|
||
// describe('HighlightFunctionsInitializer', () => { | ||
// let highlightFunctionInitializer: HighlightFunctionsInitializer; | ||
// let mockedElement: ElementWithMeta; | ||
// const mockedColor = 'rgb(0, 30, 50)'; | ||
|
||
// beforeEach(async () => { | ||
// jest.clearAllMocks(); | ||
// const dependencyService = new DependencyService(); | ||
// dependencyService.init({}); | ||
// highlightFunctionInitializer = | ||
// dependencyService.highlightFunctionInitializer; | ||
// mockedElement = document.createElement('div') as Element as ElementWithMeta; | ||
// getMockedInstance(Properties).config.highlightColor = mockedColor; | ||
// (mockedElement._tolgee as any) = {}; | ||
// highlightFunctionInitializer.initFunctions(mockedElement); | ||
// }); | ||
beforeEach(async () => { | ||
document.body.appendChild = jest.fn(); | ||
jest.clearAllMocks(); | ||
const dependencyService = new DependencyService(); | ||
dependencyService.init({}); | ||
highlightFunctionInitializer = | ||
dependencyService.highlightFunctionInitializer; | ||
mockedElement = document.createElement('div') as Element as ElementWithMeta; | ||
(mockedElement._tolgee as any) = {}; | ||
highlightFunctionInitializer.initFunctions(mockedElement); | ||
}); | ||
|
||
// afterEach(async () => { | ||
// jest.clearAllMocks(); | ||
// }); | ||
afterEach(async () => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
// test('Will reset to correct initial color', async () => { | ||
// mockedElement.style.backgroundColor = '#222222'; | ||
// mockedElement._tolgee.highlight(); | ||
// mockedElement._tolgee.unhighlight(); | ||
// expect(mockedElement.style.backgroundColor).toEqual('rgb(34, 34, 34)'); | ||
// }); | ||
test('Will reset to correct initial color', async () => { | ||
mockedElement.style.backgroundColor = '#222222'; | ||
mockedElement._tolgee.highlight(); | ||
mockedElement._tolgee.unhighlight(); | ||
expect(mockedElement.style.backgroundColor).toEqual('rgb(34, 34, 34)'); | ||
}); | ||
|
||
// test('Will highlight', async () => { | ||
// mockedElement._tolgee.highlight(); | ||
// expect(mockedElement.style.backgroundColor).toEqual(mockedColor); | ||
// }); | ||
// }); | ||
test('Will highlight', async () => { | ||
jest.spyOn(mockedElement, 'isConnected', 'get').mockReturnValue(true); | ||
mockedElement._tolgee.highlight(); | ||
expect(document.body.appendChild).toBeCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.