@@ -20,7 +20,7 @@ import {
20
20
} from '@tanstack/react-query' ;
21
21
import { act , renderHook , waitFor } from '@testing-library/react' ;
22
22
import React from 'react' ;
23
- import { beforeEach , describe , expect , it , vi } from 'vitest' ;
23
+ import { describe , expect , it , vi } from 'vitest' ;
24
24
import { qraftAPIClient , requestFn } from '../index.js' ;
25
25
import { createPredefinedParametersRequestFn } from './fixtures/api/create-predefined-parameters-request-fn.js' ;
26
26
import {
@@ -1880,8 +1880,8 @@ describe('Qraft uses "fetchQuery(...) & "prefetchQuery(...)" & "ensureQueryData(
1880
1880
1881
1881
it ( 'throws an error if requestFn is not provided' , async ( ) => {
1882
1882
const qraft = createAPIClient ( {
1883
+ // @ts -expect-error - incorrect usage case, `requestFn` is not defined
1883
1884
queryClient : new QueryClient ( ) ,
1884
- // @ts -expect-error - incorrect usage case
1885
1885
requestFn : undefined ,
1886
1886
baseUrl : 'http://any' ,
1887
1887
} ) ;
@@ -4533,43 +4533,43 @@ describe('Qraft is type-safe if client created with "QueryClient" only', () => {
4533
4533
} ) ;
4534
4534
4535
4535
describe ( 'Qraft API Client primitive conversions' , ( ) => {
4536
- let qraft : ReturnType < typeof createAPIClient > ;
4537
-
4538
- beforeEach ( ( ) => {
4539
- qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4540
- } ) ;
4541
-
4542
4536
describe ( 'Root level conversions' , ( ) => {
4543
4537
it ( 'should handle string conversion' , ( ) => {
4538
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4544
4539
expect ( String ( qraft ) ) . toBe ( qraft . toString ( ) ) ;
4545
4540
expect ( `${ qraft } ` ) . toBe ( qraft . toString ( ) ) ;
4546
4541
} ) ;
4547
4542
4548
4543
it ( 'should handle number conversion' , ( ) => {
4544
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4549
4545
expect ( Number ( qraft ) ) . toBeNaN ( ) ;
4550
4546
expect ( + qraft ) . toBeNaN ( ) ;
4551
4547
} ) ;
4552
4548
4553
4549
it ( 'should handle JSON serialization' , ( ) => {
4550
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4554
4551
expect ( JSON . stringify ( qraft ) ) . toBe (
4555
4552
JSON . stringify ( JSON . stringify ( services ) )
4556
4553
) ;
4557
4554
} ) ;
4558
4555
4559
4556
it ( 'toJSON() returns JSON string' , ( ) => {
4557
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4560
4558
expect (
4561
4559
// @ts -expect-error - toJSON() is not a standard method for Qraft API Client
4562
4560
qraft . toJSON ( )
4563
4561
) . toBe ( JSON . stringify ( services ) ) ;
4564
4562
} ) ;
4565
4563
4566
4564
it ( 'should handle valueOf()' , ( ) => {
4565
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4567
4566
const value = qraft . valueOf ( ) ;
4568
4567
expect ( typeof value ) . toBe ( 'object' ) ;
4569
4568
expect ( value ) . toBe ( services ) ;
4570
4569
} ) ;
4571
4570
4572
4571
it ( 'should handle Symbol.toStringTag' , ( ) => {
4572
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4573
4573
expect ( Object . prototype . toString . call ( qraft ) ) . toBe (
4574
4574
'[object QraftAPIClient]'
4575
4575
) ;
@@ -4578,6 +4578,7 @@ describe('Qraft API Client primitive conversions', () => {
4578
4578
4579
4579
describe ( 'Service level conversions' , ( ) => {
4580
4580
it ( 'should handle string conversion' , ( ) => {
4581
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4581
4582
expect ( String ( qraft . approvalPolicies ) ) . toBe (
4582
4583
qraft . approvalPolicies . toString ( )
4583
4584
) ;
@@ -4587,23 +4588,27 @@ describe('Qraft API Client primitive conversions', () => {
4587
4588
} ) ;
4588
4589
4589
4590
it ( 'should handle number conversion' , ( ) => {
4591
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4590
4592
expect ( Number ( qraft . approvalPolicies ) ) . toBeNaN ( ) ;
4591
4593
expect ( + qraft . approvalPolicies ) . toBeNaN ( ) ;
4592
4594
} ) ;
4593
4595
4594
4596
it ( 'should handle JSON serialization' , ( ) => {
4597
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4595
4598
expect ( JSON . stringify ( qraft . approvalPolicies ) ) . toBe (
4596
4599
JSON . stringify ( JSON . stringify ( services . approvalPolicies ) )
4597
4600
) ;
4598
4601
} ) ;
4599
4602
4600
4603
it ( 'should handle valueOf()' , ( ) => {
4604
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4601
4605
const value = qraft . approvalPolicies . valueOf ( ) ;
4602
4606
expect ( typeof value ) . toBe ( 'object' ) ;
4603
4607
expect ( value ) . toBe ( qraft . approvalPolicies . valueOf ( ) ) ;
4604
4608
} ) ;
4605
4609
4606
4610
it ( 'should handle Symbol.toStringTag' , ( ) => {
4611
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4607
4612
expect ( Object . prototype . toString . call ( qraft . approvalPolicies ) ) . toBe (
4608
4613
'[object QraftAPIClient]'
4609
4614
) ;
@@ -4612,16 +4617,19 @@ describe('Qraft API Client primitive conversions', () => {
4612
4617
4613
4618
describe ( 'Operation level conversions' , ( ) => {
4614
4619
it ( 'should handle string conversion' , ( ) => {
4620
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4615
4621
expect ( String ( qraft . approvalPolicies . getApprovalPoliciesId ) ) . toBe (
4616
4622
qraft . approvalPolicies . getApprovalPoliciesId . toString ( )
4617
4623
) ;
4618
4624
} ) ;
4619
4625
4620
4626
it ( 'should handle number conversion' , ( ) => {
4627
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4621
4628
expect ( Number ( qraft . approvalPolicies . getApprovalPoliciesId ) ) . toBeNaN ( ) ;
4622
4629
} ) ;
4623
4630
4624
4631
it ( 'should handle JSON serialization' , ( ) => {
4632
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4625
4633
expect ( JSON . stringify ( qraft . approvalPolicies . getApprovalPoliciesId ) ) . toBe (
4626
4634
JSON . stringify (
4627
4635
JSON . stringify ( services . approvalPolicies . getApprovalPoliciesId )
@@ -4630,11 +4638,13 @@ describe('Qraft API Client primitive conversions', () => {
4630
4638
} ) ;
4631
4639
4632
4640
it ( 'should handle valueOf()' , ( ) => {
4641
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4633
4642
const value = qraft . approvalPolicies . getApprovalPoliciesId . valueOf ( ) ;
4634
4643
expect ( typeof value ) . toBe ( 'object' ) ;
4635
4644
} ) ;
4636
4645
4637
4646
it ( 'should handle Symbol.toStringTag' , ( ) => {
4647
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4638
4648
expect (
4639
4649
Object . prototype . toString . call (
4640
4650
qraft . approvalPolicies . getApprovalPoliciesId
@@ -4645,22 +4655,19 @@ describe('Qraft API Client primitive conversions', () => {
4645
4655
} ) ;
4646
4656
4647
4657
describe ( 'Qraft API Client console logging' , ( ) => {
4648
- let qraft : ReturnType < typeof createAPIClient > ;
4649
-
4650
- beforeEach ( ( ) => {
4651
- qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4652
- } ) ;
4653
-
4654
4658
describe ( 'Individual elements logging' , ( ) => {
4655
4659
it ( 'should log root client without errors' , ( ) => {
4660
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4656
4661
expect ( ( ) => console . log ( qraft ) ) . not . toThrow ( ) ;
4657
4662
} ) ;
4658
4663
4659
4664
it ( 'should log service without errors' , ( ) => {
4665
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4660
4666
expect ( ( ) => console . log ( qraft . approvalPolicies ) ) . not . toThrow ( ) ;
4661
4667
} ) ;
4662
4668
4663
4669
it ( 'should log operation without errors' , ( ) => {
4670
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4664
4671
expect ( ( ) =>
4665
4672
console . log ( qraft . approvalPolicies . getApprovalPoliciesId )
4666
4673
) . not . toThrow ( ) ;
@@ -4669,6 +4676,7 @@ describe('Qraft API Client console logging', () => {
4669
4676
4670
4677
describe ( 'Multiple levels mixed logging' , ( ) => {
4671
4678
it ( 'should log multiple client elements without errors' , ( ) => {
4679
+ const qraft = createAPIClient ( { queryClient : new QueryClient ( ) } ) ;
4672
4680
const consoleSpy = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
4673
4681
4674
4682
try {
0 commit comments