Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webview/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
'!**/*.test.*',
'!src/stories/*',
'!src/stories/**/*.{ts,tsx}',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctly removes the IconWrapper and IconWrappers components from the coverage.

'!src/test/*',
'!src/shared/components/icons/*',
'!src/util/wdyr.ts'
Expand Down
9 changes: 0 additions & 9 deletions webview/setup-tests.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
jest.mock('./src/util/styles', () => {
const actualModule = jest.requireActual('./src/util/styles')
return {
__esModule: true,
...actualModule,
getThemeValue: jest.fn().mockImplementation(() => '#ffffff')
}
})

// eslint-disable-next-line no-global-assign
window = {
addEventListener: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ describe('ComparisonTable', () => {
it('should add and remove the style for the ghost header being dragged', () => {
jest.useFakeTimers()

document.documentElement.style.setProperty(
ThemeProperty.ACCENT_COLOR,
'#ffffff'
)
document.documentElement.style.setProperty(
ThemeProperty.BACKGROUND_COLOR,
'#ffffff'
)

renderTable()

const [header] = getHeaders()
Expand Down
19 changes: 0 additions & 19 deletions webview/src/shared/components/selectMenu/SingleSelect.tsx

This file was deleted.

41 changes: 41 additions & 0 deletions webview/src/util/array.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { changeOrderWithDraggedInfo, pushIf } from './array'

describe('array', () => {
describe('pushIf', () => {
it('should not push to array if condiction is not met', () => {
const currentArray = [1, 2, 3]
pushIf(currentArray, false, [4])

expect(currentArray.length).toBe(3)
})

it('should push to array if condiction is met', () => {
const currentArray = [1, 2, 3]
pushIf(currentArray, true, [4])

expect(currentArray.length).toBe(4)
})
})

describe('changeOrderWithDraggedInfo', () => {
it('should return the same order if there are no draggedInfo', () => {
const currentOrder = ['1', '2', '3', '4']

expect(changeOrderWithDraggedInfo(currentOrder, undefined)).toBe(
currentOrder
)
})

it('should return the order with the dragged item id moved to the end', () => {
const currentOrder = ['1', '2', '3', '4']

expect(
changeOrderWithDraggedInfo(currentOrder, {
group: 'any',
itemId: '2',
itemIndex: '1'
})
).toStrictEqual(['1', '3', '4', '2'])
})
})
})
11 changes: 11 additions & 0 deletions webview/src/util/ids.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createIDWithPrefixAndIndex } from './ids'

describe('ids', () => {
describe('createIDWithPrefixAndIndex', () => {
it('should create an id with a prefix and an index correctly', () => {
expect(createIDWithPrefixAndIndex('my-id', 42, 'this-isAPREFIX')).toBe(
'this-isAPREFIXmy-id_42'
)
})
})
})
14 changes: 14 additions & 0 deletions webview/src/util/styles.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getThemeValue, ThemeProperty } from './styles'

describe('styles', () => {
it('should get the theme value for the requested property when calling getThemeValue', () => {
const styleValue = 'blue'

document.documentElement.style.setProperty(
ThemeProperty.ACCENT_COLOR,
styleValue
)

expect(getThemeValue(ThemeProperty.ACCENT_COLOR)).toBe(styleValue)
})
})