diff --git a/package.json b/package.json index dacc809..5e9ec46 100755 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "i18n": "rm -Rf src/assets/i18n && mkdir src/assets/i18n && cp node_modules/tw-i18n/lang/*.json src/assets/i18n", "twwatches": "rm -Rf src/assets/watches && mkdir src/assets/watches && cp -R node_modules/tw-watches/* src/assets/watches", "prod": "npm run assets && ionic-app-scripts build --prod", - "test": "karma start ./test-config/karma.conf.js", + "test": "karma start ./test-config/karma.conf.js --coverage", "test-ci": "karma start ./test-config/karma.conf.js --single-run --coverage", "e2e": "webdriver-manager update --standalone false --gecko false; protractor ./test-config/protractor.conf.js", "coverage": "codecov -f coverage/*.info" diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index af8b968..b46811c 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { async, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { IonicModule, Platform } from 'ionic-angular'; import { PlatformMock } from '../../test-config/mocks-ionic'; @@ -32,7 +32,6 @@ import { Pipe, PipeTransform } from '@angular/core'; class ApiMock { constructor() { - console.log("constructed"); } } @@ -63,7 +62,11 @@ describe('MyApp Component', () => { AnalyticsService, Keyboard ] - }) + }); + + window.open = function(url?: string, target?: string, features?: string, replace?: boolean): Window{ + return window; + } })); beforeEach(() => { @@ -75,4 +78,39 @@ describe('MyApp Component', () => { expect(component instanceof MyApp).toBe(true); }); + it('should open intagram', () => { + expect(component.intagram()).toBeUndefined(); + }); + + it('should open pinterest', () => { + expect(component.pinterest()).toBeUndefined(); + }); + + it('should open twitter', () => { + expect(component.twitter()).toBeUndefined(); + }); + + it('should open facebook', () => { + expect(component.facebook()).toBeUndefined(); + }); + + it('should enable the menu controller', fakeAsync(() => { + + MyApp.userLogged.emit(); + tick(); + expect((component as any).menuController).toBeDefined(); + })); + + it('should open the contact form', fakeAsync(() => { + component.contact(); + tick(); + expect((component as any).menuController).toBeDefined(); + })); + + it('should open the beer form', fakeAsync(() => { + component.beer(); + tick(); + expect((component as any).menuController).toBeDefined(); + })); + }); \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ddab541..cb7cfd9 100755 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -66,7 +66,8 @@ export class MyApp { private platform: Platform, private twapi: TwAPIService, private alertController: AlertController, - public menuController: MenuController, + private menuController: MenuController, + private analytics: AnalyticsService, private storage: Storage, private translate: TranslateService, private keyboard: Keyboard, @@ -82,29 +83,29 @@ export class MyApp { keyboard.disableScroll(true); this.menuController.enable(false); + MyApp.userLogged.subscribe( () => { this.menuController.enable(true); } ); + appVersion.getVersionNumber().then( + (version) => { + analytics.appVersion = version; + this.version = version; + } + ).catch( + (err) => { + analytics.appVersion = "0.0.0"; + this.version = "0.0.0"; + } + ); - // AppVersion.getVersionNumber().then( - // (version)=> { - // GAService.appVersion = version; - // this.version = version; - // } - // ).catch( - // (err)=> { - // GAService.appVersion = "0.0.0"; - // this.version = "0.0.0"; - // } - // ); - - // if(platform.is('ios')){ - // GAService.appName = "ios"; - // }else{ - // GAService.appName = "android"; - // } + if (platform.is('ios')) { + analytics.appName = "ios"; + } else { + analytics.appName = "android"; + } }); } @@ -125,20 +126,20 @@ export class MyApp { } contact() { - this.iab.create('https://go.crisp.im/chat/embed/?website_id=-K4rBEcM_Qbt6JrISVzu', '_blank'); + let browser = this.iab.create('https://go.crisp.im/chat/embed/?website_id=-K4rBEcM_Qbt6JrISVzu', '_blank'); /** * Don't do inject if user isn't logged yet */ - // if(GAService.userEmail != null && GAService.userName != null){ + if (this.analytics.userEmail != null && this.analytics.userName != null) { - // let script:string = '' - // + '$crisp.set("user:email", "'+ GAService.userEmail +'");' - // + '$crisp.set("user:nickname", "'+ GAService.userName +'");' - // +'' - // browser.executeScript({code: script}); - // } + let script: string = '' + + '$crisp.set("user:email", "' + this.analytics.userEmail + '");' + + '$crisp.set("user:nickname", "' + this.analytics.userName + '");' + + '' + browser.executeScript({ code: script }); + } this.menuController.close(); } diff --git a/src/assets/watches/package.json b/src/assets/watches/package.json index c04d34b..e37e1e2 100755 --- a/src/assets/watches/package.json +++ b/src/assets/watches/package.json @@ -49,7 +49,7 @@ "/" ], "_resolved": "git+https://github.com/Toolwatchapp/tw-watches.git#a32dbd4b494ff364e3cfda08fd9753bdf6a38917", - "_shasum": "2368333744ddcd458661c649afd55edbc603c75f", + "_shasum": "7afb48249513e6c10981be43e62a3cc2ae67d928", "_shrinkwrap": null, "_spec": "tw-watches@git+https://github.com/Toolwatchapp/tw-watches.git", "_where": "/mnt/dev/1-NodeWorkspace/toolwatch/tw-mobile", diff --git a/src/pages/about/about.spec.ts b/src/pages/about/about.spec.ts new file mode 100644 index 0000000..2dd8ea3 --- /dev/null +++ b/src/pages/about/about.spec.ts @@ -0,0 +1,77 @@ +import { async, TestBed, fakeAsync, tick } from '@angular/core/testing'; +import { IonicModule, Platform } from 'ionic-angular'; + +import { PlatformMock } from '../../../test-config/mocks-ionic'; + +import { AboutPage } from './about'; + +import { StatusBar } from '@ionic-native/status-bar'; +import { SplashScreen } from '@ionic-native/splash-screen'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { HttpModule, Http } from '@angular/http'; +import { IonicStorageModule } from '@ionic/storage'; +import { BrowserModule } from '@angular/platform-browser'; +import { InAppBrowser } from '@ionic-native/in-app-browser'; +import { Keyboard } from '@ionic-native/keyboard'; +import { AppVersion } from '@ionic-native/app-version'; +import { Facebook } from '@ionic-native/facebook'; +import { SocialSharing } from '@ionic-native/social-sharing'; +import { AppRate } from '@ionic-native/app-rate'; + +import { TranslateService, TranslateModule } from '@ngx-translate/core'; + + +import { HeaderComponentModule } from './../../components/header/header.module'; +import { FooterComponentModule } from './../../components/footer/footer.module'; + +import { + TwAPIService, + AnalyticsService, + ConfigurationService +} from 'tw-core'; + + +import { Pipe, PipeTransform } from '@angular/core'; + +class ApiMock { + constructor() { + } +} + +describe('MyApp Component', () => { + let fixture; + let component: AboutPage; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [AboutPage], + imports: [ + IonicModule.forRoot(AboutPage), + TranslateModule.forRoot(), + HeaderComponentModule, + FooterComponentModule, + ], + providers: [ + StatusBar, + SplashScreen, + { provide: Platform, useClass: PlatformMock }, + { provide: TwAPIService, useClass: ApiMock }, + Keyboard, + AppVersion, + StatusBar, + Facebook, + SocialSharing, + AppRate, + InAppBrowser, + AnalyticsService, + Keyboard + ] + }); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AboutPage); + component = fixture.componentInstance; + }); + +}); \ No newline at end of file