Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

chore: test code quality improvements #520

Merged
merged 5 commits into from
Oct 31, 2024
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 .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true
end_of_line = lf
insert_final_newline = true

[*.{js,json,yml}]
[*.{js,ts,json,yml}]
charset = utf-8
indent_style = space
indent_size = 2
2 changes: 0 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ module.exports = {
files: ['**/*.spec.ts'],
extends: ['plugin:playwright/playwright-test'],
rules: {
'import/order': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'playwright/no-standalone-expect': 'off',
'playwright/no-networkidle': 'off',
'playwright/no-skipped-test': 'off',
Expand Down
4 changes: 1 addition & 3 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ const setupNetwork = async () => {
}
} else {
console.warn(
`Invalid network: ${network}, valid networks are ${SUPPORTED_NETWORK_IDS.join(
', '
)}`
`Invalid network: ${network}, valid networks are ${SUPPORTED_NETWORK_IDS.join(', ')}`
)
}
}
Expand Down
4 changes: 0 additions & 4 deletions components/__tests__/AppLinks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { describe, expect, it } from 'vitest'
import AppLinks from '@/components/AppLinks.vue'

describe('AppLinks', () => {
const profile: Profile = {
address: '0x1234567890abcdef1234567890abcdef12345678',
}

it('should render empty links', async () => {
const component = await renderSuspended(AppLinks, {
props: {
Expand Down
1 change: 0 additions & 1 deletion components/__tests__/AssetStandardBadge.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { fireEvent, screen } from '@testing-library/vue'
import { beforeEach, describe, expect, it } from 'vitest'

import AssetStandardBadge from '@/components/AssetStandardBadge.vue'
Expand Down
5 changes: 3 additions & 2 deletions components/__tests__/FollowCounters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { beforeEach, describe, expect, it } from 'vitest'

import type { ProfileFollowers } from '@/types/profile'
import FollowCounters from '../FollowCounters.vue'

import type { ProfileFollowers } from '@/types/profile'

describe('FollowCounters', () => {
beforeEach(() => {
useIntl().setupIntl(defaultConfig)
Expand Down
4 changes: 0 additions & 4 deletions components/__tests__/LinkButton.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { describe, expect, it } from 'vitest'
import LinkButton from '@/components/LinkButton.vue'

describe('LinkButton', () => {
const profile: Profile = {
address: '0x1234567890abcdef1234567890abcdef12345678',
}

it('should render empty state', async () => {
const component = await renderSuspended(LinkButton, {})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { fireEvent, screen } from '@testing-library/vue'
import { beforeEach, describe, expect, it } from 'vitest'

import AppNavbarProfileSearchGraph from '../AppNavbarProfileSearchGraph.vue'
Expand Down
1 change: 1 addition & 0 deletions domains/grid/components/__tests__/GridFloatingMenu.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { createTestingPinia } from '@pinia/testing'
import { beforeEach, describe, expect, it, vi } from 'vitest'

import GridFloatingMenu from '../GridFloatingMenu.vue'

vi.mock('/utils/getCurrentProfileAddress', () => ({
Expand Down
2 changes: 1 addition & 1 deletion domains/grid/utils/__tests__/buildGrid.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { e } from 'pinia-orm/dist/shared/pinia-orm.ed84a779'
import { describe, expect, it } from 'vitest'

import { buildGrid } from '../buildGrid'

describe('buildGrid', () => {
Expand Down
1 change: 1 addition & 0 deletions domains/grid/utils/__tests__/compareGridWidgets.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { compareGridWidgets } from '../compareGridWidgets'

describe('compareGridWidgets', () => {
Expand Down
1 change: 1 addition & 0 deletions domains/grid/utils/__tests__/compareGrids.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { compareGrids } from '../compareGrids'

describe('compareGrids', () => {
Expand Down
1 change: 1 addition & 0 deletions domains/grid/utils/__tests__/createGridId.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { createGridId } from '../createGridId'

describe('createGridId', () => {
Expand Down
1 change: 1 addition & 0 deletions domains/grid/utils/__tests__/createWidgetObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from 'vitest'

import { createWidgetObject } from '../createWidgetObject'

vi.mock('/domains/grid/utils/generateItemId', () => ({
Expand Down
1 change: 1 addition & 0 deletions domains/grid/utils/__tests__/gridParser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { parsePlatformInput } from '../gridParser'

const YOUTUBE_IFRAME_ALLOW =
Expand Down
3 changes: 2 additions & 1 deletion domains/grid/utils/__tests__/gridToConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from 'vitest'
import { describe, expect, it } from 'vitest'

import { gridToConfig } from '../gridToConfig'

describe('gridToConfig', () => {
Expand Down
3 changes: 2 additions & 1 deletion domains/grid/utils/__tests__/purifyGridConfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from 'vitest'
import { describe, expect, it } from 'vitest'

import { purifyGridConfig } from '../purifyGridConfig'

describe('purifyGridConfig', () => {
Expand Down
3 changes: 1 addition & 2 deletions pages/settings/data-provider/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { renderSuspended } from '@nuxt/test-utils/runtime'
import { createTestingPinia } from '@pinia/testing'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { beforeEach, describe, expect, it } from 'vitest'

import { useAppStore } from '@/stores/app'
import Index from '../index.vue'

describe('Settings data-provider page', () => {
Expand Down
4 changes: 1 addition & 3 deletions services/ipfs/formdata-base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ export class BaseFormDataUploader {
error = (error as any).error || error
throw new NetworkError(
new Error(
`unknown server response while pinning File to IPFS: ${
error || response.status
}`
`unknown server response while pinning File to IPFS: ${error || response.status}`
),
response.status
)
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/404.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@playwright/test'

import { test } from './helpers/fixtures'

test('can access 404 page', async ({ page }) => {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from '@playwright/test'

import { test } from './helpers/fixtures'

test('landing page when no browser extension', async ({ page }) => {
Expand Down
6 changes: 1 addition & 5 deletions utils/__tests__/assetChecks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { LSP4_TOKEN_TYPES } from '@lukso/lsp-smart-contracts'
import { describe, expect, test } from 'vitest'

import { LSP4_TOKEN_TYPES } from '@lukso/lsp-smart-contracts'
import type {
SelectProfileOption,
SelectStringOption,
} from '@lukso/web-components'
import {
getBalance,
hasBalance,
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/assetTypes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { getAssetType } from '../assetTypes'

test('getAssetType', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/cloneObject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { cloneObject } from '../cloneObject'

describe('cloneObject', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/decodeParameter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, test, vi } from 'vitest'
import ABICoder from 'web3-eth-abi'

import { decodeParameter } from '../decodeParameter'

describe('decodeParameter function', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/deepEqual.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { deepEqual } from '../deepEqual'

describe('deepEqual', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/externalUrls.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test } from 'vitest'

import {
universalPageProfileUrl,
universalSwapsProfileUrl,
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/groupAttributes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { groupAttributes } from '../groupAttributes'

describe('groupAttributes', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/hexToNumber.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test, vi } from 'vitest'

import { hexToNumber } from '../hexToNumber'

describe('hexToNumber function', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/hexToUtf8.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test, vi } from 'vitest'

import { hexToUtf8 } from '../hexToUtf8'

describe('hexToUtf8 function', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/isValidURL.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { isValidURL } from '../isValidURL'

describe('isValidURL', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/paddedToAddress.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, test } from 'vitest'

import { paddedToAddress } from '../paddedToAddress'

test('paddedToAddress should remove zero padding from an address', async () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/queryParamsString.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { queryParamsString } from '../queryParamsString'

describe('queryParamsString', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/slug.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { slug } from '../slug'

describe('slug', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/sort.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { stringSort } from '../sort'

describe('stringSort', () => {
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/tokenConversionWithDecimals.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import {
fromTokenUnitWithDecimals,
toTokenUnitWithDecimals,
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/truncate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'

import { truncate } from '../truncate'

describe('truncate', () => {
Expand Down
3 changes: 2 additions & 1 deletion utils/__tests__/unflatArray.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test } from 'vitest'
import { expect, test } from 'vitest'

import { unflatArray } from '../unflatArray'

test('handles consecutive indexes', () => {
Expand Down
2 changes: 1 addition & 1 deletion utils/__tests__/validateLspMetadata.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, test } from 'vitest'

import {
validateAssets,
validateAttributes,
validateDescription,
validateImage,
validateImages,
validateLinks,
validateName,
Expand Down
1 change: 1 addition & 0 deletions utils/__tests__/validators.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, expect, test } from 'vitest'

import {
assertAddress,
assertAddresses,
Expand Down
Loading