tests: cleanup common variables
This commit is contained in:
+15
-20
@@ -10,27 +10,22 @@
|
||||
const appstore = require('../appstore.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
nock = require('nock'),
|
||||
settings = require('../settings.js'),
|
||||
settingsdb = require('../settingsdb.js');
|
||||
nock = require('nock');
|
||||
|
||||
const APPSTORE_TOKEN = 'appstoretoken';
|
||||
const APP_ID = 'appid';
|
||||
const APPSTORE_APP_ID = 'appstoreappid';
|
||||
|
||||
describe('Appstore', function () {
|
||||
before(common.setup);
|
||||
after(common.cleanup);
|
||||
const { setup, cleanup, appstoreToken, mockApiServerOrigin } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
beforeEach(nock.cleanAll);
|
||||
|
||||
it('can set cloudron token', function (done) {
|
||||
settingsdb.set(settings.CLOUDRON_TOKEN_KEY, APPSTORE_TOKEN, done);
|
||||
});
|
||||
|
||||
it('can purchase an app', function (done) {
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.post(`/api/v1/cloudronapps?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
const scope1 = nock(mockApiServerOrigin)
|
||||
.post(`/api/v1/cloudronapps?accessToken=${appstoreToken}`, function () { return true; })
|
||||
.reply(201, {});
|
||||
|
||||
appstore.purchaseApp({ appId: APP_ID, appstoreId: APPSTORE_APP_ID, manifestId: APPSTORE_APP_ID }, function (error) {
|
||||
@@ -42,12 +37,12 @@ describe('Appstore', function () {
|
||||
});
|
||||
|
||||
it('unpurchase succeeds if app was never purchased', function (done) {
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`)
|
||||
const scope1 = nock(mockApiServerOrigin)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${appstoreToken}`)
|
||||
.reply(404, {});
|
||||
|
||||
var scope2 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
const scope2 = nock(mockApiServerOrigin)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${appstoreToken}`, function () { return true; })
|
||||
.reply(204, {});
|
||||
|
||||
appstore.unpurchaseApp(APP_ID, { appstoreId: APPSTORE_APP_ID, manifestId: APPSTORE_APP_ID }, function (error) {
|
||||
@@ -60,12 +55,12 @@ describe('Appstore', function () {
|
||||
});
|
||||
|
||||
it('can unpurchase an app', function (done) {
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`)
|
||||
const scope1 = nock(mockApiServerOrigin)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${appstoreToken}`)
|
||||
.reply(200, {});
|
||||
|
||||
var scope2 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
const scope2 = nock(mockApiServerOrigin)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${appstoreToken}`, function () { return true; })
|
||||
.reply(204, {});
|
||||
|
||||
appstore.unpurchaseApp(APP_ID, { appstoreId: APPSTORE_APP_ID, manifestId: APPSTORE_APP_ID }, function (error) {
|
||||
|
||||
Reference in New Issue
Block a user