File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 22
22
"scripts" : {
23
23
"test:node" : " mocha test/test-*.spec.cjs" ,
24
24
"test:browser" : " playwright-test test/test-*.cjs" ,
25
- "test:es" : " mocha test/test-*.spec.js" ,
25
+ "test:react-native" : " jest test/test-lib.react-native.spec.js" ,
26
+ "test:es" : " mocha test/test-lib.spec.js" ,
26
27
"test:cjs" : " npm run test:node && npm run test:browser" ,
27
28
"test:types:ts" : " npm test --prefix test/ts-use" ,
28
29
"test:types:esm" : " npm test --prefix test/esm-use" ,
34
35
"author" :
" Irakli Gozalishvili <[email protected] >" ,
35
36
"homepage" : " https://github.com/gozala/web-encoding" ,
36
37
"devDependencies" : {
38
+ "browser-resolve" : " ^2.0.0" ,
39
+ "jest" : " ^26.6.3" ,
40
+ "metro-react-native-babel-preset" : " ^0.64.0" ,
37
41
"mocha" : " 8.2.1" ,
38
- "playwright-test" : " 1.2.0"
42
+ "playwright-test" : " 1.2.0" ,
43
+ "react-native" : " ^0.63.4"
39
44
},
40
45
"optionalDependencies" : {
41
46
"@sinonjs/text-encoding" : " 0.7.1"
47
+ },
48
+ "jest" : {
49
+ "preset" : " react-native" ,
50
+ "transform" : {"\\ .js$" : [" babel-jest" , {"presets" : [" module:metro-react-native-babel-preset" ]}]}
42
51
}
43
52
}
Original file line number Diff line number Diff line change
1
+ import { TextEncoder , TextDecoder } from "../src/lib.react-native.js"
2
+ import assert from "assert"
3
+
4
+ describe ( "text encode/decode" , ( ) => {
5
+ const data = Uint8Array . from ( [
6
+ 104 ,
7
+ 101 ,
8
+ 108 ,
9
+ 108 ,
10
+ 111 ,
11
+ 32 ,
12
+ 119 ,
13
+ 111 ,
14
+ 114 ,
15
+ 108 ,
16
+ 100 ,
17
+ ] )
18
+
19
+ it ( "can encode text" , ( ) => {
20
+ const bytes = new TextEncoder ( ) . encode ( "hello world" )
21
+ assert . deepStrictEqual ( bytes , data )
22
+ } )
23
+
24
+ it ( "can decode text" , ( ) => {
25
+ const text = new TextDecoder ( ) . decode ( data )
26
+ assert . equal ( text , "hello world" )
27
+ } )
28
+ } )
You can’t perform that action at this time.
0 commit comments