removed old blocks page; udpated tests; added test script
This commit is contained in:
parent
3b2e65e5ad
commit
264a379285
@ -1,29 +1,45 @@
|
|||||||
import { InsightApp } from './app.component';
|
import { InsightApp } from './app.component';
|
||||||
import { MenuMock, NavMock, PlatformMock, SplashMock, StatusMock } from '../mocks';
|
import { TestBed, getTestBed, inject, async } from '@angular/core/testing';
|
||||||
|
import { Platform } from 'ionic-angular';
|
||||||
|
import { NavMock } from '../mocks';
|
||||||
import { BroadcastTxPage } from '../pages';
|
import { BroadcastTxPage } from '../pages';
|
||||||
|
import { PopoverController, MenuController } from 'ionic-angular';
|
||||||
let instance: InsightApp = null;
|
import { StatusBar } from '@ionic-native/status-bar';
|
||||||
|
import { SplashScreen } from '@ionic-native/splash-screen';
|
||||||
|
|
||||||
describe('InsightApp', () => {
|
describe('InsightApp', () => {
|
||||||
|
let injector: TestBed;
|
||||||
|
let app: InsightApp;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
instance = new InsightApp((<any> new PlatformMock), (<any> new MenuMock), (<any>new SplashMock()), (<any>new StatusMock()));
|
TestBed.configureTestingModule({
|
||||||
instance['nav'] = (<any>new NavMock());
|
providers: [
|
||||||
|
PopoverController,
|
||||||
|
InsightApp,
|
||||||
|
Platform,
|
||||||
|
MenuController,
|
||||||
|
SplashScreen,
|
||||||
|
StatusBar
|
||||||
|
]
|
||||||
|
});
|
||||||
|
injector = getTestBed();
|
||||||
|
app = injector.get(InsightApp);
|
||||||
|
|
||||||
|
app['nav'] = (<any>new NavMock());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('initializes with four possible pages', () => {
|
it('initializes with three possible pages', () => {
|
||||||
expect(instance['pages'].length).toEqual(4);
|
expect(app['pages'].length).toEqual(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('initializes with a root page', () => {
|
it('initializes with a root page', () => {
|
||||||
expect(instance['rootPage']).not.toBe(null);
|
expect(app['rootPage']).not.toBe(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('opens a page', () => {
|
it('opens a page', () => {
|
||||||
spyOn(instance['menu'], 'close');
|
spyOn(app['menu'], 'close');
|
||||||
spyOn(instance['nav'], 'setRoot');
|
spyOn(app['nav'], 'setRoot');
|
||||||
instance.openPage(instance['pages'][1]);
|
app.openPage(app['pages'][1]);
|
||||||
expect(instance['menu']['close']).toHaveBeenCalled();
|
expect(app['menu']['close']).toHaveBeenCalled();
|
||||||
expect(instance['nav'].setRoot).toHaveBeenCalledWith(BroadcastTxPage);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
<ion-header>
|
|
||||||
<head-nav [title]="'Blocks'"></head-nav>
|
|
||||||
</ion-header>
|
|
||||||
|
|
||||||
<ion-content padding>
|
|
||||||
<ion-grid>
|
|
||||||
<ion-row>
|
|
||||||
<ion-col><b>Height</b></ion-col>
|
|
||||||
<ion-col><b>Timestamp</b></ion-col>
|
|
||||||
<ion-col text-right><b>Transactions</b></ion-col>
|
|
||||||
<ion-col><b>Mined By</b></ion-col>
|
|
||||||
<ion-col text-right><b>Size</b></ion-col>
|
|
||||||
</ion-row>
|
|
||||||
<ion-row *ngFor="let block of blocks | async">
|
|
||||||
<ion-col>
|
|
||||||
<a (click)="goToBlock(block.hash)">{{block.height}}</a>
|
|
||||||
</ion-col>
|
|
||||||
<ion-col>
|
|
||||||
{{ block.timestamp * 1000 | date:'medium' }}
|
|
||||||
</ion-col>
|
|
||||||
<ion-col text-right>
|
|
||||||
{{block.transactionCount}}
|
|
||||||
</ion-col>
|
|
||||||
<ion-col>
|
|
||||||
<a *ngIf="block.poolName" href="{{block.url}}">{{block.poolName}}</a>
|
|
||||||
</ion-col>
|
|
||||||
<ion-col text-right>
|
|
||||||
{{ block.size }}
|
|
||||||
</ion-col>
|
|
||||||
</ion-row>
|
|
||||||
</ion-grid>
|
|
||||||
</ion-content>
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
.blocksPage {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
import { ComponentFixture, async } from '@angular/core/testing';
|
|
||||||
import { TestUtils } from '../../test';
|
|
||||||
import { BlocksPage } from './blocksPage';
|
|
||||||
|
|
||||||
let fixture: ComponentFixture<BlocksPage> = null;
|
|
||||||
let instance: any = null;
|
|
||||||
|
|
||||||
describe('Blocks', () => {
|
|
||||||
|
|
||||||
beforeEach(async(() => TestUtils.beforeEachCompiler([BlocksPage]).then(compiled => {
|
|
||||||
fixture = compiled.fixture;
|
|
||||||
instance = compiled.instance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
})));
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
fixture.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('initializes', () => {
|
|
||||||
expect(instance).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
it('has a search method', () => {
|
|
||||||
spyOn(instance, 'search');
|
|
||||||
instance.search();
|
|
||||||
expect(instance.search).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import { NavController } from 'ionic-angular';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { Block } from '../../models';
|
|
||||||
import { BlocksService } from '../../services';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use BlocksPage from ../blocks/blocks
|
|
||||||
*/
|
|
||||||
@Component({
|
|
||||||
templateUrl: './blocksPage.html'
|
|
||||||
})
|
|
||||||
export class BlocksPage {
|
|
||||||
|
|
||||||
public title: string;
|
|
||||||
public blocks: Observable<Block[]>;
|
|
||||||
|
|
||||||
constructor(private navCtrl: NavController, private blocksService: BlocksService) {
|
|
||||||
// TODO Put loading spinner on page
|
|
||||||
|
|
||||||
this.title = 'Blocks';
|
|
||||||
this.blocks = blocksService.latestBlocks;
|
|
||||||
this.blocks.subscribe((blocks) => {
|
|
||||||
console.log('blocks', blocks);
|
|
||||||
});
|
|
||||||
blocksService.getLatestBlocks();
|
|
||||||
}
|
|
||||||
|
|
||||||
public goToBlock(blockHash: string): void {
|
|
||||||
this.navCtrl.push('block-detail', {
|
|
||||||
'blockHash': blockHash
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -20,7 +20,7 @@ export class CurrencyProvider {
|
|||||||
private loading: boolean;
|
private loading: boolean;
|
||||||
|
|
||||||
constructor(public http: Http, private api: ApiProvider) {
|
constructor(public http: Http, private api: ApiProvider) {
|
||||||
this.defaultCurrency = 'BCH';
|
this.defaultCurrency = 'BTC';
|
||||||
this.currencySymbol = this.defaultCurrency;
|
this.currencySymbol = this.defaultCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,8 @@
|
|||||||
"postinstall": "run-s install-app",
|
"postinstall": "run-s install-app",
|
||||||
"install-app": "cd app && npm install",
|
"install-app": "cd app && npm install",
|
||||||
"start": "run-s watch-app",
|
"start": "run-s watch-app",
|
||||||
"watch-app": "cd app && npm start"
|
"watch-app": "cd app && npm start",
|
||||||
|
"test": "cd app && ng test --code-coverage"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user