mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-27 01:19:52 -04:00
TEST: YAY! Got unit testing to work!...
This commit is contained in:
parent
648e731a3c
commit
6f92321ebf
58
DynamicBibleIonic/angular-cli.json
Normal file
58
DynamicBibleIonic/angular-cli.json
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"project": {
|
||||||
|
"version": "3.0.0-beta.22-1",
|
||||||
|
"name": "Dynamic Bible"
|
||||||
|
},
|
||||||
|
"apps": [
|
||||||
|
{
|
||||||
|
"root": "src",
|
||||||
|
"outDir": "dist",
|
||||||
|
"assets": [
|
||||||
|
"assets"
|
||||||
|
],
|
||||||
|
"index": "index.html",
|
||||||
|
"main": "main.ts",
|
||||||
|
"test": "test.ts",
|
||||||
|
"tsconfig": "tsconfig.test.json",
|
||||||
|
"prefix": "app",
|
||||||
|
"mobile": false,
|
||||||
|
"styles": [
|
||||||
|
"styles.css"
|
||||||
|
],
|
||||||
|
"scripts": [],
|
||||||
|
"environments": {
|
||||||
|
"source": "environments/environment.ts",
|
||||||
|
"dev": "environments/environment.ts",
|
||||||
|
"prod": "environments/environment.prod.ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"addons": [],
|
||||||
|
"packages": [],
|
||||||
|
"e2e": {
|
||||||
|
"protractor": {
|
||||||
|
"config": "./protractor.conf.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"karma": {
|
||||||
|
"config": "./karma.conf.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaults": {
|
||||||
|
"styleExt": "css",
|
||||||
|
"prefixInterfaces": false,
|
||||||
|
"inline": {
|
||||||
|
"style": false,
|
||||||
|
"template": false
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"class": false,
|
||||||
|
"component": true,
|
||||||
|
"directive": true,
|
||||||
|
"module": false,
|
||||||
|
"pipe": true,
|
||||||
|
"service": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,42 +1,41 @@
|
|||||||
module.exports = function (config)
|
module.exports = function (config) {
|
||||||
{
|
|
||||||
config.set({
|
config.set({
|
||||||
basePath: '',
|
basePath: '',
|
||||||
frameworks: ['jasmine', 'karma-typescript'],
|
proxies: {
|
||||||
|
'/data/': '/base/www/data/',
|
||||||
|
},
|
||||||
|
frameworks: ['jasmine', 'angular-cli'],
|
||||||
|
plugins: [
|
||||||
|
require('karma-jasmine'),
|
||||||
|
require('karma-chrome-launcher'),
|
||||||
|
require('karma-remap-istanbul'),
|
||||||
|
require('karma-mocha-reporter'),
|
||||||
|
require('angular-cli/plugins/karma')
|
||||||
|
],
|
||||||
files: [
|
files: [
|
||||||
'./src/**/*.spec.ts'
|
{ pattern: './www/lib/jquery.min.js', watched: false },
|
||||||
|
{ pattern: './www/data/**/*.json', included: false, served: true },
|
||||||
|
{ pattern: './src/test.ts', watched: false },
|
||||||
],
|
],
|
||||||
|
|
||||||
exclude: [
|
|
||||||
],
|
|
||||||
|
|
||||||
preprocessors: {
|
preprocessors: {
|
||||||
'./src/**/*.spec.ts': ['karma-typescript']
|
'./src/test.ts': ['angular-cli']
|
||||||
|
},
|
||||||
|
mime: {
|
||||||
|
'text/x-typescript': ['ts','tsx']
|
||||||
},
|
},
|
||||||
|
|
||||||
typescriptPreprocessor: {
|
angularCli: {
|
||||||
options: {
|
config: './angular-cli.json',
|
||||||
sourceMap: false,
|
environment: 'dev'
|
||||||
target: 'ES5',
|
|
||||||
module: 'amd',
|
|
||||||
noImplicitAny: true,
|
|
||||||
noResolve: true,
|
|
||||||
removeComments: true,
|
|
||||||
concatenateOutput: false
|
|
||||||
},
|
},
|
||||||
transformPath: function (path)
|
reporters: config.angularCli && config.angularCli.codeCoverage
|
||||||
{
|
? ['mocha', 'karma-remap-istanbul']
|
||||||
return path.replace(/\.ts$/, '.js');
|
: ['mocha'],
|
||||||
}
|
|
||||||
},
|
|
||||||
reporters: ['progress', 'karma-typescript'],
|
|
||||||
port: 9876,
|
port: 9876,
|
||||||
colors: true,
|
colors: true,
|
||||||
logLevel: config.LOG_DEBUG,
|
logLevel: config.LOG_INFO,
|
||||||
autoWatch: true,
|
autoWatch: true,
|
||||||
browsers: ['Chrome'],
|
browsers: ['Chrome'],
|
||||||
singleRun: false,
|
singleRun: false
|
||||||
concurrency: Infinity
|
});
|
||||||
})
|
};
|
||||||
}
|
|
@ -12,7 +12,9 @@
|
|||||||
"build": "ionic-app-scripts build",
|
"build": "ionic-app-scripts build",
|
||||||
"ionic:build": "ionic-app-scripts build",
|
"ionic:build": "ionic-app-scripts build",
|
||||||
"ionic:serve": "ionic-app-scripts serve",
|
"ionic:serve": "ionic-app-scripts serve",
|
||||||
"test": "karma start karma.conf.js"
|
"start": "ionic serve",
|
||||||
|
"test": "ng test",
|
||||||
|
"test-coverage": "ng test --code-coverage"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "2.2.1",
|
"@angular/common": "2.2.1",
|
||||||
@ -29,18 +31,29 @@
|
|||||||
"ionic-angular": "2.0.0-rc.4",
|
"ionic-angular": "2.0.0-rc.4",
|
||||||
"ionic-native": "2.2.11",
|
"ionic-native": "2.2.11",
|
||||||
"ionicons": "3.0.0",
|
"ionicons": "3.0.0",
|
||||||
"jasmine-core": "^2.5.2",
|
|
||||||
"karma": "^1.3.0",
|
|
||||||
"karma-chrome-launcher": "^2.0.0",
|
|
||||||
"karma-jasmine": "^1.1.0",
|
|
||||||
"karma-typescript": "^2.1.5",
|
|
||||||
"rxjs": "5.0.0-beta.12",
|
"rxjs": "5.0.0-beta.12",
|
||||||
"zone.js": "0.6.26"
|
"zone.js": "0.6.26"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ionic/app-scripts": "0.0.47",
|
"@ionic/app-scripts": "0.0.47",
|
||||||
"karma": "^1.3.0",
|
"@types/jasmine": "2.5.38",
|
||||||
"typescript": "2.0.9"
|
"@types/node": "6.0.42",
|
||||||
|
"angular-cli": "1.0.0-beta.24",
|
||||||
|
"codecov": "1.0.1",
|
||||||
|
"jasmine-core": "2.5.2",
|
||||||
|
"jasmine-spec-reporter": "2.7.0",
|
||||||
|
"karma": "1.3.0",
|
||||||
|
"karma-chrome-launcher": "2.0.0",
|
||||||
|
"karma-cli": "1.0.1",
|
||||||
|
"karma-jasmine": "1.1.0",
|
||||||
|
"karma-mocha-reporter": "2.2.1",
|
||||||
|
"karma-remap-istanbul": "0.2.2",
|
||||||
|
"protractor": "4.0.13",
|
||||||
|
"protractor-jasmine2-screenshot-reporter": "0.3.2",
|
||||||
|
"ts-node": "1.7.2",
|
||||||
|
"tslint": "4.1.1",
|
||||||
|
"tslint-eslint-rules": "3.2.0",
|
||||||
|
"typescript": "2.0.10"
|
||||||
},
|
},
|
||||||
"cordovaPlugins": [
|
"cordovaPlugins": [
|
||||||
"cordova-plugin-whitelist",
|
"cordova-plugin-whitelist",
|
||||||
|
32
DynamicBibleIonic/protractor.conf.js
Normal file
32
DynamicBibleIonic/protractor.conf.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Protractor configuration file, see link for more information
|
||||||
|
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
|
||||||
|
|
||||||
|
/*global jasmine */
|
||||||
|
var SpecReporter = require('jasmine-spec-reporter');
|
||||||
|
|
||||||
|
exports.config = {
|
||||||
|
allScriptsTimeout: 11000,
|
||||||
|
specs: [
|
||||||
|
'./e2e/**/*.e2e-spec.ts'
|
||||||
|
],
|
||||||
|
capabilities: {
|
||||||
|
'browserName': 'chrome'
|
||||||
|
},
|
||||||
|
directConnect: true,
|
||||||
|
baseUrl: 'http://localhost:8100/',
|
||||||
|
framework: 'jasmine',
|
||||||
|
jasmineNodeOpts: {
|
||||||
|
showColors: true,
|
||||||
|
defaultTimeoutInterval: 30000,
|
||||||
|
print: function() {}
|
||||||
|
},
|
||||||
|
useAllAngular2AppRoots: true,
|
||||||
|
beforeLaunch: function() {
|
||||||
|
require('ts-node').register({
|
||||||
|
project: 'e2e'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onPrepare: function() {
|
||||||
|
jasmine.getEnv().addReporter(new SpecReporter());
|
||||||
|
}
|
||||||
|
};
|
38
DynamicBibleIonic/src/Reference.spec.ts
Normal file
38
DynamicBibleIonic/src/Reference.spec.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { Reference } from './Reference';
|
||||||
|
|
||||||
|
describe('Reference', () => {
|
||||||
|
|
||||||
|
it('Should parse the reference: Gen 1:1', () => {
|
||||||
|
let ref = new Reference("Gen 1:1").toString();
|
||||||
|
expect(ref).toBe('Genesis 1:1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: Gen 1:1-11', () => {
|
||||||
|
let ref = new Reference("Gen 1:1-11").toString();
|
||||||
|
expect(ref).toBe('Genesis 1:1 - 11');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: Gen 1-2', () => {
|
||||||
|
let ref = new Reference("Gen 1-2").toString();
|
||||||
|
expect(ref).toBe('Genesis 1:1 - 2:*');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: John 3:16', () => {
|
||||||
|
let ref = new Reference("John 3:16").toString();
|
||||||
|
expect(ref).toBe('John 3:16');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: John 3-6', () => {
|
||||||
|
let ref = new Reference("Jn 3-6").toString();
|
||||||
|
expect(ref).toBe('John 3:1 - 6:*');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: 1 Corinthians 3:5-6:5', () => {
|
||||||
|
let ref = new Reference("1 Corinthians 3:5-6:5").toString();
|
||||||
|
expect(ref).toBe('1 Corinthians 3:5 - 6:5');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should parse the reference: 2 Samuel 5:5-6:5', () => {
|
||||||
|
expect(new Reference("II sam 5:5-6:5").toString()).toBe('2 Samuel 5:5 - 6:5');
|
||||||
|
});
|
||||||
|
});
|
@ -593,35 +593,41 @@ export class Reference {
|
|||||||
|
|
||||||
public toString() {
|
public toString() {
|
||||||
// get the starting book, chapter, verse
|
// get the starting book, chapter, verse
|
||||||
let ref = this.Section.start.bookname.concat(" ").
|
return Reference.toString(this.Section);
|
||||||
concat(this.Section.start.chapter).concat(":").
|
};
|
||||||
concat(this.Section.start.verse);
|
|
||||||
|
|
||||||
if (this.Section.start.chapter == this.Section.end.chapter &&
|
public static toString(section: Section)
|
||||||
this.Section.start.verse == this.Section.end.verse &&
|
{
|
||||||
this.Section.start.book == this.Section.end.book)
|
// get the starting book, chapter, verse
|
||||||
|
let ref = section.start.bookname.concat(" ").
|
||||||
|
concat(section.start.chapter).concat(":").
|
||||||
|
concat(section.start.verse);
|
||||||
|
|
||||||
|
if (section.start.chapter == section.end.chapter &&
|
||||||
|
section.start.verse == section.end.verse &&
|
||||||
|
section.start.book == section.end.book)
|
||||||
{
|
{
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.Section.start.chapter == this.Section.end.chapter &&
|
if (section.start.chapter == section.end.chapter &&
|
||||||
this.Section.start.verse != this.Section.end.verse &&
|
section.start.verse != section.end.verse &&
|
||||||
this.Section.start.book == this.Section.end.book)
|
section.start.book == section.end.book)
|
||||||
{
|
{
|
||||||
return ref.concat(" - ").concat(this.Section.end.verse);
|
return ref.concat(" - ").concat(section.end.verse);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.Section.start.book != this.Section.end.book) {
|
if (section.start.book != section.end.book) {
|
||||||
ref = ref.concat(" - ").concat(this.Section.end.bookname).concat(" ");
|
ref = ref.concat(" - ").concat(section.end.bookname).concat(" ");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ref = ref.concat(" - ");
|
ref = ref.concat(" - ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ref = ref.concat(this.Section.end.chapter).concat(":");
|
ref = ref.concat(section.end.chapter).concat(":");
|
||||||
|
|
||||||
return ref.concat(this.Section.end.verse);
|
return ref.concat(section.end.verse);
|
||||||
};
|
}
|
||||||
|
|
||||||
public static bookName(booknum: number): string {
|
public static bookName(booknum: number): string {
|
||||||
let book = new Array();
|
let book = new Array();
|
||||||
|
69
DynamicBibleIonic/src/bible-service.spec.ts
Normal file
69
DynamicBibleIonic/src/bible-service.spec.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { getTestBed, TestBed, inject } from '@angular/core/testing';
|
||||||
|
import { XHRBackend, BaseRequestOptions, HttpModule, Http, } from '@angular/http';
|
||||||
|
import { MockBackend } from '@angular/http/testing';
|
||||||
|
import { BibleService } from './bible-service';
|
||||||
|
import { Reference } from './Reference';
|
||||||
|
|
||||||
|
describe('Bible Service', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [HttpModule],
|
||||||
|
providers: [
|
||||||
|
BibleService,
|
||||||
|
{
|
||||||
|
provide: Http,
|
||||||
|
useFactory: function (backend, defaultOptions) {
|
||||||
|
return new Http(backend, defaultOptions);
|
||||||
|
},
|
||||||
|
deps: [MockBackend, BaseRequestOptions]
|
||||||
|
},
|
||||||
|
MockBackend,
|
||||||
|
BaseRequestOptions
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should get the verse: Gen 1:1', () => {
|
||||||
|
let svc: BibleService = getTestBed().get(BibleService);
|
||||||
|
let ref = new Reference("Gen 1:1").Section;
|
||||||
|
var r = svc.getResult(ref);
|
||||||
|
|
||||||
|
expect(r.msg).toBe(':)');
|
||||||
|
expect(r.ref).toBe('Genesis 1:1');
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
expect(r.testament).toBe("old");
|
||||||
|
|
||||||
|
expect(r.cs.length).toBe(1);
|
||||||
|
expect(r.cs[0].vss.length).toBe(1);
|
||||||
|
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||||
|
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should get the passage: Gen 1:1-9', () => {
|
||||||
|
let svc: BibleService = getTestBed().get(BibleService);
|
||||||
|
let ref = new Reference("Gen 1:1-9").Section;
|
||||||
|
var r = svc.getResult(ref);
|
||||||
|
|
||||||
|
expect(r.msg).toBe(':)');
|
||||||
|
expect(r.ref).toBe('Genesis 1:1 - 9');
|
||||||
|
expect(r.status).toBe(0);
|
||||||
|
expect(r.testament).toBe("old");
|
||||||
|
|
||||||
|
expect(r.cs.length).toBe(1);
|
||||||
|
expect(r.cs[0].vss.length).toBe(9);
|
||||||
|
expect(r.cs[0].vss[0].w.length).toBe(9);
|
||||||
|
expect(r.cs[0].vss[0].w[0].t).toBe("In the");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return an error status', () => {
|
||||||
|
let svc: BibleService = getTestBed().get(BibleService);
|
||||||
|
let ref = new Reference("Gen 100:1").Section;
|
||||||
|
var r = svc.getResult(ref);
|
||||||
|
|
||||||
|
expect(r.msg).toBe('Unable to retrieve bible passage Genesis 100:1.');
|
||||||
|
expect(r.ref).toBe("Genesis 100:1");
|
||||||
|
expect(r.status).toBe(-1);
|
||||||
|
expect(r.testament).toBe('');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
@ -2,6 +2,7 @@
|
|||||||
/// <reference path="types.ts" />
|
/// <reference path="types.ts" />
|
||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import { Http } from "@angular/http";
|
import { Http } from "@angular/http";
|
||||||
|
import { Reference } from "./Reference";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BibleService
|
export class BibleService
|
||||||
@ -9,6 +10,7 @@ export class BibleService
|
|||||||
chapters: BiblePassage[];
|
chapters: BiblePassage[];
|
||||||
result: BiblePassageResult;
|
result: BiblePassageResult;
|
||||||
count: number = 0;
|
count: number = 0;
|
||||||
|
$: any;
|
||||||
|
|
||||||
constructor(private http: Http)
|
constructor(private http: Http)
|
||||||
{
|
{
|
||||||
@ -23,7 +25,7 @@ export class BibleService
|
|||||||
this.result = {
|
this.result = {
|
||||||
cs: [],
|
cs: [],
|
||||||
testament: "",
|
testament: "",
|
||||||
ref: "",
|
ref: Reference.toString(section),
|
||||||
status: 0,
|
status: 0,
|
||||||
msg: ":)"
|
msg: ":)"
|
||||||
};
|
};
|
||||||
@ -32,7 +34,8 @@ export class BibleService
|
|||||||
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++)
|
for (let i = Number(section.start.chapter); i <= Number(section.end.chapter); i++)
|
||||||
{
|
{
|
||||||
const url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
|
const url = "data/bibles/kjv_strongs/" + section.start.book + "-" + i + ".json";
|
||||||
jQuery.ajax({
|
|
||||||
|
$.ajax({
|
||||||
async: false,
|
async: false,
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
|
66
DynamicBibleIonic/src/mocks.ts
Normal file
66
DynamicBibleIonic/src/mocks.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
// IONIC:
|
||||||
|
|
||||||
|
export class ConfigMock {
|
||||||
|
|
||||||
|
public get(): any {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBoolean(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNumber(): number {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FormMock {
|
||||||
|
public register(): any {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NavMock {
|
||||||
|
|
||||||
|
public pop(): any {
|
||||||
|
return new Promise(function(resolve: Function): void {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public push(): any {
|
||||||
|
return new Promise(function(resolve: Function): void {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public getActive(): any {
|
||||||
|
return {
|
||||||
|
'instance': {
|
||||||
|
'model': 'something',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public setRoot(): any {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PlatformMock {
|
||||||
|
public ready(): any {
|
||||||
|
return new Promise((resolve: Function) => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MenuMock {
|
||||||
|
public close(): any {
|
||||||
|
return new Promise((resolve: Function) => {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
19
DynamicBibleIonic/src/polyfills.ts
Normal file
19
DynamicBibleIonic/src/polyfills.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// This file includes polyfills needed by Angular 2 and is loaded before
|
||||||
|
// the app. You can add your own extra polyfills to this file.
|
||||||
|
import 'core-js/es6/symbol';
|
||||||
|
import 'core-js/es6/object';
|
||||||
|
import 'core-js/es6/function';
|
||||||
|
import 'core-js/es6/parse-int';
|
||||||
|
import 'core-js/es6/parse-float';
|
||||||
|
import 'core-js/es6/number';
|
||||||
|
import 'core-js/es6/math';
|
||||||
|
import 'core-js/es6/string';
|
||||||
|
import 'core-js/es6/date';
|
||||||
|
import 'core-js/es6/array';
|
||||||
|
import 'core-js/es6/regexp';
|
||||||
|
import 'core-js/es6/map';
|
||||||
|
import 'core-js/es6/set';
|
||||||
|
import 'core-js/es6/reflect';
|
||||||
|
|
||||||
|
import 'core-js/es7/reflect';
|
||||||
|
import 'zone.js/dist/zone';
|
14
DynamicBibleIonic/src/test-service.ts
Normal file
14
DynamicBibleIonic/src/test-service.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { Http } from "@angular/http";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TestService
|
||||||
|
{
|
||||||
|
constructor(private http: Http)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
getTest()
|
||||||
|
{
|
||||||
|
return "yes";
|
||||||
|
}
|
||||||
|
}
|
78
DynamicBibleIonic/src/test.ts
Normal file
78
DynamicBibleIonic/src/test.ts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/// <reference path="../typings/browser/ambient/jquery/index.d.ts" />
|
||||||
|
import './polyfills.ts';
|
||||||
|
|
||||||
|
import 'zone.js/dist/long-stack-trace-zone';
|
||||||
|
import 'zone.js/dist/proxy.js';
|
||||||
|
import 'zone.js/dist/sync-test';
|
||||||
|
import 'zone.js/dist/jasmine-patch';
|
||||||
|
import 'zone.js/dist/async-test';
|
||||||
|
import 'zone.js/dist/fake-async-test';
|
||||||
|
|
||||||
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
import { getTestBed, TestBed } from '@angular/core/testing';
|
||||||
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||||
|
import { App, Config, Form, IonicModule, Keyboard, DomController, MenuController, NavController, Platform } from 'ionic-angular';
|
||||||
|
import { ConfigMock } from './mocks';
|
||||||
|
|
||||||
|
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
|
||||||
|
declare var __karma__: any;
|
||||||
|
declare var require: any;
|
||||||
|
|
||||||
|
// Prevent Karma from running prematurely.
|
||||||
|
__karma__.loaded = function (): void {
|
||||||
|
// noop
|
||||||
|
};
|
||||||
|
|
||||||
|
// First, initialize the Angular testing environment.
|
||||||
|
getTestBed().initTestEnvironment(
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting(),
|
||||||
|
);
|
||||||
|
// Then we find all the tests.
|
||||||
|
let context: any = require.context('./', true, /\.spec\.ts/);
|
||||||
|
// And load the modules.
|
||||||
|
context.keys().map(context);
|
||||||
|
// Finally, start Karma to run the tests.
|
||||||
|
__karma__.start();
|
||||||
|
|
||||||
|
export class TestUtils {
|
||||||
|
|
||||||
|
public static beforeEachCompiler(components: Array<any>): Promise<{fixture: any, instance: any}> {
|
||||||
|
return TestUtils.configureIonicTestingModule(components)
|
||||||
|
.compileComponents().then(() => {
|
||||||
|
let fixture: any = TestBed.createComponent(components[0]);
|
||||||
|
return {
|
||||||
|
fixture: fixture,
|
||||||
|
instance: fixture.debugElement.componentInstance,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static configureIonicTestingModule(components: Array<any>): typeof TestBed {
|
||||||
|
return TestBed.configureTestingModule({
|
||||||
|
declarations: [
|
||||||
|
...components,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
App, Platform, Form, Keyboard, DomController, MenuController, NavController,
|
||||||
|
{provide: Config, useClass: ConfigMock},
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
IonicModule,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript
|
||||||
|
public static eventFire(el: any, etype: string): void {
|
||||||
|
if (el.fireEvent) {
|
||||||
|
el.fireEvent('on' + etype);
|
||||||
|
} else {
|
||||||
|
let evObj: any = document.createEvent('Events');
|
||||||
|
evObj.initEvent(etype, true, false);
|
||||||
|
el.dispatchEvent(evObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
DynamicBibleIonic/src/tsconfig.test.json
Normal file
20
DynamicBibleIonic/src/tsconfig.test.json
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"declaration": false,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es2015"
|
||||||
|
],
|
||||||
|
"module": "es2015",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"target": "es5",
|
||||||
|
"outDir": "../dist/out-tsc",
|
||||||
|
"typeRoots": [
|
||||||
|
"../node_modules/@types"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules",
|
"node_modules",
|
||||||
|
"src/**/*.spec.ts",
|
||||||
".tmp"
|
".tmp"
|
||||||
],
|
],
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user