Skip to content

Commit

Permalink
chore: upgrade to vite v5 (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
peetzweg authored Feb 7, 2024
1 parent f68c395 commit 4607273
Show file tree
Hide file tree
Showing 7 changed files with 1,444 additions and 1,524 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20

- name: Install and build
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 14
node-version: 20

- name: Install and test
run: |
yarn
yarn test:vitest
yarn vitest run
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"@headlessui/react": "^1.7.17",
"@headlessui/react": "^1.7.18",
"@heroicons/react": "^1.0.6",
"@polkadot/api": "10.11.1",
"@polkadot/api-contract": "10.11.1",
"@polkadot/api": "10.11.2",
"@polkadot/api-contract": "10.11.2",
"@polkadot/extension-dapp": "^0.46.6",
"@polkadot/ui-keyring": "^3.6.4",
"@polkadot/ui-shared": "^3.6.4",
Expand All @@ -49,55 +49,55 @@
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-markdown": "^8.0.7",
"react-router": "^6.20.0",
"react-router-dom": "^6.20.0",
"react-router": "^6.22.0",
"react-router-dom": "^6.22.0",
"react-select": "^5.8.0",
"react-tooltip": "^5.24.0",
"react-tooltip": "^5.26.0",
"remark-gfm": "^3.0.1",
"tailwind-merge": "^1.14.0",
"yup": "^1.3.2"
"yup": "^1.3.3"
},
"devDependencies": {
"@cypress/code-coverage": "^3.12.11",
"@cypress/code-coverage": "^3.12.20",
"@cypress/snapshot": "^2.1.7",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@nabla/vite-plugin-eslint": "^1.6.0",
"@tailwindcss/forms": "^0.5.7",
"@types/bcryptjs": "^2.4.6",
"@types/big.js": "^6.2.2",
"@types/node": "^20.9.4",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"@vitejs/plugin-react": "^4.2.0",
"autoprefixer": "^10.4.16",
"@types/node": "^20.11.16",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react-swc": "^3.6.0",
"autoprefixer": "^10.4.17",
"cross-env": "^7.0.3",
"cypress": "^12.17.4",
"cypress-file-upload": "^5.0.8",
"eslint": "^8.54.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"istanbul-lib-coverage": "^3.2.2",
"lint-staged": ">=13.2.2",
"nyc": "^15.1.0",
"postcss": "^8.4.31",
"postcss": "^8.4.34",
"postcss-import": "^15.1.0",
"prettier": "^3.1.0",
"prettier-plugin-tailwindcss": "^0.5.7",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.11",
"source-map-support": "^0.5.21",
"tailwindcss": "^3.3.5",
"ts-node": "^10.9.1",
"typescript": "^5.3.2",
"vite": "^4.5.2",
"tailwindcss": "^3.4.1",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-istanbul": "^5.0.0",
"vite-tsconfig-paths": "^4.2.1",
"vitest": "^0.34.6"
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
},
"browserslist": [
"last 2 Chrome versions"
Expand Down
23 changes: 9 additions & 14 deletions src/lib/formatBalance.test.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
// Copyright 2022 @paritytech/contracts-ui authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import { ApiPromise } from '@polkadot/api';
import { TypeRegistry } from '@polkadot/types';
import { beforeAll, describe, expect, it } from 'vitest';
import { formatBalance } from './formatBalance';

describe('formatBalance', () => {
let api: ApiPromise;
let registry: TypeRegistry;

beforeAll(async () => {
api = await ApiPromise.create({
types: {
Balance: 'u128',
},
});
beforeAll(() => {
registry = new TypeRegistry();
});

it('should throw on invalid options', () => {
expect(() =>
formatBalance(api.createType('Balance', 1), { decimals: -1, fractionDigits: 0 }),
formatBalance(registry.createType('Balance', 1), { decimals: -1, fractionDigits: 0 }),
).toThrow();

expect(() =>
formatBalance(api.createType('Balance', 1), { decimals: 0, fractionDigits: -1 }),
formatBalance(registry.createType('Balance', 1), { decimals: 0, fractionDigits: -1 }),
).toThrow();

expect(() =>
formatBalance(api.createType('Balance', 1), { decimals: 0, fractionDigits: 1 }),
formatBalance(registry.createType('Balance', 1), { decimals: 0, fractionDigits: 1 }),
).toThrow();
});

Expand All @@ -40,7 +35,7 @@ describe('formatBalance', () => {
expected: '340,282,366,920,938,463,463,374,607.43',
},
].forEach(({ value, expected }) => {
const balance = api.createType('Balance', value);
const balance = registry.createType('Balance', value);
expect(formatBalance(balance)).toBe(expected);
});
});
Expand Down Expand Up @@ -71,7 +66,7 @@ describe('formatBalance', () => {
];

cases.forEach(({ value, expected, options }) => {
const balance = api.createType('Balance', value);
const balance = registry.createType('Balance', value);
expect(formatBalance(balance, options)).toBe(expected);
});
});
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "Node",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down
6 changes: 2 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// Copyright 2022 @paritytech/contracts-ui authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import react from '@vitejs/plugin-react-swc';
import tsConfigPaths from 'vite-tsconfig-paths';
import eslintPlugin from '@nabla/vite-plugin-eslint';
import istanbul from 'vite-plugin-istanbul';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
tsConfigPaths(),
eslintPlugin(),
istanbul({
include: 'src/*',
exclude: ['node_modules', 'cypress/'],
Expand Down
Loading

0 comments on commit 4607273

Please sign in to comment.