mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-26 17:10:11 -04:00
313 lines
14 KiB
TypeScript
313 lines
14 KiB
TypeScript
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('');
|
|
|
|
});
|
|
|
|
|
|
let booknames = [
|
|
{ "abbr": "gen", "actual": "Genesis" },
|
|
{ "abbr": "ge", "actual": "Genesis" },
|
|
{ "abbr": "genesis", "actual": "Genesis" },
|
|
{ "abbr": "gn", "actual": "Genesis" },
|
|
{ "abbr": "exodus", "actual": "Exodus" },
|
|
{ "abbr": "ex", "actual": "Exodus" },
|
|
{ "abbr": "exo", "actual": "Exodus" },
|
|
{ "abbr": "exod", "actual": "Exodus" },
|
|
{ "abbr": "exd", "actual": "Exodus" },
|
|
{ "abbr": "leviticus", "actual": "Leviticus" },
|
|
{ "abbr": "lev", "actual": "Leviticus" },
|
|
{ "abbr": "le", "actual": "Leviticus" },
|
|
{ "abbr": "levi", "actual": "Leviticus" },
|
|
{ "abbr": "lv", "actual": "Leviticus" },
|
|
{ "abbr": "numbers", "actual": "Numbers" },
|
|
{ "abbr": "num", "actual": "Numbers" },
|
|
{ "abbr": "nu", "actual": "Numbers" },
|
|
{ "abbr": "numb", "actual": "Numbers" },
|
|
{ "abbr": "number", "actual": "Numbers" },
|
|
{ "abbr": "deuteronomy", "actual": "Deuteronomy" },
|
|
{ "abbr": "deut", "actual": "Deuteronomy" },
|
|
{ "abbr": "de", "actual": "Deuteronomy" },
|
|
{ "abbr": "dt", "actual": "Deuteronomy" },
|
|
{ "abbr": "deu", "actual": "Deuteronomy" },
|
|
{ "abbr": "joshua", "actual": "Joshua" },
|
|
{ "abbr": "josh", "actual": "Joshua" },
|
|
{ "abbr": "jos", "actual": "Joshua" },
|
|
{ "abbr": "judges", "actual": "Judges" },
|
|
{ "abbr": "jud", "actual": "Judges" },
|
|
{ "abbr": "jdg", "actual": "Judges" },
|
|
{ "abbr": "judg", "actual": "Judges" },
|
|
{ "abbr": "ruth", "actual": "Ruth" },
|
|
{ "abbr": "ru", "actual": "Ruth" },
|
|
{ "abbr": "1 samuel", "actual": "1 Samuel" },
|
|
{ "abbr": "1 sa", "actual": "1 Samuel" },
|
|
{ "abbr": "1 sam", "actual": "1 Samuel" },
|
|
{ "abbr": "1 sml", "actual": "1 Samuel" },
|
|
{ "abbr": "i samuel", "actual": "1 Samuel" },
|
|
{ "abbr": "i sa", "actual": "1 Samuel" },
|
|
{ "abbr": "i sam", "actual": "1 Samuel" },
|
|
{ "abbr": "i sml", "actual": "1 Samuel" },
|
|
{ "abbr": "1st samuel", "actual": "1 Samuel" },
|
|
{ "abbr": "1st sa", "actual": "1 Samuel" },
|
|
{ "abbr": "1st sam", "actual": "1 Samuel" },
|
|
{ "abbr": "1st sml", "actual": "1 Samuel" },
|
|
{ "abbr": "first samuel", "actual": "1 Samuel" },
|
|
{ "abbr": "first sa", "actual": "1 Samuel" },
|
|
{ "abbr": "first sam", "actual": "1 Samuel" },
|
|
{ "abbr": "first sml", "actual": "1 Samuel" },
|
|
{ "abbr": "2 samuel", "actual": "2 Samuel" },
|
|
{ "abbr": "2 sa", "actual": "2 Samuel" },
|
|
{ "abbr": "2 sam", "actual": "2 Samuel" },
|
|
{ "abbr": "2 sml", "actual": "2 Samuel" },
|
|
{ "abbr": "ii samuel", "actual": "2 Samuel" },
|
|
{ "abbr": "ii sa", "actual": "2 Samuel" },
|
|
{ "abbr": "ii sam", "actual": "2 Samuel" },
|
|
{ "abbr": "ii sml", "actual": "2 Samuel" },
|
|
{ "abbr": "2nd samuel", "actual": "2 Samuel" },
|
|
{ "abbr": "2nd sa", "actual": "2 Samuel" },
|
|
{ "abbr": "2nd sam", "actual": "2 Samuel" },
|
|
{ "abbr": "2nd sml", "actual": "2 Samuel" },
|
|
{ "abbr": "second samuel", "actual": "2 Samuel" },
|
|
{ "abbr": "second sa", "actual": "2 Samuel" },
|
|
{ "abbr": "second sam", "actual": "2 Samuel" },
|
|
{ "abbr": "second sml", "actual": "2 Samuel" },
|
|
{ "abbr": "sec samuel", "actual": "2 Samuel" },
|
|
{ "abbr": "sec sa", "actual": "2 Samuel" },
|
|
{ "abbr": "sec sam", "actual": "2 Samuel" },
|
|
{ "abbr": "sec sml", "actual": "2 Samuel" },
|
|
{ "abbr": "1 kings", "actual": "1 Kings" },
|
|
{ "abbr": "1 king", "actual": "1 Kings" },
|
|
{ "abbr": "1 kgs", "actual": "1 Kings" },
|
|
{ "abbr": "1 kn", "actual": "1 Kings" },
|
|
{ "abbr": "1 k", "actual": "1 Kings" },
|
|
{ "abbr": "1 ki", "actual": "1 Kings" },
|
|
{ "abbr": "i kings", "actual": "1 Kings" },
|
|
{ "abbr": "i king", "actual": "1 Kings" },
|
|
{ "abbr": "i kgs", "actual": "1 Kings" },
|
|
{ "abbr": "i kn", "actual": "1 Kings" },
|
|
{ "abbr": "i k", "actual": "1 Kings" },
|
|
{ "abbr": "i ki", "actual": "1 Kings" },
|
|
{ "abbr": "1st kings", "actual": "1 Kings" },
|
|
{ "abbr": "1st king", "actual": "1 Kings" },
|
|
{ "abbr": "1st kgs", "actual": "1 Kings" },
|
|
{ "abbr": "1st kn", "actual": "1 Kings" },
|
|
{ "abbr": "1st k", "actual": "1 Kings" },
|
|
{ "abbr": "1st ki", "actual": "1 Kings" },
|
|
{ "abbr": "first kings", "actual": "1 Kings" },
|
|
{ "abbr": "first king", "actual": "1 Kings" },
|
|
{ "abbr": "first kgs", "actual": "1 Kings" },
|
|
{ "abbr": "first kn", "actual": "1 Kings" },
|
|
{ "abbr": "first k", "actual": "1 Kings" },
|
|
{ "abbr": "first ki", "actual": "1 Kings" },
|
|
{ "abbr": "2 Kings", "actual": "2 Kings" },
|
|
{ "abbr": "2 king", "actual": "2 Kings" },
|
|
{ "abbr": "2 kgs", "actual": "2 Kings" },
|
|
{ "abbr": "2 kn", "actual": "2 Kings" },
|
|
{ "abbr": "2 k", "actual": "2 Kings" },
|
|
{ "abbr": "2 ki", "actual": "2 Kings" },
|
|
{ "abbr": "ii kings", "actual": "2 Kings" },
|
|
{ "abbr": "ii king", "actual": "2 Kings" },
|
|
{ "abbr": "ii kgs", "actual": "2 Kings" },
|
|
{ "abbr": "ii kn", "actual": "2 Kings" },
|
|
{ "abbr": "ii k", "actual": "2 Kings" },
|
|
{ "abbr": "ii ki", "actual": "2 Kings" },
|
|
{ "abbr": "2nd kings", "actual": "2 Kings" },
|
|
{ "abbr": "2nd king", "actual": "2 Kings" },
|
|
{ "abbr": "2nd kgs", "actual": "2 Kings" },
|
|
{ "abbr": "2nd kn", "actual": "2 Kings" },
|
|
{ "abbr": "2nd k", "actual": "2 Kings" },
|
|
{ "abbr": "2nd ki", "actual": "2 Kings" },
|
|
{ "abbr": "second kings", "actual": "2 Kings" },
|
|
{ "abbr": "second king", "actual": "2 Kings" },
|
|
{ "abbr": "second kgs", "actual": "2 Kings" },
|
|
{ "abbr": "second kn", "actual": "2 Kings" },
|
|
{ "abbr": "second k", "actual": "2 Kings" },
|
|
{ "abbr": "second ki", "actual": "2 Kings" },
|
|
{ "abbr": "sec kings", "actual": "2 Kings" },
|
|
{ "abbr": "sec king", "actual": "2 Kings" },
|
|
{ "abbr": "sec kgs", "actual": "2 Kings" },
|
|
{ "abbr": "sec kn", "actual": "2 Kings" },
|
|
{ "abbr": "sec k", "actual": "2 Kings" },
|
|
{ "abbr": "sec ki", "actual": "2 Kings" },
|
|
{ "abbr": "2 Chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "2 chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "2 chron", "actual": "2 Chronicles" },
|
|
{ "abbr": "2 ch", "actual": "2 Chronicles" },
|
|
{ "abbr": "2 chr", "actual": "2 Chronicles" },
|
|
{ "abbr": "ii Chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "ii chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "ii chron", "actual": "2 Chronicles" },
|
|
{ "abbr": "ii ch", "actual": "2 Chronicles" },
|
|
{ "abbr": "ii chr", "actual": "2 Chronicles" },
|
|
{ "abbr": "2nd Chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "2nd chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "2nd chron", "actual": "2 Chronicles" },
|
|
{ "abbr": "2nd ch", "actual": "2 Chronicles" },
|
|
{ "abbr": "2nd chr", "actual": "2 Chronicles" },
|
|
{ "abbr": "second Chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "second chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "second chron", "actual": "2 Chronicles" },
|
|
{ "abbr": "second ch", "actual": "2 Chronicles" },
|
|
{ "abbr": "second chr", "actual": "2 Chronicles" },
|
|
{ "abbr": "sec Chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "sec chronicles", "actual": "2 Chronicles" },
|
|
{ "abbr": "sec chron", "actual": "2 Chronicles" },
|
|
{ "abbr": "sec ch", "actual": "2 Chronicles" },
|
|
{ "abbr": "sec chr", "actual": "2 Chronicles" },
|
|
{ "abbr": "1 Chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "1 chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "1 chron", "actual": "1 Chronicles" },
|
|
{ "abbr": "1 ch", "actual": "1 Chronicles" },
|
|
{ "abbr": "1 chr", "actual": "1 Chronicles" },
|
|
{ "abbr": "i Chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "i chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "i chron", "actual": "1 Chronicles" },
|
|
{ "abbr": "i ch", "actual": "1 Chronicles" },
|
|
{ "abbr": "i chr", "actual": "1 Chronicles" },
|
|
{ "abbr": "1st Chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "1st chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "1st chron", "actual": "1 Chronicles" },
|
|
{ "abbr": "1st ch", "actual": "1 Chronicles" },
|
|
{ "abbr": "1st chr", "actual": "1 Chronicles" },
|
|
{ "abbr": "first Chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "first chronicles", "actual": "1 Chronicles" },
|
|
{ "abbr": "first chron", "actual": "1 Chronicles" },
|
|
{ "abbr": "first ch", "actual": "1 Chronicles" },
|
|
{ "abbr": "first chr", "actual": "1 Chronicles" },
|
|
{ "abbr": "ezra", "actual": "Ezra" },
|
|
{ "abbr": "ezr", "actual": "Ezra" },
|
|
{ "abbr": "nehemiah", "actual": "Nehemiah" },
|
|
{ "abbr": "neh", "actual": "Nehemiah" },
|
|
{ "abbr": "ne", "actual": "Nehemiah" },
|
|
{ "abbr": "nehamiah", "actual": "Nehemiah" },
|
|
{ "abbr": "esther", "actual": "Esther" },
|
|
{ "abbr": "est", "actual": "Esther" },
|
|
{ "abbr": "es", "actual": "Esther" },
|
|
{ "abbr": "esth", "actual": "Esther" },
|
|
{ "abbr": "job", "actual": "Job" },
|
|
{ "abbr": "jo", "actual": "Job" },
|
|
{ "abbr": "jb", "actual": "Job" },
|
|
{ "abbr": "psalms", "actual": "Psalm" },
|
|
{ "abbr": "ps", "actual": "Psalm" },
|
|
{ "abbr": "psa", "actual": "Psalm" },
|
|
{ "abbr": "psalm", "actual": "Psalm" },
|
|
{ "abbr": "psm", "actual": "Psalm" },
|
|
{ "abbr": "proverbs", "actual": "Proverbs" },
|
|
{ "abbr": "prov", "actual": "Proverbs" },
|
|
{ "abbr": "pr", "actual": "Proverbs" },
|
|
{ "abbr": "pro", "actual": "Proverbs" },
|
|
{ "abbr": "proverb", "actual": "Proverbs" },
|
|
{ "abbr": "prv", "actual": "Proverbs" },
|
|
{ "abbr": "prvbs", "actual": "Proverbs" },
|
|
{ "abbr": "ecclesiastes", "actual": "Ecclesiastes" },
|
|
{ "abbr": "eccl", "actual": "Ecclesiastes" },
|
|
{ "abbr": "ecc", "actual": "Ecclesiastes" },
|
|
{ "abbr": "eccles", "actual": "Ecclesiastes" },
|
|
{ "abbr": "ec", "actual": "Ecclesiastes" },
|
|
{ "abbr": "ecl", "actual": "Ecclesiastes" },
|
|
{ "abbr": "ecclesiaste", "actual": "Ecclesiastes" },
|
|
{ "abbr": "song of solomon", "actual": "Song of Solomon" },
|
|
{ "abbr": "song of songs", "actual": "Song of Solomon" },
|
|
{ "abbr": "sos", "actual": "Song of Solomon" },
|
|
{ "abbr": "ss", "actual": "Song of Solomon" },
|
|
{ "abbr": "son", "actual": "Song of Solomon" },
|
|
{ "abbr": "so", "actual": "Song of Solomon" },
|
|
{ "abbr": "song", "actual": "Song of Solomon" },
|
|
{ "abbr": "songs", "actual": "Song of Solomon" },
|
|
{ "abbr": "isaiah", "actual": "Isaiah" },
|
|
{ "abbr": "is", "actual": "Isaiah" },
|
|
{ "abbr": "isah", "actual": "Isaiah" },
|
|
{ "abbr": "isai", "actual": "Isaiah" },
|
|
{ "abbr": "ia", "actual": "Isaiah" },
|
|
{ "abbr": "jerimiah", "actual": "Jeremiah" },
|
|
{ "abbr": "jeremiah", "actual": "Jeremiah" },
|
|
{ "abbr": "jer", "actual": "Jeremiah" },
|
|
{ "abbr": "je", "actual": "Jeremiah" },
|
|
{ "abbr": "jere", "actual": "Jeremiah" },
|
|
{ "abbr": "lamentations", "actual": "Lamentations" },
|
|
{ "abbr": "lam", "actual": "Lamentations" },
|
|
{ "abbr": "la", "actual": "Lamentations" },
|
|
{ "abbr": "lamentation", "actual": "Lamentations" },
|
|
];
|
|
|
|
for (let bk of booknames) {
|
|
it('Get Data for: ' + bk.abbr, () => {
|
|
let svc: BibleService = getTestBed().get(BibleService);
|
|
let book = Reference.parseBook(bk.abbr);
|
|
for (let i = 1; i <= book.lastchapter; i++)
|
|
{
|
|
let ref = new Reference(bk.abbr + " "+i).Section;
|
|
var r = svc.getResult(ref);
|
|
|
|
expect(r.msg).toBe(':)');
|
|
expect(r.ref).toBe(book.bookname + " "+i+":1 - *");
|
|
expect(r.status).toBe(0);
|
|
expect(r.cs[0].vss.length).toBeGreaterThan(1);
|
|
}
|
|
});
|
|
}
|
|
});
|