type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
(): void => { // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach((): void => {}); test('should return an empty array when handle is undefined', async (): Promise<void> => { // Given const handle: ElementHandle<Element> | undefined = undefined; // When const result = await SUT.getAllOptionsOfHandle(handle, 'foobar'); // Then expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(0); }); test('should return an empty array when handle is null', async (): Promise<void> => { // Given const handle: ElementHandle<Element> | null = null; // When const result = await SUT.getAllOptionsOfHandle(handle, 'foobar'); // Then expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(0); }); }
hdorgeval/playwright-controller
src/actions/handle-actions/get-all-options-of-handle/tests/get-all-options-of-handle.common.test.ts
TypeScript
ArrowFunction
async (): Promise<void> => { // Given const handle: ElementHandle<Element> | undefined = undefined; // When const result = await SUT.getAllOptionsOfHandle(handle, 'foobar'); // Then expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(0); }
hdorgeval/playwright-controller
src/actions/handle-actions/get-all-options-of-handle/tests/get-all-options-of-handle.common.test.ts
TypeScript
ArrowFunction
async (): Promise<void> => { // Given const handle: ElementHandle<Element> | null = null; // When const result = await SUT.getAllOptionsOfHandle(handle, 'foobar'); // Then expect(Array.isArray(result)).toBe(true); expect(result.length).toBe(0); }
hdorgeval/playwright-controller
src/actions/handle-actions/get-all-options-of-handle/tests/get-all-options-of-handle.common.test.ts
TypeScript
ClassDeclaration
export class User { name: string email: string; }
Mihai-Ionut-Aurel/scala-play-angular-authentication
ui/src/app/authentification/_models/user.ts
TypeScript
ArrowFunction
() => uuidv4()
Simon2828/learning-objectives-backend
src/utils/index.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { stop } = createCompositeEffect(stoppable(counter, x => captured.push(x))); setTimeout(() => { setCounter(1); assert.is(captured[1], 1, "change before stop"); stop(); setCounter(2); assert.is(captured[2], undefined, "change after stop"); dispose(); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { stop } = createCompositeEffect(stoppable(counter, x => captured.push(x))); setTimeout(() => { setCounter(1); assert.is(captured[1], 1, "change before stop"); stop(); setCounter(2); assert.is(captured[2], undefined, "change after stop"); dispose(); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
x => captured.push(x)
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { setCounter(1); assert.is(captured[1], 1, "change before stop"); stop(); setCounter(2); assert.is(captured[2], undefined, "change after stop"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect( once(counter, x => captured.push(x)), { defer: true } ); setTimeout(() => { setCounter(1); assert.is(captured[0], 1, "first change should be captured"); setCounter(2); assert.is(captured[1], undefined, "next change shouldn't be captured"); dispose(); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect( once(counter, x => captured.push(x)), { defer: true } ); setTimeout(() => { setCounter(1); assert.is(captured[0], 1, "first change should be captured"); setCounter(2); assert.is(captured[1], undefined, "next change shouldn't be captured"); dispose(); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { setCounter(1); assert.is(captured[0], 1, "first change should be captured"); setCounter(2); assert.is(captured[1], undefined, "next change shouldn't be captured"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { count } = createCompositeEffect(atMost(counter, x => captured.push(x), { limit: 2 })); assert.is(count(), 0, "initial count should be 0"); setTimeout(() => { assert.is(count(), 1, "count after initial effect should be 1"); assert.equal(captured, [0], "initial state should be captured"); setCounter(1); assert.is(count(), 2, "count after first change should be 2"); assert.equal(captured, [0, 1], "first change should be captured"); setCounter(2); assert.is(count(), 2, "count next change should still be 2"); assert.equal(captured, [0, 1], "next change shouldn't be captured"); dispose(); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { count } = createCompositeEffect(atMost(counter, x => captured.push(x), { limit: 2 })); assert.is(count(), 0, "initial count should be 0"); setTimeout(() => { assert.is(count(), 1, "count after initial effect should be 1"); assert.equal(captured, [0], "initial state should be captured"); setCounter(1); assert.is(count(), 2, "count after first change should be 2"); assert.equal(captured, [0, 1], "first change should be captured"); setCounter(2); assert.is(count(), 2, "count next change should still be 2"); assert.equal(captured, [0, 1], "next change shouldn't be captured"); dispose(); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.is(count(), 1, "count after initial effect should be 1"); assert.equal(captured, [0], "initial state should be captured"); setCounter(1); assert.is(count(), 2, "count after first change should be 2"); assert.equal(captured, [0, 1], "first change should be captured"); setCounter(2); assert.is(count(), 2, "count next change should still be 2"); assert.equal(captured, [0, 1], "next change shouldn't be captured"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect(debounce(counter, x => captured.push(x), 10)); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured immediately"); setCounter(1); assert.equal(captured, [], "first change should not be captured immediately"); }, 0); setTimeout(() => { assert.equal(captured, [1], "after delay, only the last change should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal(captured, [1, 9], "after delay, only the next last change should be captured"); dispose(); }, 15); }, 15); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect(debounce(counter, x => captured.push(x), 10)); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured immediately"); setCounter(1); assert.equal(captured, [], "first change should not be captured immediately"); }, 0); setTimeout(() => { assert.equal(captured, [1], "after delay, only the last change should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal(captured, [1, 9], "after delay, only the next last change should be captured"); dispose(); }, 15); }, 15); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [], "initial state should not be captured immediately"); setCounter(1); assert.equal(captured, [], "first change should not be captured immediately"); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [1], "after delay, only the last change should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal(captured, [1, 9], "after delay, only the next last change should be captured"); dispose(); }, 15); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [1, 9], "after delay, only the next last change should be captured"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect(throttle(counter, x => captured.push(x), 10)); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured immediately"); setCounter(1); assert.equal(captured, [], "first change should not be captured immediately"); }, 0); setTimeout(() => { assert.equal(captured, [0], "after delay, only the initial state should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal( captured, [0, 7], "after delay, only the next first change should be captured" ); dispose(); }, 15); }, 15); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; createCompositeEffect(throttle(counter, x => captured.push(x), 10)); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured immediately"); setCounter(1); assert.equal(captured, [], "first change should not be captured immediately"); }, 0); setTimeout(() => { assert.equal(captured, [0], "after delay, only the initial state should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal( captured, [0, 7], "after delay, only the next first change should be captured" ); dispose(); }, 15); }, 15); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [0], "after delay, only the initial state should be captured"); setCounter(7); setCounter(9); setTimeout(() => { assert.equal( captured, [0, 7], "after delay, only the next first change should be captured" ); dispose(); }, 15); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal( captured, [0, 7], "after delay, only the next first change should be captured" ); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured1: number[] = []; const captured2: number[] = []; createCompositeEffect( whenever( () => counter() % 2 === 0, () => captured1.push(counter()) ) ); createCompositeEffect( whenever( createMemo(() => counter() >= 3), () => captured2.push(counter()) ) ); setTimeout(() => { assert.equal(captured1, [0], "initial state should be captured for 1"); assert.equal(captured2, [], "initial state should not be captured for 2"); setCounter(1); assert.equal(captured1, [0], "first change should not be captured for 1"); assert.equal(captured2, [], "first change should not be captured for 2"); setCounter(2); assert.equal(captured1, [0, 2], "2 should be added for 1"); assert.equal(captured2, [], "2 should not be added for 2"); setCounter(3); assert.equal(captured1, [0, 2], "3 should not be added for 1"); assert.equal(captured2, [3], "3 should be added for 2"); setCounter(4); assert.equal(captured1, [0, 2, 4], "4 should be added for 1"); assert.equal(captured2, [3], "4 should not be added for 2"); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured1: number[] = []; const captured2: number[] = []; createCompositeEffect( whenever( () => counter() % 2 === 0, () => captured1.push(counter()) ) ); createCompositeEffect( whenever( createMemo(() => counter() >= 3), () => captured2.push(counter()) ) ); setTimeout(() => { assert.equal(captured1, [0], "initial state should be captured for 1"); assert.equal(captured2, [], "initial state should not be captured for 2"); setCounter(1); assert.equal(captured1, [0], "first change should not be captured for 1"); assert.equal(captured2, [], "first change should not be captured for 2"); setCounter(2); assert.equal(captured1, [0, 2], "2 should be added for 1"); assert.equal(captured2, [], "2 should not be added for 2"); setCounter(3); assert.equal(captured1, [0, 2], "3 should not be added for 1"); assert.equal(captured2, [3], "3 should be added for 2"); setCounter(4); assert.equal(captured1, [0, 2, 4], "4 should be added for 1"); assert.equal(captured2, [3], "4 should not be added for 2"); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => counter() % 2 === 0
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => captured1.push(counter())
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => counter() >= 3
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => captured2.push(counter())
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured1, [0], "initial state should be captured for 1"); assert.equal(captured2, [], "initial state should not be captured for 2"); setCounter(1); assert.equal(captured1, [0], "first change should not be captured for 1"); assert.equal(captured2, [], "first change should not be captured for 2"); setCounter(2); assert.equal(captured1, [0, 2], "2 should be added for 1"); assert.equal(captured2, [], "2 should not be added for 2"); setCounter(3); assert.equal(captured1, [0, 2], "3 should not be added for 1"); assert.equal(captured2, [3], "3 should be added for 2"); setCounter(4); assert.equal(captured1, [0, 2, 4], "4 should be added for 1"); assert.equal(captured2, [3], "4 should not be added for 2"); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { pause, resume, toggle } = createCompositeEffect( pausable(counter, () => captured.push(counter()), { active: false }) ); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured"); setCounter(1); assert.equal(captured, [], "first change should not be captured"); resume(); setCounter(2); assert.equal(captured, [2], "after resume() change should be captured"); pause(); setCounter(3); assert.equal(captured, [2], "after pause() change should not be captured"); toggle(); setCounter(4); assert.equal(captured, [2, 4], "after toggle() change should be captured"); toggle(true); setCounter(5); assert.equal(captured, [2, 4, 5], "after toggle(true) change should be captured"); toggle(false); setCounter(6); assert.equal(captured, [2, 4, 5], "after toggle(false) change should not be captured"); dispose(); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { pause, resume, toggle } = createCompositeEffect( pausable(counter, () => captured.push(counter()), { active: false }) ); setTimeout(() => { assert.equal(captured, [], "initial state should not be captured"); setCounter(1); assert.equal(captured, [], "first change should not be captured"); resume(); setCounter(2); assert.equal(captured, [2], "after resume() change should be captured"); pause(); setCounter(3); assert.equal(captured, [2], "after pause() change should not be captured"); toggle(); setCounter(4); assert.equal(captured, [2, 4], "after toggle() change should be captured"); toggle(true); setCounter(5); assert.equal(captured, [2, 4, 5], "after toggle(true) change should be captured"); toggle(false); setCounter(6); assert.equal(captured, [2, 4, 5], "after toggle(false) change should not be captured"); dispose(); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => captured.push(counter())
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [], "initial state should not be captured"); setCounter(1); assert.equal(captured, [], "first change should not be captured"); resume(); setCounter(2); assert.equal(captured, [2], "after resume() change should be captured"); pause(); setCounter(3); assert.equal(captured, [2], "after pause() change should not be captured"); toggle(); setCounter(4); assert.equal(captured, [2, 4], "after toggle() change should be captured"); toggle(true); setCounter(5); assert.equal(captured, [2, 4, 5], "after toggle(true) change should be captured"); toggle(false); setCounter(6); assert.equal(captured, [2, 4, 5], "after toggle(false) change should not be captured"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { createRoot(dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { ignoreNext, ignore } = createCompositeEffect( ignorable(counter, x => { captured.push(x); // next effect will be ignored: ignoreNext(); setCounter(p => p + 1); // this change happens in the same effect, so it will also be ignored setCounter(5); }) ); setTimeout(() => { assert.equal(captured, [0], "initial state should be captured"); assert.is(counter(), 5, "although it wasn't captured, the counter should be 5"); ignore(() => { // both changes will be ignored: setCounter(420); setCounter(69); }); assert.equal(captured, [0], "changes in ignore() should not be captured"); assert.equal(counter(), 69, "changes in ignore() were executed applied"); // but not this one: setCounter(p => 111); assert.equal(captured, [0, 111], "changes after ignore() should be captured"); dispose(); }, 0); }); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
dispose => { const [counter, setCounter] = createSignal(0); const captured: number[] = []; const { ignoreNext, ignore } = createCompositeEffect( ignorable(counter, x => { captured.push(x); // next effect will be ignored: ignoreNext(); setCounter(p => p + 1); // this change happens in the same effect, so it will also be ignored setCounter(5); }) ); setTimeout(() => { assert.equal(captured, [0], "initial state should be captured"); assert.is(counter(), 5, "although it wasn't captured, the counter should be 5"); ignore(() => { // both changes will be ignored: setCounter(420); setCounter(69); }); assert.equal(captured, [0], "changes in ignore() should not be captured"); assert.equal(counter(), 69, "changes in ignore() were executed applied"); // but not this one: setCounter(p => 111); assert.equal(captured, [0, 111], "changes after ignore() should be captured"); dispose(); }, 0); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
x => { captured.push(x); // next effect will be ignored: ignoreNext(); setCounter(p => p + 1); // this change happens in the same effect, so it will also be ignored setCounter(5); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
p => p + 1
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { assert.equal(captured, [0], "initial state should be captured"); assert.is(counter(), 5, "although it wasn't captured, the counter should be 5"); ignore(() => { // both changes will be ignored: setCounter(420); setCounter(69); }); assert.equal(captured, [0], "changes in ignore() should not be captured"); assert.equal(counter(), 69, "changes in ignore() were executed applied"); // but not this one: setCounter(p => 111); assert.equal(captured, [0, 111], "changes after ignore() should be captured"); dispose(); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
() => { // both changes will be ignored: setCounter(420); setCounter(69); }
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
p => 111
KrofDrakula/solid-primitives
packages/composites/test/modifiers.test.ts
TypeScript
ArrowFunction
(a: TransactionDetails, b: TransactionDetails) => b.addedTime - a.addedTime
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
ArrowFunction
(sortedRecentTransaction: TransactionDetails) => { const { hash, receipt } = sortedRecentTransaction if (!hash) { return { icon: <Loader />, color: 'text' } } if (hash && receipt?.status === 1) { return { icon: <CheckmarkCircleIcon color="success" />, color: 'success' } } return { icon: <ErrorIcon color="failure" />, color: 'failure' } } const RecentTransactionsModal = ({ onDismiss = defaultOnDismiss, translateString }: RecentTransactionsModalProps) => { const TranslateString = translateString const { account, chainId } = useActiveWeb3React() const allTransactions = useAllTransactions() // Logic taken from Web3Status/index.tsx line 175 const sortedRecentTransactions = useMemo(() => { const txs = Object.values(allTransactions) return txs.filter(isTransactionRecent).sort(newTransactionsFirst) }, [allTransactions]) return ( <Modal title={TranslateString(1202, 'Recent transactions')} onDismiss={onDismiss}> {!account && ( <Flex justifyContent="center" flexDirection="column" alignItems="center"> <Text mb="8px" bold> Please connect your wallet to view your recent transactions </Text> <Button variant="tertiary" scale="sm" onClick={onDismiss}> Close </Button> </Flex>
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
ArrowFunction
({ onDismiss = defaultOnDismiss, translateString }: RecentTransactionsModalProps) => { const TranslateString = translateString const { account, chainId } = useActiveWeb3React() const allTransactions = useAllTransactions() // Logic taken from Web3Status/index.tsx line 175 const sortedRecentTransactions = useMemo(() => { const txs = Object.values(allTransactions) return txs.filter(isTransactionRecent).sort(newTransactionsFirst) }, [allTransactions]) return ( <Modal title={TranslateString(1202, 'Recent transactions')} onDismiss={onDismiss}> {!account && ( <Flex justifyContent="center" flexDirection="column" alignItems="center"> <Text mb="8px" bold> Please connect your wallet to view your recent transactions </Text> <Button variant="tertiary" scale="sm" onClick={onDismiss}> Close </Button> </Flex>
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
ArrowFunction
() => { const txs = Object.values(allTransactions) return txs.filter(isTransactionRecent).sort(newTransactionsFirst) }
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
ArrowFunction
(sortedRecentTransaction) => { const { hash, summary } = sortedRecentTransaction const { icon, color } = getRowStatus(sortedRecentTransaction) return ( <> <Flex key={hash} alignItems="center" justifyContent="space-between" mb="4px"> <LinkExternal href={getBscScanLink(chainId, hash, 'transaction')} color={color}> {summary ?? hash}
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
TypeAliasDeclaration
type RecentTransactionsModalProps = { onDismiss?: () => void translateString: (translationId: number, fallback: string) => (string) }
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
MethodDeclaration
TranslateString(1202, 'Recent transactions')
CryptoCoder50/BSC-Moonwalker-Swap
src/components/PageHeader/RecentTransactionsModal.tsx
TypeScript
ArrowFunction
() => { let component: AccountPickerComponent; let fixture: ComponentFixture<AccountPickerComponent>; let userServiceSpy; beforeEach(async(() => { const subFn = { subscribe: () => {} }; const getValueFn = { getValue: () => {} }; userServiceSpy = jasmine.createSpyObj('UserService', [ 'userAccounts', 'activeAccount', 'setActiveAccount', ]); userServiceSpy.activeAccount = jasmine.createSpyObj('activeAccount', subFn); userServiceSpy.userAccounts = jasmine.createSpyObj( 'userAccounts', getValueFn, ); TestBed.configureTestingModule({ declarations: [AccountPickerComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], providers: [{ provide: UserService, useValue: userServiceSpy }], imports: [TruncatePublicKeyPipeModule], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(AccountPickerComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); }
poliha/wallet.saza.io
src/app/components/account-picker/account-picker.component.spec.ts
TypeScript
ArrowFunction
() => { const subFn = { subscribe: () => {} }; const getValueFn = { getValue: () => {} }; userServiceSpy = jasmine.createSpyObj('UserService', [ 'userAccounts', 'activeAccount', 'setActiveAccount', ]); userServiceSpy.activeAccount = jasmine.createSpyObj('activeAccount', subFn); userServiceSpy.userAccounts = jasmine.createSpyObj( 'userAccounts', getValueFn, ); TestBed.configureTestingModule({ declarations: [AccountPickerComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], providers: [{ provide: UserService, useValue: userServiceSpy }], imports: [TruncatePublicKeyPipeModule], }).compileComponents(); }
poliha/wallet.saza.io
src/app/components/account-picker/account-picker.component.spec.ts
TypeScript
ArrowFunction
() => { fixture = TestBed.createComponent(AccountPickerComponent); component = fixture.componentInstance; fixture.detectChanges(); }
poliha/wallet.saza.io
src/app/components/account-picker/account-picker.component.spec.ts
TypeScript
InterfaceDeclaration
export interface CredentialStatus { id: string type: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * A JWT payload representation of a Credential * @see https://www.w3.org/TR/vc-data-model/#jwt-encoding */ export interface JwtCredentialPayload { iss?: string sub?: string vc: Extensible<{ '@context': string[] | string type: string[] | string credentialSubject: JwtCredentialSubject credentialStatus?: CredentialStatus // eslint-disable-next-line @typescript-eslint/no-explicit-any evidence?: any // eslint-disable-next-line @typescript-eslint/no-explicit-any termsOfUse?: any }> nbf?: number aud?: string | string[] exp?: number jti?: string // eslint-disable-next-line @typescript-eslint/no-explicit-any [x: string]: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * A JWT payload representation of a Presentation * @see https://www.w3.org/TR/vc-data-model/#jwt-encoding */ export interface JwtPresentationPayload { vp: Extensible<{ '@context': string[] | string type: string[] | string verifiableCredential?: VerifiableCredential[] | VerifiableCredential }> iss?: string aud?: string | string[] nbf?: number exp?: number jti?: string nonce?: string // eslint-disable-next-line @typescript-eslint/no-explicit-any [x: string]: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * used as input when creating Verifiable Credentials */ interface FixedCredentialPayload { '@context': string | string[] id?: string type: string | string[] issuer: IssuerType issuanceDate: DateType expirationDate?: DateType credentialSubject: Extensible<{ id?: string }> credentialStatus?: CredentialStatus // eslint-disable-next-line @typescript-eslint/no-explicit-any evidence?: any // eslint-disable-next-line @typescript-eslint/no-explicit-any termsOfUse?: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * This is meant to reflect unambiguous types for the properties in `CredentialPayload` */ interface NarrowCredentialDefinitions { '@context': string[] type: string[] issuer: Exclude<IssuerType, string> issuanceDate: string expirationDate?: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * used as input when creating Verifiable Presentations */ export interface FixedPresentationPayload { '@context': string | string[] type: string | string[] id?: string verifiableCredential?: VerifiableCredential[] holder: string verifier?: string | string[] issuanceDate?: string expirationDate?: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
interface NarrowPresentationDefinitions { '@context': string[] type: string[] verifier: string[] verifiableCredential?: Verifiable<W3CCredential>[] }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
export interface Proof { type?: string // eslint-disable-next-line @typescript-eslint/no-explicit-any [x: string]: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * Represents a tuple of a DID-URL with a `Signer` and associated algorithm. */ export interface Issuer { did: string // eslint-disable-next-line // @ts-ignore signer: Signer alg?: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * Represents the Creation Options that can be passed to the createVerifiableCredentialJwt method. */ export interface CreateCredentialOptions { /** * Determines whether the JSON->JWT transformation will remove the original fields from the input payload. * See https://www.w3.org/TR/vc-data-model/#jwt-encoding * * @default true */ removeOriginalFields?: boolean /** * Allows including or overriding some header parameters for the resulting JWT. * If the issuer or holder does not list an `alg`, then the one specified in `header` will be used */ // eslint-disable-next-line // @ts-ignore header?: Partial<JWTHeader> // eslint-disable-next-line @typescript-eslint/no-explicit-any [x: string]: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * Represents the Verification Options that can be passed to the verifyPresentation method. * The verification will fail if given options are NOT satisfied. */ export interface VerifyPresentationOptions extends VerifyCredentialOptions { domain?: string challenge?: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
InterfaceDeclaration
/** * Represents the Creation Options that can be passed to the createVerifiablePresentationJwt method. */ export interface CreatePresentationOptions extends CreateCredentialOptions { domain?: string challenge?: string }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
// eslint-disable-next-line @typescript-eslint/no-explicit-any export type JwtCredentialSubject = Record<string, any>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
export type IssuerType = Extensible<{ id: string }> | string
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
export type DateType = string | Date
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * A more flexible representation of a {@link W3CCredential} that can be used as input to methods * that expect it. */ export type CredentialPayload = Extensible<FixedCredentialPayload>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * Replaces the matching property types of T with the ones in U */ type Replace<T, U> = Omit<T, keyof U> & U
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
// eslint-disable-next-line @typescript-eslint/no-explicit-any type Extensible<T> = T & { [x: string]: any }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * This data type represents a parsed VerifiableCredential. * It is meant to be an unambiguous representation of the properties of a Credential and is usually the result of a transformation method. * * `issuer` is always an object with an `id` property and potentially other app specific issuer claims * `issuanceDate` is an ISO DateTime string * `expirationDate`, is a nullable ISO DateTime string * * Any JWT specific properties are transformed to the broader W3C variant and any app specific properties are left intact */ export type W3CCredential = Extensible<Replace<FixedCredentialPayload, NarrowCredentialDefinitions>>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * A more flexible representation of a {@link W3CPresentation} that can be used as input to methods * that expect it. */ export type PresentationPayload = Extensible<FixedPresentationPayload>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * This data type represents a parsed Presentation payload. * It is meant to be an unambiguous representation of the properties of a Presentation and is usually the result of a transformation method. * * The `verifiableCredential` array should contain parsed `Verifiable<Credential>` elements. * Any JWT specific properties are transformed to the broader W3C variant and any other app specific properties are left intact. */ export type W3CPresentation = Extensible<Replace<FixedPresentationPayload, NarrowPresentationDefinitions>>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * Represents a readonly representation of a verifiable object, including the {@link Proof} * property that can be used to verify it. */ export type Verifiable<T> = Readonly<T> & { readonly proof: Proof }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
export type JWT = string
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * A union type for both possible representations of a Credential (JWT and W3C standard) * * @see https://www.w3.org/TR/vc-data-model/#proof-formats */ export type VerifiableCredential = JWT | Verifiable<W3CCredential>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * A union type for both possible representations of a Presentation (JWT and W3C standard) * * @see https://www.w3.org/TR/vc-data-model/#proof-formats */ export type VerifiablePresentation = JWT | Verifiable<W3CPresentation>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
// eslint-disable-next-line // @ts-ignore export type VerifiedJWT = JWTVerified
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * Represents the result of a Presentation verification. * It includes the properties produced by `did-jwt` and a W3C compliant representation of * the Presentation that was just verified. * * This is usually the result of a verification method and not meant to be created by generic code. */ export type VerifiedPresentation = VerifiedJWT & { verifiablePresentation: Verifiable<W3CPresentation> }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * Represents the result of a Credential verification. * It includes the properties produced by `did-jwt` and a W3C compliant representation of * the Credential that was just verified. * * This is usually the result of a verification method and not meant to be created by generic code. */ export type VerifiedCredential = VerifiedJWT & { verifiableCredential: Verifiable<W3CCredential> }
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
TypeAliasDeclaration
/** * Represents the Verification Options that can be passed to the verifyCredential method. * These options are forwarded to the lower level verification code */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export type VerifyCredentialOptions = Record<string, any>
Electronic-Signatures-Industries/did-jwt-vc
src/types.ts
TypeScript
ArrowFunction
(): { activeAddress: string; setActiveAddress: (address: string) => void } => { const [activeAddress, setActiveAddress] = useState<string>(); const web3 = useWeb3(); useEffect(() => web3.onAccountsChanged((accounts) => setActiveAddress(accounts[0])), []); return { activeAddress, setActiveAddress }; }
bperekitko/liquidator
src/ethereum/web3/useActiveAddress.tsx
TypeScript
ArrowFunction
() => web3.onAccountsChanged((accounts) => setActiveAddress(accounts[0]))
bperekitko/liquidator
src/ethereum/web3/useActiveAddress.tsx
TypeScript
ArrowFunction
(accounts) => setActiveAddress(accounts[0])
bperekitko/liquidator
src/ethereum/web3/useActiveAddress.tsx
TypeScript
ArrowFunction
() => ({ getDevice: () => mockDevice })
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
() => mockDevice
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
(): SensorListProps => { const pins: Pins = { 50: { mode: 1, value: 500, }, 51: { mode: 0, value: 1, }, 52: { mode: 0, value: 1, }, 53: { mode: 0, value: 0, }, }; const fakeSensor1 = fakeSensor(); const fakeSensor2 = fakeSensor(); const fakeSensor3 = fakeSensor(); const fakeSensor4 = fakeSensor(); fakeSensor1.body.id = 1; fakeSensor1.body.pin = 51; fakeSensor1.body.mode = 0; fakeSensor1.body.label = "GPIO 51"; fakeSensor2.body.id = 2; fakeSensor2.body.pin = 50; fakeSensor2.body.mode = 1; fakeSensor2.body.label = "GPIO 50 - Moisture"; fakeSensor3.body.id = 3; fakeSensor3.body.pin = 52; fakeSensor3.body.mode = 0; fakeSensor3.body.label = "GPIO 52 - Tool Verification"; fakeSensor4.body.id = 4; fakeSensor4.body.pin = 53; fakeSensor4.body.mode = 0; fakeSensor4.body.label = "GPIO 53 - Tool Verification"; return { dispatch: jest.fn(), sensors: [fakeSensor2, fakeSensor1, fakeSensor3, fakeSensor4], pins, disabled: false }; }
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
(pin_number: number, pin_mode: 0 | 1) => ({ pin_number, label: `pin${pin_number}`, pin_mode })
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
() => { const wrapper = mount(<SensorList {...fakeProps()} />); const readSensorBtn = wrapper.find("button"); readSensorBtn.at(0).simulate("click"); expect(mockDevice.readPin).toHaveBeenCalledWith(expectedPayload(51, 0)); readSensorBtn.at(1).simulate("click"); expect(mockDevice.readPin).toHaveBeenLastCalledWith(expectedPayload(50, 1)); expect(mockDevice.readPin).toHaveBeenCalledTimes(2); }
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
() => { const p = fakeProps(); p.disabled = true; const wrapper = mount(<SensorList {...p} />); const readSensorBtn = wrapper.find("button"); readSensorBtn.first().simulate("click"); readSensorBtn.last().simulate("click"); expect(mockDevice.readPin).not.toHaveBeenCalled(); }
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ArrowFunction
() => { const p = fakeProps(); p.pins[50] && (p.pins[50].value = 600); const wrapper = mount(<SensorList {...p} />); expect(wrapper.html()).toContain("margin-left: -3.5rem"); }
EarthEngineering/Facetop-Web-App
frontend/controls/sensors/__tests__/sensor_list_test.tsx
TypeScript
ClassDeclaration
@Component({ selector: 'app-home', templateUrl: './home.component.html', styleUrls: ['./home.component.scss'] }) export class HomeComponent implements OnInit { isLoading: boolean; constructor() {} ngOnInit() { this.isLoading = true; } }
jeanlucmoisan/webfront
src/app/home/home.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.isLoading = true; }
jeanlucmoisan/webfront
src/app/home/home.component.ts
TypeScript
FunctionDeclaration
export function isMockFunction(fn: any): fn is EnhancedSpy { return typeof fn === 'function' && '__isSpy' in fn && fn.__isSpy }
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
FunctionDeclaration
export function spyOn<T, K extends keyof T>( obj: T, method: K, accessType?: 'get' | 'set', ): T[K] extends (...args: infer TArgs) => infer TReturnValue ? JestMockCompat<TArgs, TReturnValue> : JestMockCompat { const dictionary = { get: 'getter', set: 'setter', } as const const objMethod = accessType ? { [dictionary[accessType]]: method } : method const stub = tinyspy.spyOn(obj, objMethod as any) return enhanceSpy(stub) as any }
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
FunctionDeclaration
function enhanceSpy<TArgs extends any[], TReturns>( spy: SpyImpl<TArgs, TReturns>, ): JestMockCompat<TArgs, TReturns> { const stub = spy as unknown as EnhancedSpy<TArgs, TReturns> let implementation: ((...args: TArgs) => TReturns) | undefined const instances: any[] = [] const mockContext = { get calls() { return stub.calls }, get instances() { return instances }, // not supported get invocationCallOrder() { return [] }, get results() { return stub.results.map(([callType, value]) => { const type = callType === 'error' ? 'throw' : 'return' return { type, value } }) }, } let onceImplementations: ((...args: TArgs) => TReturns)[] = [] let name: string = (stub as any).name stub.getMockName = () => name || 'vi.fn()' stub.mockName = (n) => { name = n return stub } stub.mockClear = () => { stub.reset() return stub } stub.mockReset = () => { stub.reset() implementation = () => undefined as unknown as TReturns onceImplementations = [] return stub } stub.mockRestore = () => { stub.mockReset() implementation = undefined return stub } stub.getMockImplementation = () => implementation stub.mockImplementation = (fn: (...args: TArgs) => TReturns) => { implementation = fn return stub } stub.mockImplementationOnce = (fn: (...args: TArgs) => TReturns) => { onceImplementations.push(fn) return stub } stub.mockReturnThis = () => stub.mockImplementation(function(this: TReturns) { return this }) stub.mockReturnValue = (val: TReturns) => stub.mockImplementation(() => val) stub.mockReturnValueOnce = (val: TReturns) => stub.mockImplementationOnce(() => val) stub.mockResolvedValue = (val: Awaited<TReturns>) => stub.mockImplementation(() => Promise.resolve(val as TReturns)) stub.mockResolvedValueOnce = (val: Awaited<TReturns>) => stub.mockImplementationOnce(() => Promise.resolve(val as TReturns)) stub.mockRejectedValue = (val: unknown) => stub.mockImplementation(() => Promise.reject(val)) stub.mockRejectedValueOnce = (val: unknown) => stub.mockImplementationOnce(() => Promise.reject(val)) util.addProperty(stub, 'mock', () => mockContext) stub.willCall(function(this: unknown, ...args) { instances.push(this) const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {}) return impl.apply(this, args) }) spies.add(stub) return stub as any }
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
FunctionDeclaration
export function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TArgs, R>
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
FunctionDeclaration
export function fn<TArgs extends any[] = any[], R = any>( implementation: (...args: TArgs) => R ): JestMockCompatFn<TArgs, R>
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
FunctionDeclaration
export function fn<TArgs extends any[] = any[], R = any>( implementation?: (...args: TArgs) => R, ): JestMockCompatFn<TArgs, R> { return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {}) }, 'fn')) as unknown as JestMockCompatFn }
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript
ArrowFunction
([callType, value]) => { const type = callType === 'error' ? 'throw' : 'return' return { type, value } }
JoostK/vitest
packages/vitest/src/integrations/jest-mock.ts
TypeScript