tests: cleanup common variables
This commit is contained in:
@@ -15,13 +15,13 @@ const common = require('./common.js'),
|
||||
settings = require('../settings.js'),
|
||||
updatechecker = require('../updatechecker.js');
|
||||
|
||||
const { APP, APPSTORE_TOKEN, MOCK_API_SERVER_ORIGIN } = common;
|
||||
|
||||
const UPDATE_VERSION = semver.inc(constants.VERSION, 'major');
|
||||
|
||||
describe('updatechecker', function () {
|
||||
before(common.setup);
|
||||
after(common.cleanup);
|
||||
const { setup, cleanup, app, appstoreToken, mockApiServerOrigin } = common;
|
||||
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
|
||||
describe('box', function () {
|
||||
before(function (done) {
|
||||
@@ -33,9 +33,9 @@ describe('updatechecker', function () {
|
||||
it('no updates', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/boxupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false })
|
||||
.reply(204, { } );
|
||||
|
||||
updatechecker.checkForUpdates({ automatic: false }, function (error) {
|
||||
@@ -49,9 +49,9 @@ describe('updatechecker', function () {
|
||||
it('new version', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/boxupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false })
|
||||
.reply(200, { version: UPDATE_VERSION, changelog: [''], sourceTarballUrl: 'box.tar.gz', sourceTarballSigUrl: 'box.tar.gz.sig', boxVersionsUrl: 'box.versions', boxVersionsSigUrl: 'box.versions.sig' } );
|
||||
|
||||
updatechecker.checkForUpdates({ automatic: false }, function (error) {
|
||||
@@ -66,9 +66,9 @@ describe('updatechecker', function () {
|
||||
it('bad response offers whatever was last valid', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/boxupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false })
|
||||
.reply(404, { version: '2.0.0-pre.0', changelog: [''], sourceTarballUrl: 'box-pre.tar.gz' } );
|
||||
|
||||
updatechecker.checkForUpdates({ automatic: false }, function (error) {
|
||||
@@ -91,9 +91,9 @@ describe('updatechecker', function () {
|
||||
it('no updates', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/appupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, appId: APP.appStoreId, appVersion: APP.manifest.version, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false })
|
||||
.reply(204, { } );
|
||||
|
||||
updatechecker._checkAppUpdates({ automatic: false }, function (error) {
|
||||
@@ -107,9 +107,9 @@ describe('updatechecker', function () {
|
||||
it('bad response', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/appupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, appId: APP.appStoreId, appVersion: APP.manifest.version, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false })
|
||||
.reply(500, { update: { manifest: { version: '1.0.0', changelog: '* some changes' } } } );
|
||||
|
||||
updatechecker._checkAppUpdates({ automatic: false }, function (error) {
|
||||
@@ -123,9 +123,9 @@ describe('updatechecker', function () {
|
||||
it('offers new version', function (done) {
|
||||
nock.cleanAll();
|
||||
|
||||
var scope = nock(MOCK_API_SERVER_ORIGIN)
|
||||
var scope = nock(mockApiServerOrigin)
|
||||
.get('/api/v1/appupdate')
|
||||
.query({ boxVersion: constants.VERSION, accessToken: APPSTORE_TOKEN, appId: APP.appStoreId, appVersion: APP.manifest.version, automatic: false })
|
||||
.query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false })
|
||||
.reply(200, { manifest: { version: '2.0.0', changelog: '* some changes' } } );
|
||||
|
||||
updatechecker._checkAppUpdates({ automatic: false }, function (error) {
|
||||
|
||||
Reference in New Issue
Block a user