mirror of
https://github.com/pezkuwichain/pezkuwi-dev.git
synced 2026-10-23 20:26:16 +00:00
Initial rebrand: @polkadot -> @pezkuwi (3 packages)
- Package namespace: @polkadot/dev -> @pezkuwi/dev - Repository: polkadot-js/dev -> pezkuwichain/pezkuwi-dev - Author: Pezkuwi Team <team@pezkuwichain.io> Packages: - @pezkuwi/dev (build tools, linting, CI scripts) - @pezkuwi/dev-test (test runner) - @pezkuwi/dev-ts (TypeScript build) Upstream: polkadot-js/dev v0.83.3
This commit is contained in:
commit
8d28b36f9c
135 files changed
+19232
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export class Clazz {
|
||||
#something = 123_456_789;
|
||||
|
||||
readonly and: number;
|
||||
|
||||
static staticProperty = 'foobar';
|
||||
static staticFunction = (): string|null => Clazz.staticProperty;
|
||||
|
||||
/**
|
||||
* @param and the number we should and with
|
||||
*/
|
||||
constructor (and: number) {
|
||||
this.and = and;
|
||||
this.#something = this.#something & and;
|
||||
}
|
||||
|
||||
get something (): number {
|
||||
return this.#something;
|
||||
}
|
||||
|
||||
async doAsync (): Promise<boolean> {
|
||||
const res = await new Promise<boolean>((resolve) => resolve(true));
|
||||
|
||||
console.log(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sets something to something
|
||||
* @param something The addition
|
||||
*/
|
||||
setSomething = (something?: number): number => {
|
||||
this.#something = (something ?? 123_456) & this.and;
|
||||
|
||||
return this.#something;
|
||||
};
|
||||
|
||||
toString (): string {
|
||||
return `something=${this.#something}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
||||
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import React from 'react';
|
||||
|
||||
import Jsx from './Jsx.js';
|
||||
|
||||
describe('react testing', () => {
|
||||
it('shows the children when the checkbox is checked', () => {
|
||||
const testMessage = 'Test Message';
|
||||
|
||||
render(<Jsx>{testMessage}</Jsx>);
|
||||
|
||||
assert.equal(screen.queryByText(testMessage), null);
|
||||
|
||||
fireEvent.click(screen.getByLabelText(/show/i));
|
||||
|
||||
assert.notEqual(screen.getByText(testMessage), null);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Adapted from https://github.com/testing-library/react-testing-library#basic-example
|
||||
|
||||
import type { Props } from './JsxChild.js';
|
||||
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { styled } from 'styled-components';
|
||||
|
||||
import Child from './JsxChild.js';
|
||||
|
||||
function Hidden ({ children, className }: Props): React.ReactElement<Props> {
|
||||
const [isMessageVisible, setMessageVisibility] = useState(false);
|
||||
|
||||
const onShow = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) =>
|
||||
setMessageVisibility(e.target.checked),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<StyledDiv className={className}>
|
||||
<label htmlFor='toggle'>Show Message</label>
|
||||
<input
|
||||
checked={isMessageVisible}
|
||||
id='toggle'
|
||||
onChange={onShow}
|
||||
type='checkbox'
|
||||
/>
|
||||
{isMessageVisible && (
|
||||
<>
|
||||
{children}
|
||||
<Child label='hello' />
|
||||
</>
|
||||
)}
|
||||
</StyledDiv>
|
||||
);
|
||||
}
|
||||
|
||||
const StyledDiv = styled.div`
|
||||
background: red;
|
||||
`;
|
||||
|
||||
export default React.memo(Hidden);
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
|
||||
export interface Props {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
function Child ({ children, className, label }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className}>
|
||||
{label || ''}{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Child);
|
||||
@@ -0,0 +1,13 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
/** This tests augmentation outputs, e.g. as used in the polkadot-js/api */
|
||||
|
||||
export interface Something {
|
||||
bar: string;
|
||||
foo: string;
|
||||
}
|
||||
|
||||
declare module '@polkadot/dev/types' {
|
||||
const blah: string;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/**
|
||||
* Returns the sum of 2 numbers
|
||||
*
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @returns {number}
|
||||
*/
|
||||
export function sum (a, b) {
|
||||
return a + b;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/** This should appear as-is in the output with: 1. extension added, 2. augmented.d.ts correct */
|
||||
import './augmented.js';
|
||||
|
||||
/** This import should appear as-in in the ouput (cjs without asserts) */
|
||||
import testJson from '@pezkuwi/dev/rootJs/testJson.json' assert { type: 'json' };
|
||||
|
||||
/** Double double work, i.e. re-exports */
|
||||
export { Clazz } from './Clazz.js';
|
||||
|
||||
/** Function to ensure that BigInt does not have the Babel Math.pow() transform */
|
||||
export function bigIntExp (): bigint {
|
||||
// 123_456n * 137_858_491_849n
|
||||
return 123_456_789n * (13n ** 10n);
|
||||
}
|
||||
|
||||
/** Function to ensure that dynamic imports work */
|
||||
export async function dynamic (a: number, b: number): Promise<number> {
|
||||
// NOTE we go via this path so it points to the same location in both ESM
|
||||
// and CJS output (a './dynamic' import would be different otherwise)
|
||||
const { sum } = await import('@polkadot/dev/rootJs/dynamic.mjs');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return sum(a, b);
|
||||
}
|
||||
|
||||
/** Function to ensure we have json correctly imported */
|
||||
export function json (): string {
|
||||
return testJson.test.json;
|
||||
}
|
||||
|
||||
/** Check support for the ?? operator */
|
||||
export function jsOpExp (a?: number): number {
|
||||
const defaults = {
|
||||
a: 42,
|
||||
b: 43,
|
||||
c: 44
|
||||
};
|
||||
|
||||
return a ?? defaults.a;
|
||||
}
|
||||
|
||||
/** This is an actual check to ensure PURE is all-happy */
|
||||
export const pureOpExp = /*#__PURE__*/ jsOpExp();
|
||||
|
||||
const fooA = 1;
|
||||
const fooB = 2;
|
||||
const fooC = 3;
|
||||
const fooD = 4;
|
||||
|
||||
export { fooA, fooB, fooC, fooD };
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2025 @polkadot/dev authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/** This file should not be in the compiled output */
|
||||
|
||||
declare module './testJson.json' {
|
||||
declare let contents: { test: { json: 'works' } };
|
||||
export default contents;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"test": {
|
||||
"json": "works"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user