-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
31 additions
and
54 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
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,48 +1,43 @@ | ||
import developer from './developer.js' | ||
|
||
describe('developer', () => { | ||
test('get developer', async (done) => { | ||
test('get developer', async () => { | ||
try { | ||
const { account, applications } = await developer({ id: 284882218 }) | ||
expect(account).toBeDefined() | ||
expect(applications).toBeInstanceOf(Array) | ||
expect(applications.length > 0).toBeTruthy() | ||
} catch (error) { | ||
expect(error).toBeUndefined() | ||
} finally { | ||
done() | ||
} | ||
}) | ||
|
||
test('should throw error on invalid id', async (done) => { | ||
test('should throw error on invalid id', async () => { | ||
try { | ||
await developer({ id: null }) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
expect(error.message).toEqual('Id is required') | ||
} finally { | ||
done() | ||
} | ||
}) | ||
|
||
test('should throw error on invalid country', async (done) => { | ||
test('should throw error on invalid country', async () => { | ||
try { | ||
await developer({ id: 284882215, country: 'HELLO' }) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
expect(error.message).toEqual('Invalid country id') | ||
} finally { | ||
done() | ||
} | ||
}) | ||
|
||
test('should set request options', async (done) => { | ||
test('should set request options', async () => { | ||
try { | ||
await developer({ id: 284882215 }, { method: 'DELETE' }) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
} finally { | ||
done() | ||
} | ||
}) | ||
}) |
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,26 +1,24 @@ | ||
import ratings from './ratings.js' | ||
|
||
describe('ratings', () => { | ||
it('should get ratings properly', async (done) => { | ||
it('should get ratings properly', async () => { | ||
try { | ||
const r = await ratings({ id: 284882215, country: 'US' }) | ||
expect(r.ratings).toBeDefined() | ||
expect(r.histogram).toBeInstanceOf(Object) | ||
expect(Object.keys(r.histogram).length).toEqual(5) | ||
} catch (error) { | ||
expect(error).toBeUndefined() | ||
} finally { | ||
done() | ||
} | ||
}) | ||
|
||
test('should set request options', async (done) => { | ||
test('should set request options', async () => { | ||
try { | ||
await ratings({ id: 284882215, country: 'us' }, { method: 'DELETE' }) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
} finally { | ||
done() | ||
expect(error.message.includes('Invalid')).toBeFalsy() | ||
} | ||
}) | ||
}) |
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,40 +1,37 @@ | ||
import search from './search.js' | ||
|
||
describe('search', () => { | ||
test('search an application', async (done) => { | ||
test('search an application', async () => { | ||
try { | ||
const results = await search({ term: 'facebook' }) | ||
expect(results).toBeInstanceOf(Array) | ||
expect(results[0].appId).toEqual('com.facebook.Facebook') | ||
done() | ||
} catch (error) { | ||
expect(error).toBeUndefined() | ||
done(error) | ||
} | ||
}) | ||
|
||
test('should throw an error on invalid country', async (done) => { | ||
test('should throw an error on invalid country', async () => { | ||
try { | ||
const results = await search({ | ||
term: 'facebook', | ||
country: 'laba daba lup lup', | ||
}) | ||
expect(results).toBeUndefined() | ||
done(new Error(`Country should have throwed an error`)) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
expect(error.message).toEqual('Invalid country id') | ||
done() | ||
} | ||
}) | ||
|
||
test('should set request options', async (done) => { | ||
test('should set request options', async () => { | ||
try { | ||
await search({ term: 'facebook' }, { method: 'DELETE' }) | ||
done(new Error(`Invalid`)) | ||
throw new Error(`Invalid`) | ||
} catch (error) { | ||
expect(error).toBeDefined() | ||
done() | ||
expect(error.message.includes('Invalid')).toBeFalsy() | ||
} | ||
}) | ||
}) |