fix tests
This commit is contained in:
@@ -7,44 +7,20 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
appstore = require('../appstore.js'),
|
||||
database = require('../database.js'),
|
||||
const appstore = require('../appstore.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
nock = require('nock'),
|
||||
settings = require('../settings.js'),
|
||||
settingsdb = require('../settingsdb.js');
|
||||
|
||||
const DASHBOARD_DOMAIN = 'appstore-test.example.com';
|
||||
const APPSTORE_TOKEN = 'appstoretoken';
|
||||
const APP_ID = 'appid';
|
||||
const APPSTORE_APP_ID = 'appstoreappid';
|
||||
const MOCK_API_SERVER_ORIGIN = 'http://localhost:6060';
|
||||
|
||||
function setup(done) {
|
||||
nock.cleanAll();
|
||||
|
||||
async.series([
|
||||
database.initialize,
|
||||
database._clear,
|
||||
settings._setApiServerOrigin.bind(null, MOCK_API_SERVER_ORIGIN),
|
||||
settings.setDashboardLocation.bind(null, DASHBOARD_DOMAIN, 'my.' + DASHBOARD_DOMAIN),
|
||||
settings.initCache
|
||||
], done);
|
||||
}
|
||||
|
||||
function cleanup(done) {
|
||||
nock.cleanAll();
|
||||
|
||||
async.series([
|
||||
database._clear,
|
||||
database.uninitialize
|
||||
], done);
|
||||
}
|
||||
|
||||
describe('Appstore', function () {
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
before(common.setup);
|
||||
after(common.cleanup);
|
||||
|
||||
beforeEach(nock.cleanAll);
|
||||
|
||||
@@ -53,7 +29,7 @@ describe('Appstore', function () {
|
||||
});
|
||||
|
||||
it('can purchase an app', function (done) {
|
||||
var scope1 = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.post(`/api/v1/cloudronapps?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
.reply(201, {});
|
||||
|
||||
@@ -66,11 +42,11 @@ describe('Appstore', function () {
|
||||
});
|
||||
|
||||
it('unpurchase succeeds if app was never purchased', function (done) {
|
||||
var scope1 = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`)
|
||||
.reply(404, {});
|
||||
|
||||
var scope2 = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope2 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
.reply(204, {});
|
||||
|
||||
@@ -84,11 +60,11 @@ describe('Appstore', function () {
|
||||
});
|
||||
|
||||
it('can unpurchase an app', function (done) {
|
||||
var scope1 = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope1 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.get(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`)
|
||||
.reply(200, {});
|
||||
|
||||
var scope2 = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope2 = nock(common.MOCK_API_SERVER_ORIGIN)
|
||||
.delete(`/api/v1/cloudronapps/${APP_ID}?accessToken=${APPSTORE_TOKEN}`, function () { return true; })
|
||||
.reply(204, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user