This repository has been archived by the owner on Mar 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added getCompleteDownloadInfo to be used before downloadApk
- Loading branch information
1 parent
c648986
commit f1a8d88
Showing
3 changed files
with
86 additions
and
10 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
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,46 @@ | ||
var api = require('./api'); | ||
var test = require('tape'); | ||
var AppNotFreeError = require('../lib/errors').AppNotFreeError; | ||
var RequestError = require('../lib/errors').RequestError; | ||
|
||
test('completeDownloadInfo api', function (t) { | ||
t.plan(8); | ||
api.completeDownloadInfo('com.viber.voip', 37, function (err, res) { | ||
t.notOk(err, 'no error'); | ||
t.ok(res, 'returned results'); | ||
|
||
t.ok(res.hasOwnProperty('url'), 'url in response'); | ||
t.ok(res.url.indexOf('com.viber.voip') > -1, 'package name should be in response url'); | ||
|
||
t.ok(res.hasOwnProperty('jar'), 'response should have cookie jar'); | ||
|
||
t.ok(res.hasOwnProperty('headers'), 'response has headers'); | ||
t.ok(res.headers.hasOwnProperty('User-Agent'), 'User-Agent in response headers'); | ||
t.ok(res.headers.hasOwnProperty('Accept-Encoding'), 'Accept-Encoding in response headers'); | ||
}); | ||
}); | ||
|
||
// TODO: fix this test | ||
test.skip('completeDownloadInfo api - Paid apps', function (t) { | ||
t.plan(5); | ||
api.completeDownloadInfo('com.mojang.minecraftpe', 740140009, function (err, res) { | ||
t.ok(err, 'error expected'); | ||
t.ok(err instanceof AppNotFreeError, 'error instanceof AppNotFreeError'); | ||
t.ok(err.name === 'AppNotFreeError', 'error.name is AppNotFreeError'); | ||
t.ok(err.price, 'error has price'); | ||
t.notOk(res, 'no results'); | ||
t.comment('price: ' + err.price); | ||
}); | ||
}); | ||
|
||
test('completeDownloadInfo api - Item not found ', function (t) { | ||
t.plan(5); | ||
api.completeDownloadInfo('i.should.probably.not.exist', 25, function (err, res) { | ||
t.ok(err instanceof RequestError, 'RequestError'); | ||
t.ok(err, 'error returned'); | ||
t.notOk(res, 'no response'); | ||
t.ok(err.message = 'Item not found', 'error msg'); | ||
t.equal(err.statusCode, 403, 'status code'); | ||
}); | ||
}); | ||
|