- This starter project comes with simple tabs-based layout for apps
- that are going to primarily use a Tabbed UI.
-
-
- Take a look at the src/pages/ directory to add or change tabs,
- update any existing page or create new pages.
+ If you get lost, the docs will be your guide.
diff --git a/manup-demo/src/pages/home/home.ts b/manup-demo/src/pages/home/home.ts
index e9f7e6a..1d510dd 100644
--- a/manup-demo/src/pages/home/home.ts
+++ b/manup-demo/src/pages/home/home.ts
@@ -1,5 +1,4 @@
import { Component } from '@angular/core';
-
import { NavController } from 'ionic-angular';
@Component({
diff --git a/manup-demo/src/pages/tabs/tabs.html b/manup-demo/src/pages/tabs/tabs.html
deleted file mode 100644
index fa3921a..0000000
--- a/manup-demo/src/pages/tabs/tabs.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/manup-demo/src/pages/tabs/tabs.ts b/manup-demo/src/pages/tabs/tabs.ts
deleted file mode 100644
index a95cdf4..0000000
--- a/manup-demo/src/pages/tabs/tabs.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Component } from '@angular/core';
-
-import { HomePage } from '../home/home';
-import { AboutPage } from '../about/about';
-import { ContactPage } from '../contact/contact';
-
-@Component({
- templateUrl: 'tabs.html'
-})
-export class TabsPage {
- // this tells the tabs component which Pages
- // should be each tab's root Page
- tab1Root: any = HomePage;
- tab2Root: any = AboutPage;
- tab3Root: any = ContactPage;
-
- constructor() {
-
- }
-}
diff --git a/manup-demo/src/theme/variables.scss b/manup-demo/src/theme/variables.scss
index 12c82d5..18276a4 100644
--- a/manup-demo/src/theme/variables.scss
+++ b/manup-demo/src/theme/variables.scss
@@ -1,7 +1,17 @@
// Ionic Variables and Theming. For more info, please see:
-// http://ionicframework.com/docs/v2/theming/
+// http://ionicframework.com/docs/theming/
+
+// Font path is used to include ionicons,
+// roboto, and noto sans fonts
$font-path: "../assets/fonts";
+
+// The app direction is used to include
+// rtl styles in your app. For more info, please see:
+// http://ionicframework.com/docs/theming/rtl-support/
+$app-direction: ltr;
+
+
@import "ionic.globals";
@@ -10,7 +20,7 @@ $font-path: "../assets/fonts";
// To customize the look and feel of this app, you can override
// the Sass variables found in Ionic's source scss files.
// To view all the possible Ionic variables, see:
-// http://ionicframework.com/docs/v2/theming/overriding-ionic-variables/
+// http://ionicframework.com/docs/theming/overriding-ionic-variables/
@@ -24,7 +34,7 @@ $font-path: "../assets/fonts";
// The "primary" color is the only required color in the map.
$colors: (
- primary: #387ef5,
+ primary: #488aff,
secondary: #32db64,
danger: #f53d3d,
light: #f4f4f4,
@@ -66,7 +76,7 @@ $colors: (
// Ionicons
// --------------------------------------------------
// The premium icon font for Ionic. For more info, please see:
-// http://ionicframework.com/docs/v2/ionicons/
+// http://ionicframework.com/docs/ionicons/
@import "ionic.ionicons";
diff --git a/manup-demo/tsconfig.json b/manup-demo/tsconfig.json
index df50ddf..2e450f9 100644
--- a/manup-demo/tsconfig.json
+++ b/manup-demo/tsconfig.json
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
- "declaration": true,
+ "declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
@@ -23,4 +23,4 @@
"atom": {
"rewriteTsconfig": false
}
-}
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index d73ddd6..0f3dc9d 100644
--- a/package.json
+++ b/package.json
@@ -7,14 +7,14 @@
"scripts": {
"clean": "rm -rf lib",
"mocha": "node_modules/.bin/mocha",
- "test": "ng test --single-run --code-coverage",
"posttest": "npm run coveralls",
"tsc": "node_modules/.bin/tsc",
"ngc": "node_modules/.bin/ngc",
"build": "npm run ngc",
"prebuild": "npm run clean",
"prepublish": "npm run build",
- "coveralls": "./node_modules/coveralls/bin/coveralls.js < coverage/coverage.lcov"
+ "coveralls": "./node_modules/coveralls/bin/coveralls.js < coverage/lcov.info",
+ "test": "karma start ./test-config/karma.conf.js --single-run --coverage"
},
"repository": {
"type": "git",
@@ -28,36 +28,45 @@
"author": "Michael Marner ",
"license": "MIT",
"devDependencies": {
- "@angular/common": "^2.2.1",
- "@angular/compiler": "^2.2.1",
- "@angular/compiler-cli": "^2.2.1",
- "@angular/core": "^2.2.1",
- "@angular/forms": "^2.2.1",
- "@angular/http": "^2.2.1",
- "@angular/platform-browser": "^2.2.1",
- "@angular/platform-browser-dynamic": "^2.2.1",
- "@angular/platform-server": "^2.2.1",
+ "@angular/common": "^4.4.3",
+ "@angular/compiler": "^4.4.3",
+ "@angular/compiler-cli": "^4.4.3",
+ "@angular/core": "^4.4.3",
+ "@angular/forms": "^4.4.3",
+ "@angular/http": "^4.4.3",
+ "@angular/platform-browser": "^4.4.3",
+ "@angular/platform-browser-dynamic": "^4.4.3",
+ "@angular/platform-server": "^4.4.3",
+ "@ionic-native/app-version": "^4.3.1",
+ "@ionic-native/core": "^4.3.1",
+ "@ionic-native/in-app-browser": "^4.3.1",
"@ionic/storage": "^1.1.9",
"@ngx-translate/core": "^7.0.0",
"@types/jasmine": "^2.5.41",
"@types/node": "^7.0.5",
"@types/semver": "^5.3.30",
- "angular-cli": "^1.0.0-beta.28.3",
+ "angular2-template-loader": "^0.6.2",
"codecov": "^1.0.1",
"coveralls": "^2.11.16",
"ionic-angular": "^2.0.0",
- "ionic-native": "^2.4.1",
+ "istanbul-instrumenter-loader": "^3.0.0",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^3.2.0",
"karma": "^1.4.1",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
+ "karma-coverage": "^1.1.1",
+ "karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
+ "karma-jasmine-html-reporter": "^0.2.2",
"karma-mocha-reporter": "^2.2.2",
- "karma-phantomjs-launcher": "^1.0.2",
"karma-remap-istanbul": "^0.6.0",
+ "karma-sourcemap-loader": "^0.3.7",
+ "karma-typescript": "^3.0.7",
+ "karma-webpack": "^2.0.4",
"mocha": "^3.2.0",
"rxjs": "^5.0.0-beta.12",
+ "ts-loader": "^2.3.7",
"ts-node": "^2.1.0",
"tslint": "^4.4.2",
"tslint-eslint-rules": "^3.3.0",
@@ -68,6 +77,10 @@
"peerDependencies": {
"@angular/common": "^2.0.0",
"@angular/core": "^2.0.0",
+ "@ionic/storage": "^1.1.9",
+ "@ionic-native/app-version": "^4.3.1",
+ "@ionic-native/core": "^4.3.1",
+ "@ionic-native/in-app-browser": "^4.3.1",
"rxjs": "^5.0.0-beta.12",
"zone.js": "^0.6.26"
},
diff --git a/src/manup.service.ts b/src/manup.service.ts
index 9f64934..5f8b120 100644
--- a/src/manup.service.ts
+++ b/src/manup.service.ts
@@ -1,174 +1,172 @@
-import { TranslateService } from '@ngx-translate/core';
-import { ManUpConfig } from './manup.config';
-import { AlertController, Platform } from 'ionic-angular';
+import 'rxjs/add/observable/fromPromise';
+import 'rxjs/add/operator/map';
+
+import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
import { Http } from '@angular/http';
-import { Injectable, Optional } from '@angular/core';
-import { AppVersion, InAppBrowser } from 'ionic-native';
-import { Observable } from 'rxjs';
+import { AppVersion } from '@ionic-native/app-version';
+import { InAppBrowser } from '@ionic-native/in-app-browser';
import { Storage } from '@ionic/storage';
+import { AlertController, Platform } from 'ionic-angular';
+import { Observable } from 'rxjs';
+import * as semver from 'semver';
import { i18n } from './i18n';
+import { ManUpConfig } from './manup.config';
-import 'rxjs/add/operator/map';
-import 'rxjs/add/observable/fromPromise';
-
-import * as semver from 'semver';
+/**
+ * DI InjectionToken for optional ngx-translate
+ */
+export const TRANSLATE_SERVICE: any = new InjectionToken('manup:translate');
-const STORAGE_KEY='com.nextfaze.ionic-manup';
+const STORAGE_KEY = 'com.nextfaze.ionic-manup';
/**
* The types of alerts we may present
*/
export enum AlertType {
- /**
+ /**
* A mandatory update is required
*/
- MANDATORY,
+ MANDATORY,
- /**
+ /**
* An optional update is available
*/
- OPTIONAL,
+ OPTIONAL,
- /**
+ /**
* The app is disabled
*/
- MAINTENANCE,
+ MAINTENANCE,
- /**
+ /**
* Nothing to see here
*/
- NOP
+ NOP
}
export interface PlatformData {
- minimum: string,
- latest: string,
- url: string,
- enabled: boolean
+ minimum: string;
+ latest: string;
+ url: string;
+ enabled: boolean;
}
/**
* What the metadata object should look like
*/
export interface ManUpData {
- ios?: PlatformData;
- android?: PlatformData;
- windows?: PlatformData;
+ ios?: PlatformData;
+ android?: PlatformData;
+ windows?: PlatformData;
}
@Injectable()
export class ManUpService {
- /**
- * A local reference to Ionic Native's AppVersion class.
- * Stored locally so mocks can be injected in for testing.
- *
- * @type {*}
- * @memberOf ManUpService
- */
- public AppVersion: any = AppVersion;
-
- public constructor(private config: ManUpConfig,
- private http: Http,
- private alert: AlertController,
- private platform: Platform,
- @Optional() private translate: TranslateService,
- @Optional() private storage: Storage) {
-
- // load the translations unless we've been told not to
- if (this.translate && !this.config.externalTranslations) {
- for (let lang of i18n) {
- this.translate.setTranslation(lang.lang, lang.translations, true);
- }
- }
+ public constructor(
+ private config: ManUpConfig,
+ private http: Http,
+ private alert: AlertController,
+ private platform: Platform,
+ private iab: InAppBrowser,
+ private AppVersion: AppVersion,
+ @Optional()
+ @Inject(TRANSLATE_SERVICE)
+ private translate: any,
+ @Optional() private storage: Storage
+ ) {
+ // load the translations unless we've been told not to
+ if (this.translate && !this.config.externalTranslations) {
+ for (let lang of i18n) {
+ this.translate.setTranslation(lang.lang, lang.translations, true);
+ }
}
+ }
- /**
+ /**
* True if there is an alert already displayed. Used to prevent multiple alerts
* being presented on top of one another
*/
- private inProgress: boolean = false;
+ private inProgress: boolean = false;
- /**
+ /**
* A reference to the current unresolved promise
*/
- private currentPromise: Promise;
+ private currentPromise: Promise;
- /**
+ /**
* Begins the manup check process.
*
* @Returns a promise that resolves if the app is able to continue.
*/
- public validate(): Promise {
-
- if (!this.inProgress) {
- this.inProgress = true;
- this.currentPromise = new Promise( (resolve, reject) => {
- this.platform.ready()
- .then( () => {
- this.metadata()
- .map(response => this.getPlatformData(response))
- .subscribe(metadata => {
- this.evaluate(metadata).then(alert => {
- switch (alert) {
- case AlertType.NOP:
- resolve();
- break;
- default:
- return this.presentAlert(alert, metadata);
- }
- },
- error => resolve());
- });
- })
+ public validate(): Promise {
+ if (!this.inProgress) {
+ this.inProgress = true;
+ this.currentPromise = new Promise((resolve, reject) => {
+ this.platform.ready().then(() => {
+ this.metadata()
+ .map(response => this.getPlatformData(response))
+ .subscribe(metadata => {
+ this.evaluate(metadata).then(
+ alert => {
+ switch (alert) {
+ case AlertType.NOP:
+ resolve();
+ break;
+ default:
+ return this.presentAlert(alert, metadata);
+ }
+ },
+ error => resolve()
+ );
});
- }
- return this.currentPromise;
- }
-
- /**
- * Evaluates what kind of update is required, if any.
- *
- * Returns a promise that resolves with an alert type.
- */
- public evaluate(metadata: PlatformData): Promise {
- if (!metadata.enabled) {
- return Promise.resolve(AlertType.MAINTENANCE);
- }
- return this.AppVersion.getVersionNumber().then((version:string) => {
-
- if (semver.lt(version, metadata.minimum)) {
- return AlertType.MANDATORY;
- }
- else if (semver.lt(version, metadata.latest)) {
- return AlertType.OPTIONAL;
- }
- return AlertType.NOP;
});
+ });
}
-
-
- /**
- * Fetches the remote metadata and returns an observable with the json
- */
- public metadata(): Observable {
- return this.http.get(this.config.url).map(response => response.json())
- .map(response => {
- if (this.storage) {
- this.saveMetadata(response).catch( () => {});
- }
- return response;
- })
- .catch(err => {
- if (this.storage) {
- return this.metadataFromStorage();
- }
- return err;
- });
+ return this.currentPromise;
+ }
+
+ /**
+ * Evaluates what kind of update is required, if any.
+ *
+ * Returns a promise that resolves with an alert type.
+ */
+ public evaluate(metadata: PlatformData): Promise {
+ if (!metadata.enabled) {
+ return Promise.resolve(AlertType.MAINTENANCE);
}
+ return this.AppVersion.getVersionNumber().then((version: string) => {
+ if (semver.lt(version, metadata.minimum)) {
+ return AlertType.MANDATORY;
+ } else if (semver.lt(version, metadata.latest)) {
+ return AlertType.OPTIONAL;
+ }
+ return AlertType.NOP;
+ });
+ }
+
+ /**
+ * Fetches the remote metadata and returns an observable with the json
+ */
+ public metadata(): Observable {
+ return this.http
+ .get(this.config.url)
+ .map(response => response.json())
+ .map(response => {
+ if (this.storage) {
+ this.saveMetadata(response).catch(() => {});
+ }
+ return response;
+ })
+ .catch(err => {
+ if (this.storage) {
+ return this.metadataFromStorage();
+ }
+ return err;
+ });
+ }
-
- /**
+ /**
* Gets the version metadata from storage, if available.
*
* @private
@@ -177,16 +175,17 @@ export class ManUpService {
*
* @memberOf ManUpService
*/
- metadataFromStorage(): Observable {
- if (this.storage) {
- return Observable.fromPromise((> this.storage.get(STORAGE_KEY + '.manup'))).map(v=> JSON.parse(v));
- }
- else {
- throw new Error('Storage not configured');
- }
+ metadataFromStorage(): Observable {
+ if (this.storage) {
+ return Observable.fromPromise(>this.storage.get(
+ STORAGE_KEY + '.manup'
+ )).map(v => JSON.parse(v));
+ } else {
+ throw new Error('Storage not configured');
}
+ }
- /**
+ /**
*
* Saves the metadata to storage.
*
@@ -197,33 +196,31 @@ export class ManUpService {
*
* @memberOf ManUpService
*/
- public saveMetadata(metadata: ManUpData): Promise {
- if (this.storage) {
- return this.storage.set(STORAGE_KEY + '.manup', JSON.stringify(metadata));
- }
- else {
- throw new Error('Storage not configured');
- }
+ public saveMetadata(metadata: ManUpData): Promise {
+ if (this.storage) {
+ return this.storage.set(STORAGE_KEY + '.manup', JSON.stringify(metadata));
+ } else {
+ throw new Error('Storage not configured');
}
+ }
- /**
+ /**
* Returns the branch of the metadata relevant to this platform
*/
- public getPlatformData(metadata: ManUpData): PlatformData {
- if (this.platform.is('ios')) {
- return metadata.ios;
- }
- if (this.platform.is('android')) {
- return metadata.android;
- }
- if (this.platform.is('windows')) {
- return metadata.windows;
- }
- throw new Error('Unknown platform');
+ public getPlatformData(metadata: ManUpData): PlatformData {
+ if (this.platform.is('ios')) {
+ return metadata.ios;
}
+ if (this.platform.is('android')) {
+ return metadata.android;
+ }
+ if (this.platform.is('windows')) {
+ return metadata.windows;
+ }
+ throw new Error('Unknown platform');
+ }
-
- /**
+ /**
* Presents an update alert.
*
* @param type The type of alert to show
@@ -231,94 +228,106 @@ export class ManUpService {
*
* @returns A promise that resolves when this whole thing is over.
*/
- private presentAlert(type: AlertType, platformData: any): Promise {
- switch (type) {
- case AlertType.MANDATORY:
- return this.presentMandatoryUpdate(platformData);
+ private presentAlert(type: AlertType, platformData: any): Promise {
+ switch (type) {
+ case AlertType.MANDATORY:
+ return this.presentMandatoryUpdate(platformData);
- case AlertType.OPTIONAL:
- return this.presentOptionalUpdate(platformData);
+ case AlertType.OPTIONAL:
+ return this.presentOptionalUpdate(platformData);
- case AlertType.MAINTENANCE:
- return this.presentMaintenanceMode();
- }
+ case AlertType.MAINTENANCE:
+ return this.presentMaintenanceMode();
}
+ }
- /**
+ /**
* Displays a maintenance mode alert.
*
* @returns a promise that will never resolve, because the app should not continue
*/
- presentMaintenanceMode(): Promise {
- return this.AppVersion.getAppName().then( (name:string) => {
- return new Promise((resolve, reject) => {
- let alert = this.alert.create({
- enableBackdropDismiss: false,
- title: (this.translate) ? this.translate.instant('manup.maintenance.title', {app: name}) : `${name} Unavailable`,
- subTitle: (this.translate) ? this.translate.instant('manup.maintenance.text', {app: name}) : `${name} is currently unavailable. Please check back later`,
- })
- alert.present();
- });
- })
- }
+ presentMaintenanceMode(): Promise {
+ return this.AppVersion.getAppName().then((name: string) => {
+ return new Promise((resolve, reject) => {
+ let alert = this.alert.create({
+ enableBackdropDismiss: false,
+ title: this.translate
+ ? this.translate.instant('manup.maintenance.title', { app: name })
+ : `${name} Unavailable`,
+ subTitle: this.translate
+ ? this.translate.instant('manup.maintenance.text', { app: name })
+ : `${name} is currently unavailable. Please check back later`
+ });
+ alert.present();
+ });
+ });
+ }
- /**
+ /**
* Displays a mandatory update alert.
*
* @returns a promise that will never resolve, because the app should not continue
*/
- presentMandatoryUpdate(platformData: any): Promise {
- return this.AppVersion.getAppName().then( (name:string) => {
- return new Promise((resolve, reject) => {
- let alert = this.alert.create({
- enableBackdropDismiss: false,
- title: (this.translate) ? this.translate.instant('manup.mandatory.title', {app: name}) : "Update Required",
- subTitle: (this.translate) ? this.translate.instant('manup.mandatory.text', {app: name}) : `An update to ${name} is required to continue.`,
- buttons: [
- {
- text: (this.translate) ? this.translate.instant('manup.buttons.update') : 'Update',
- handler: () => {
- new InAppBrowser(platformData.url, '_system');
- return false;
- }
- }
- ]
- })
- alert.present();
- });
+ presentMandatoryUpdate(platformData: any): Promise {
+ return this.AppVersion.getAppName().then((name: string) => {
+ return new Promise((resolve, reject) => {
+ let alert = this.alert.create({
+ enableBackdropDismiss: false,
+ title: this.translate
+ ? this.translate.instant('manup.mandatory.title', { app: name })
+ : 'Update Required',
+ subTitle: this.translate
+ ? this.translate.instant('manup.mandatory.text', { app: name })
+ : `An update to ${name} is required to continue.`,
+ buttons: [
+ {
+ text: this.translate ? this.translate.instant('manup.buttons.update') : 'Update',
+ handler: () => {
+ this.iab.create(platformData.url, '_system');
+ return false;
+ }
+ }
+ ]
});
- }
+ alert.present();
+ });
+ });
+ }
- /**
+ /**
* Displays an optional update alert.
*
* @returns a promise that will resolves if the user selects 'not now'
*/
- presentOptionalUpdate(platformData: any): Promise {
- return this.AppVersion.getAppName().then( (name:string) => {
- return new Promise((resolve, reject) => {
- let alert = this.alert.create({
- enableBackdropDismiss: false,
- title: (this.translate) ? this.translate.instant('manup.optional.title', {app: name}) : "Update Available",
- subTitle: (this.translate) ? this.translate.instant('manup.optional.text', {app: name}) : `An update to ${name} is available. Would you like to update?`,
- buttons: [
- {
- text: (this.translate) ? this.translate.instant('manup.buttons.later') : 'Not Now',
- handler: () => {
- resolve();
- }
- },
- {
- text: (this.translate) ? this.translate.instant('manup.buttons.update') : 'Update',
- handler: () => {
- new InAppBrowser(platformData.url, '_system');
- return false;
- }
- }
- ]
- })
- alert.present();
- });
+ presentOptionalUpdate(platformData: any): Promise {
+ return this.AppVersion.getAppName().then((name: string) => {
+ return new Promise((resolve, reject) => {
+ let alert = this.alert.create({
+ enableBackdropDismiss: false,
+ title: this.translate
+ ? this.translate.instant('manup.optional.title', { app: name })
+ : 'Update Available',
+ subTitle: this.translate
+ ? this.translate.instant('manup.optional.text', { app: name })
+ : `An update to ${name} is available. Would you like to update?`,
+ buttons: [
+ {
+ text: this.translate ? this.translate.instant('manup.buttons.later') : 'Not Now',
+ handler: () => {
+ resolve();
+ }
+ },
+ {
+ text: this.translate ? this.translate.instant('manup.buttons.update') : 'Update',
+ handler: () => {
+ this.iab.create(platformData.url, '_system');
+ return false;
+ }
+ }
+ ]
});
- }
+ alert.present();
+ });
+ });
+ }
}
diff --git a/src/manup.spec.ts b/src/manup.spec.ts
index 5549637..38b5670 100644
--- a/src/manup.spec.ts
+++ b/src/manup.spec.ts
@@ -1,368 +1,409 @@
-import { error } from 'util';
+import 'rxjs/add/observable/of';
+
import { Observable } from 'rxjs/Rx';
-import { AlertType, ManUpService } from './manup.service';
-import { ManUpConfig} from './manup.config';
+import { error } from 'util';
-import 'rxjs/add/observable/of';
+import { ManUpConfig } from './manup.config';
+import { AlertType, ManUpService } from './manup.service';
class MockAppVersion {
- public static getVersionNumber() {
- return Promise.resolve("2.3.4");
- }
+ public static getVersionNumber() {
+ return Promise.resolve('2.3.4');
+ }
}
describe('Manup Spec', function() {
-
- describe('evaluate', function() {
- it('Should return maintenance mode if json says disabled', function(done) {
- let json = {
- minimum: "2.3.4",
- latest: "2.3.4",
- url: "http://example.com",
- enabled: false
- };
-
- let manup = new ManUpService(null, null, null, null, null,null);
- manup.AppVersion = MockAppVersion;
-
- manup.evaluate(json).then(function(alert) {
- expect(alert).toEqual(AlertType.MAINTENANCE);
- done();
- });
- });
- it('Should return mandatory update if app version less than minimum', function(done) {
- let json = {
- minimum: "4.3.4",
- latest: "6.3.4",
- url: "http://example.com",
- enabled: true
- };
-
- let manup = new ManUpService(null, null, null, null, null,null);
- manup.AppVersion = MockAppVersion;
-
- manup.evaluate(json).then(function(alert) {
- expect(alert).toEqual(AlertType.MANDATORY);
- done();
- });
- });
- it('Should return optional update if app version less than latest', function(done) {
- let json = {
- minimum: "2.3.4",
- latest: "6.3.4",
- url: "http://example.com",
- enabled: true
- };
-
- let manup = new ManUpService(null, null, null, null, null,null);
- manup.AppVersion = MockAppVersion;
-
- manup.evaluate(json).then(function(alert) {
- expect(alert).toEqual(AlertType.OPTIONAL);
- done();
- });
- });
- it('Should return nop if app version latest', function(done) {
- let json = {
- minimum: "2.3.4",
- latest: "2.3.4",
- url: "http://example.com",
- enabled: true
- };
-
- let manup = new ManUpService(null, null, null, null, null,null);
- manup.AppVersion = MockAppVersion;
-
- manup.evaluate(json).then(function(alert) {
- expect(alert).toEqual(AlertType.NOP);
- done();
- });
- });
+ describe('evaluate', function() {
+ it('Should return maintenance mode if json says disabled', function(done) {
+ let json = {
+ minimum: '2.3.4',
+ latest: '2.3.4',
+ url: 'http://example.com',
+ enabled: false
+ };
+
+ let manup = new ManUpService(null, null, null, null, null, MockAppVersion, null, null);
+
+ manup.evaluate(json).then(function(alert) {
+ expect(alert).toEqual(AlertType.MAINTENANCE);
+ done();
+ });
});
-
- describe('metadata', function() {
-
- let config: ManUpConfig = {
- url: 'test.example.com'
- }
-
- describe('Http route, no storage configured', () => {
- let mockHttp = {
- get: function(url: string):Observable