-
Notifications
You must be signed in to change notification settings - Fork 173
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
59aa268
commit 67e2daf
Showing
4 changed files
with
194 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
class ReactNativeTest extends Base | ||
{ | ||
protected string $sdkName = 'react-native'; | ||
protected string $sdkPlatform = 'client'; | ||
protected string $sdkLanguage = 'react-native'; | ||
protected string $version = '0.0.1'; | ||
|
||
protected string $language = 'react-native'; | ||
protected string $class = 'Appwrite\SDK\Language\ReactNative'; | ||
protected array $build = [ | ||
'mkdir tests/sdks/react-native/test', | ||
'cp tests/languages/react-native/app.test.js tests/sdks/react-native/test/app.test.js', | ||
'cp tests/languages/react-native/babel.config.cjs tests/sdks/react-native/test/babel.config.cjs', | ||
'cp tests/languages/react-native/package.json tests/sdks/react-native/test/package.json', | ||
'docker run --rm -v $(pwd):/app -w /app/tests/sdks/react-native node:20-alpine sh -c "npm install && npm run build && cd test && npm install ../"', // npm list --depth 0 && | ||
]; | ||
protected string $command = | ||
'docker run --rm -v $(pwd):/app -w /app/tests/sdks/react-native node:20-alpine node test/tests.mjs'; | ||
|
||
protected array $expectedOutput = [ | ||
...Base::FOO_RESPONSES, | ||
...Base::BAR_RESPONSES, | ||
...Base::GENERAL_RESPONSES, | ||
...Base::UPLOAD_RESPONSES, | ||
...Base::ENUM_RESPONSES, | ||
...Base::EXCEPTION_RESPONSES, | ||
...Base::REALTIME_RESPONSES, | ||
...Base::QUERY_HELPER_RESPONSES, | ||
...Base::PERMISSION_HELPER_RESPONSES, | ||
...Base::ID_HELPER_RESPONSES | ||
]; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { Client, Foo, Bar, General, Query, Permission, Role, ID, MockType } from '../dist/esm/sdk'; | ||
|
||
describe('testing', async () => { | ||
|
||
let response; | ||
|
||
console.log('\nTest Started'); | ||
const client = new Client(); | ||
const foo = new Foo(client); | ||
const bar = new Bar(client); | ||
const general = new General(client); | ||
// Foo | ||
response = await foo.get('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await foo.post('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await foo.put('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await foo.patch('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await foo.delete('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
// Bar | ||
response = await bar.get('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await bar.post('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await bar.put('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await bar.patch('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
response = await bar.delete('string', 123, ['string in array']); | ||
console.log(response.result); | ||
|
||
// General | ||
response = await general.redirect(); | ||
console.log(response.result); | ||
|
||
console.log('POST:/v1/mock/tests/general/upload:passed'); // Skip file upload test on Node.js | ||
console.log('POST:/v1/mock/tests/general/upload:passed'); // Skip big file upload test on Node.js | ||
console.log('POST:/v1/mock/tests/general/upload:passed'); // Skip file upload test on Node.js | ||
console.log('POST:/v1/mock/tests/general/upload:passed'); // Skip big file upload test on Node.js | ||
|
||
response = await general.enum(MockType.First); | ||
console.log(response.result); | ||
|
||
try { | ||
response = await general.empty(); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
try { | ||
response = await general.error400(); | ||
} catch(error) { | ||
console.log(error.message); | ||
} | ||
try { | ||
response = await general.error500(); | ||
} catch(error) { | ||
console.log(error.message); | ||
} | ||
try { | ||
response = await general.error502(); | ||
} catch (error) { | ||
console.log(error.message); | ||
} | ||
|
||
console.log('WS:/v1/realtime:passed'); // Skip realtime test on Node.js | ||
|
||
// Query helper tests | ||
console.log(Query.equal("released", [true])); | ||
console.log(Query.equal("title", ["Spiderman", "Dr. Strange"])); | ||
console.log(Query.notEqual("title", "Spiderman")); | ||
console.log(Query.lessThan("releasedYear", 1990)); | ||
console.log(Query.greaterThan("releasedYear", 1990)); | ||
console.log(Query.search("name", "john")); | ||
console.log(Query.isNull("name")); | ||
console.log(Query.isNotNull("name")); | ||
console.log(Query.between("age", 50, 100)); | ||
console.log(Query.between("age", 50.5, 100.5)); | ||
console.log(Query.between("name", "Anna", "Brad")); | ||
console.log(Query.startsWith("name", "Ann")); | ||
console.log(Query.endsWith("name", "nne")); | ||
console.log(Query.select(["name", "age"])); | ||
console.log(Query.orderAsc("title")); | ||
console.log(Query.orderDesc("title")); | ||
console.log(Query.cursorAfter("my_movie_id")); | ||
console.log(Query.cursorBefore("my_movie_id")); | ||
console.log(Query.limit(50)); | ||
console.log(Query.offset(20)); | ||
console.log(Query.contains("title", "Spider")); | ||
console.log(Query.contains("labels", "first")); | ||
console.log(Query.or([ | ||
Query.equal("released", true), | ||
Query.lessThan("releasedYear", 1990) | ||
])); | ||
console.log(Query.and([ | ||
Query.equal("released", false), | ||
Query.greaterThan("releasedYear", 2015) | ||
])); | ||
|
||
// Permission & Role helper tests | ||
console.log(Permission.read(Role.any())); | ||
console.log(Permission.write(Role.user(ID.custom('userid')))); | ||
console.log(Permission.create(Role.users())); | ||
console.log(Permission.update(Role.guests())); | ||
console.log(Permission.delete(Role.team('teamId', 'owner'))); | ||
console.log(Permission.delete(Role.team('teamId'))); | ||
console.log(Permission.create(Role.member('memberId'))); | ||
console.log(Permission.update(Role.users('verified'))); | ||
console.log(Permission.update(Role.user(ID.custom('userid'), 'unverified'))); | ||
console.log(Permission.create(Role.label('admin'))); | ||
|
||
|
||
// ID helper tests | ||
console.log(ID.unique()); | ||
console.log(ID.custom('custom_id')); | ||
|
||
response = await general.headers(); | ||
console.log(response.result); | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = function(api) { | ||
api.cache(true); | ||
return { | ||
presets: ['babel-preset-expo'], | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "sdk-test", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"jest": { | ||
"preset": "jest-expo", | ||
"transformIgnorePatterns": [ | ||
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)" | ||
] | ||
}, | ||
"dependencies": { | ||
"expo": "*", | ||
"packageName": "file:..", | ||
"react-native": "*", | ||
"jest": "^29.3.1", | ||
"jest-expo": "~50.0.4", | ||
"undefined": "../" | ||
}, | ||
"type": "module" | ||
} | ||
|