-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4b4a0d
commit 4c94b15
Showing
22 changed files
with
1,204 additions
and
873 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ coverage/ | |
dist/ | ||
lib/ | ||
example/ | ||
index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
module.exports = { | ||
extends: ['@react-native-community'], | ||
rules: { | ||
'no-bitwise': 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,149 @@ | ||
import ByteParser from '../src/ByteParser'; | ||
|
||
test('parse byteToHexString', () => { | ||
let payload = [104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 119, 104, 105, 116, 101, 100, 111, 103, 103, 49, 51, 47, 114, 101, 97, 99, 116, 45, 110, 97, 116, 105, 118, 101, 45, 110, 102, 99, 45, 109, 97, 110, 97, 103, 101, 114, 35, 114, 101, 97, 100, 109, 101]; | ||
expect(ByteParser.byteToHexString(payload)).toBe("68747470733a2f2f6769746875622e636f6d2f7768697465646f676731332f72656163742d6e61746976652d6e66632d6d616e6167657223726561646d65"); | ||
test('parse byteToHexString', () => { | ||
let payload = [ | ||
104, | ||
116, | ||
116, | ||
112, | ||
115, | ||
58, | ||
47, | ||
47, | ||
103, | ||
105, | ||
116, | ||
104, | ||
117, | ||
98, | ||
46, | ||
99, | ||
111, | ||
109, | ||
47, | ||
119, | ||
104, | ||
105, | ||
116, | ||
101, | ||
100, | ||
111, | ||
103, | ||
103, | ||
49, | ||
51, | ||
47, | ||
114, | ||
101, | ||
97, | ||
99, | ||
116, | ||
45, | ||
110, | ||
97, | ||
116, | ||
105, | ||
118, | ||
101, | ||
45, | ||
110, | ||
102, | ||
99, | ||
45, | ||
109, | ||
97, | ||
110, | ||
97, | ||
103, | ||
101, | ||
114, | ||
35, | ||
114, | ||
101, | ||
97, | ||
100, | ||
109, | ||
101, | ||
]; | ||
expect(ByteParser.byteToHexString(payload)).toBe( | ||
'68747470733a2f2f6769746875622e636f6d2f7768697465646f676731332f72656163742d6e61746976652d6e66632d6d616e6167657223726561646d65', | ||
); | ||
}); | ||
|
||
test('parse byteToHexString should return empty', () => { | ||
expect(ByteParser.byteToHexString({something: "wrong"})).toBe(""); | ||
test('parse byteToHexString should return empty', () => { | ||
expect(ByteParser.byteToHexString({something: 'wrong'})).toBe(''); | ||
}); | ||
|
||
test('parse byteToString', () => { | ||
let payload = [104, 116, 116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, 119, 104, 105, 116, 101, 100, 111, 103, 103, 49, 51, 47, 114, 101, 97, 99, 116, 45, 110, 97, 116, 105, 118, 101, 45, 110, 102, 99, 45, 109, 97, 110, 97, 103, 101, 114, 35, 114, 101, 97, 100, 109, 101]; | ||
expect(ByteParser.byteToString(payload)).toBe("https://github.com/whitedogg13/react-native-nfc-manager#readme"); | ||
test('parse byteToString', () => { | ||
let payload = [ | ||
104, | ||
116, | ||
116, | ||
112, | ||
115, | ||
58, | ||
47, | ||
47, | ||
103, | ||
105, | ||
116, | ||
104, | ||
117, | ||
98, | ||
46, | ||
99, | ||
111, | ||
109, | ||
47, | ||
119, | ||
104, | ||
105, | ||
116, | ||
101, | ||
100, | ||
111, | ||
103, | ||
103, | ||
49, | ||
51, | ||
47, | ||
114, | ||
101, | ||
97, | ||
99, | ||
116, | ||
45, | ||
110, | ||
97, | ||
116, | ||
105, | ||
118, | ||
101, | ||
45, | ||
110, | ||
102, | ||
99, | ||
45, | ||
109, | ||
97, | ||
110, | ||
97, | ||
103, | ||
101, | ||
114, | ||
35, | ||
114, | ||
101, | ||
97, | ||
100, | ||
109, | ||
101, | ||
]; | ||
expect(ByteParser.byteToString(payload)).toBe( | ||
'https://github.com/whitedogg13/react-native-nfc-manager#readme', | ||
); | ||
}); | ||
|
||
test('parse byteToString should return empty', () => { | ||
expect(ByteParser.byteToString({something: "wrong"})).toBe(""); | ||
test('parse byteToString should return empty', () => { | ||
expect(ByteParser.byteToString({something: 'wrong'})).toBe(''); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.