Skip to content

Commit e8b51b0

Browse files
shuuji3danielroe
andauthored
refactor: use import aliases in test files (#2130)
Co-authored-by: Daniel Roe <daniel@roe.dev>
1 parent d4dae8d commit e8b51b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+98
-125
lines changed

test/e2e/helpers/mock-connector-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
createMockConnectorState,
66
DEFAULT_MOCK_CONFIG,
77
type MockConnectorConfig,
8-
} from '../../../cli/src/mock-state.ts'
8+
} from '../../../cli/src/mock-state'
99

1010
export { MockConnectorStateManager, createMockConnectorState, DEFAULT_MOCK_CONFIG }
1111
export type { MockConnectorConfig }

test/e2e/helpers/mock-connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* with global singleton state for Playwright test isolation.
44
*/
55

6-
import { MockConnectorServer as BaseMockConnectorServer } from '../../../cli/src/mock-app.ts'
6+
import { MockConnectorServer as BaseMockConnectorServer } from '../../../cli/src/mock-app'
77
import { type MockConnectorConfig, initGlobalMockState } from './mock-connector-state'
88

99
export class MockConnectorServer {

test/nuxt/components/HeaderConnectorModal.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
22
import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime'
33
import { ref, computed, readonly, nextTick } from 'vue'
44
import type { VueWrapper } from '@vue/test-utils'
5-
import type { PendingOperation } from '../../../cli/src/types'
5+
import type { PendingOperation } from '~~/cli/src/types'
66
import { HeaderConnectorModal } from '#components'
77

88
// Mock state that will be controlled by tests

test/nuxt/composables/use-colors.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('useCssVariables', () => {
6464
})
6565

6666
it('does not attach html mutation observer when client is not supported', async () => {
67-
const { useCssVariables } = await import('../../../app/composables/useColors')
67+
const { useCssVariables } = await import('~/composables/useColors')
6868

6969
useSupportedMock.mockReturnValueOnce(computed(() => false))
7070
mockComputedStyle({ '--bg': 'oklch(1 0 0)' })
@@ -84,7 +84,7 @@ describe('useCssVariables', () => {
8484
})
8585

8686
it('attaches html mutation observer when client is supported', async () => {
87-
const { useCssVariables } = await import('../../../app/composables/useColors')
87+
const { useCssVariables } = await import('~/composables/useColors')
8888

8989
useSupportedMock.mockReturnValueOnce(computed(() => true))
9090
mockComputedStyle({ '--bg': 'oklch(1 0 0)' })

test/nuxt/composables/use-preferences-provider.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, beforeEach } from 'vitest'
22
import { defineComponent, onMounted } from 'vue'
33
import { mount } from '@vue/test-utils'
4-
import { usePreferencesProvider } from '../../../app/composables/usePreferencesProvider'
4+
import { usePreferencesProvider } from '~/composables/usePreferencesProvider'
55

66
const STORAGE_KEY = 'npmx-list-prefs'
77

test/nuxt/composables/use-settings.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ describe('useSettings - keyboardShortcuts', () => {
77

88
describe('default value', () => {
99
it('should default keyboardShortcuts to true', async () => {
10-
const { useSettings } = await import('../../../app/composables/useSettings')
10+
const { useSettings } = await import('~/composables/useSettings')
1111
const { settings } = useSettings()
1212
expect(settings.value.keyboardShortcuts).toBe(true)
1313
})
1414
})
1515

1616
describe('useKeyboardShortcuts composable', () => {
1717
it('should return true by default', async () => {
18-
const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings')
18+
const { useKeyboardShortcuts } = await import('~/composables/useSettings')
1919
const enabled = useKeyboardShortcuts()
2020
expect(enabled.value).toBe(true)
2121
})
2222

2323
it('should reflect changes made via settings', async () => {
24-
const { useSettings } = await import('../../../app/composables/useSettings')
25-
const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings')
24+
const { useSettings } = await import('~/composables/useSettings')
25+
const { useKeyboardShortcuts } = await import('~/composables/useSettings')
2626
const { settings } = useSettings()
2727
const enabled = useKeyboardShortcuts()
2828

@@ -34,8 +34,8 @@ describe('useSettings - keyboardShortcuts', () => {
3434
})
3535

3636
it('should be reactive', async () => {
37-
const { useSettings } = await import('../../../app/composables/useSettings')
38-
const { useKeyboardShortcuts } = await import('../../../app/composables/useSettings')
37+
const { useSettings } = await import('~/composables/useSettings')
38+
const { useKeyboardShortcuts } = await import('~/composables/useSettings')
3939
const { settings } = useSettings()
4040
const enabled = useKeyboardShortcuts()
4141

test/unit/app/composables/use-charts.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ vi.mock('~/utils/npm/api', () => ({
44
fetchNpmDownloadsRange: vi.fn(),
55
}))
66

7-
import { getNpmPackageCreationDate } from '../../../../app/composables/useCharts'
7+
import { getNpmPackageCreationDate } from '~/composables/useCharts'
88

99
describe('getNpmPackageCreationDate', () => {
1010
it('returns created date from packument time', () => {

test/unit/app/composables/use-number-formatter.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
22
import { computed, ref } from 'vue'
3-
import { useBytesFormatter } from '../../../../app/composables/useNumberFormatter'
3+
import { useBytesFormatter } from '~/composables/useNumberFormatter'
44

55
describe('useBytesFormatter', () => {
66
beforeEach(() => {

test/unit/app/router.options.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import routerOptions from '../../../app/router.options'
2+
import routerOptions from '~/router.options'
33

44
type ScrollBehavior = NonNullable<typeof routerOptions.scrollBehavior>
55
type RouteArg = Parameters<ScrollBehavior>[0]

test/unit/app/utils/chart-data-buckets.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
buildWeeklyEvolution,
66
buildMonthlyEvolution,
77
buildYearlyEvolution,
8-
} from '../../../../app/utils/chart-data-buckets'
8+
} from '~/utils/chart-data-buckets'
99

1010
describe('fillPartialBucket', () => {
1111
it('scales proportionally', () => {

0 commit comments

Comments
 (0)