@@ -6,34 +6,34 @@ import { describe, expect, it } from 'vitest';
6
6
import { getBodyString , getFetchRequestArgBody , serializeFormData } from '../src/networkUtils' ;
7
7
8
8
describe ( 'getBodyString' , ( ) => {
9
- it ( 'should work with a string' , ( ) => {
9
+ it ( 'works with a string' , ( ) => {
10
10
const actual = getBodyString ( 'abc' ) ;
11
11
expect ( actual ) . toEqual ( [ 'abc' ] ) ;
12
12
} ) ;
13
13
14
- it ( 'should work with URLSearchParams' , ( ) => {
14
+ it ( 'works with URLSearchParams' , ( ) => {
15
15
const body = new URLSearchParams ( ) ;
16
16
body . append ( 'name' , 'Anne' ) ;
17
17
body . append ( 'age' , '32' ) ;
18
18
const actual = getBodyString ( body ) ;
19
19
expect ( actual ) . toEqual ( [ 'name=Anne&age=32' ] ) ;
20
20
} ) ;
21
21
22
- it ( 'should work with FormData' , ( ) => {
22
+ it ( 'works with FormData' , ( ) => {
23
23
const body = new FormData ( ) ;
24
- body . append ( 'name' , 'Bob ' ) ;
24
+ body . append ( 'name' , 'Anne ' ) ;
25
25
body . append ( 'age' , '32' ) ;
26
26
const actual = getBodyString ( body ) ;
27
- expect ( actual ) . toEqual ( [ 'name=Bob &age=32' ] ) ;
27
+ expect ( actual ) . toEqual ( [ 'name=Anne &age=32' ] ) ;
28
28
} ) ;
29
29
30
- it ( 'should work with empty data' , ( ) => {
30
+ it ( 'works with empty data' , ( ) => {
31
31
const body = undefined ;
32
32
const actual = getBodyString ( body ) ;
33
33
expect ( actual ) . toEqual ( [ undefined ] ) ;
34
34
} ) ;
35
35
36
- it ( 'should return unparsable with other types of data' , ( ) => {
36
+ it ( 'works with other type of data' , ( ) => {
37
37
const body = { } ;
38
38
const actual = getBodyString ( body ) ;
39
39
expect ( actual ) . toEqual ( [ undefined , 'UNPARSEABLE_BODY_TYPE' ] ) ;
@@ -42,15 +42,15 @@ describe('getBodyString', () => {
42
42
43
43
describe ( 'getFetchRequestArgBody' , ( ) => {
44
44
describe ( 'valid types of body' , ( ) => {
45
- it ( 'should work with json string' , ( ) => {
45
+ it ( 'works with json string' , ( ) => {
46
46
const body = { data : [ 1 , 2 , 3 ] } ;
47
47
const jsonBody = JSON . stringify ( body ) ;
48
48
49
49
const actual = getFetchRequestArgBody ( [ 'http://example.com' , { method : 'POST' , body : jsonBody } ] ) ;
50
50
expect ( actual ) . toEqual ( jsonBody ) ;
51
51
} ) ;
52
52
53
- it ( 'should work with URLSearchParams' , ( ) => {
53
+ it ( 'works with URLSearchParams' , ( ) => {
54
54
const body = new URLSearchParams ( ) ;
55
55
body . append ( 'name' , 'Anne' ) ;
56
56
body . append ( 'age' , '32' ) ;
@@ -59,7 +59,7 @@ describe('getFetchRequestArgBody', () => {
59
59
expect ( actual ) . toEqual ( body ) ;
60
60
} ) ;
61
61
62
- it ( 'should work with FormData' , ( ) => {
62
+ it ( 'works with FormData' , ( ) => {
63
63
const body = new FormData ( ) ;
64
64
body . append ( 'name' , 'Bob' ) ;
65
65
body . append ( 'age' , '32' ) ;
@@ -68,13 +68,13 @@ describe('getFetchRequestArgBody', () => {
68
68
expect ( actual ) . toEqual ( body ) ;
69
69
} ) ;
70
70
71
- it ( 'should work with Blob' , ( ) => {
71
+ it ( 'works with Blob' , ( ) => {
72
72
const body = new Blob ( [ 'example' ] , { type : 'text/plain' } ) ;
73
73
const actual = getFetchRequestArgBody ( [ 'http://example.com' , { method : 'POST' , body } ] ) ;
74
74
expect ( actual ) . toEqual ( body ) ;
75
75
} ) ;
76
76
77
- it ( 'should work with BufferSource (ArrayBufferView | ArrayBuffer)' , ( ) => {
77
+ it ( 'works with BufferSource (ArrayBufferView | ArrayBuffer)' , ( ) => {
78
78
const body = new Uint8Array ( [ 1 , 2 , 3 ] ) ;
79
79
const actual = getFetchRequestArgBody ( [ 'http://example.com' , { method : 'POST' , body } ] ) ;
80
80
expect ( actual ) . toEqual ( body ) ;
0 commit comments