-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
12 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/app/data/poe-ninja/service/currency-overview-http.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { AssetService } from '@app/assets'; | ||
import { TradeLeaguesHttpLeague } from '@data/poe/schema'; | ||
import { CurrencyOverviewHttpService } from './currency-overview-http.service'; | ||
|
||
describe('CurrencyOverviewHttpService', () => { | ||
let sut: CurrencyOverviewHttpService; | ||
|
||
beforeEach(async () => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
CommonModule, | ||
HttpClientModule, | ||
BrowserModule | ||
] | ||
}).compileComponents(); | ||
sut = TestBed.inject<CurrencyOverviewHttpService>(CurrencyOverviewHttpService); | ||
const asset = TestBed.inject<AssetService>(AssetService); | ||
await asset.load().toPromise(); | ||
}); | ||
|
||
const leagueMap = { | ||
[TradeLeaguesHttpLeague.Standard]: 'standard', | ||
[TradeLeaguesHttpLeague.Hardcore]: 'hardcore', | ||
['Harvest']: 'challenge', | ||
['Hardcore Harvest']: 'challengehc', | ||
}; | ||
|
||
Object.keys(leagueMap).forEach(key => { | ||
it(`getLeaguePath('${key}') should be '${leagueMap[key]}'`, () => { | ||
const result = sut.getLeaguePath(key); | ||
expect(result).toBe(leagueMap[key]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/app/data/poe-ninja/service/item-overview-http.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { AssetService } from '@app/assets'; | ||
import { TradeLeaguesHttpLeague } from '@data/poe/schema'; | ||
import { ItemOverviewHttpService } from './item-overview-http.service'; | ||
|
||
describe('ItemOverviewHttpService', () => { | ||
let sut: ItemOverviewHttpService; | ||
|
||
beforeEach(async () => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
CommonModule, | ||
HttpClientModule, | ||
BrowserModule | ||
] | ||
}).compileComponents(); | ||
sut = TestBed.inject<ItemOverviewHttpService>(ItemOverviewHttpService); | ||
const asset = TestBed.inject<AssetService>(AssetService); | ||
await asset.load().toPromise(); | ||
}); | ||
|
||
const leagueMap = { | ||
[TradeLeaguesHttpLeague.Standard]: 'standard', | ||
[TradeLeaguesHttpLeague.Hardcore]: 'hardcore', | ||
['Harvest']: 'challenge', | ||
['Hardcore Harvest']: 'challengehc', | ||
}; | ||
|
||
Object.keys(leagueMap).forEach(key => { | ||
it(`getLeaguePath('${key}') should be '${leagueMap[key]}'`, () => { | ||
const result = sut.getLeaguePath(key); | ||
expect(result).toBe(leagueMap[key]); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { TradeLeaguesHttpLeague } from '@data/poe/schema'; | ||
|
||
export abstract class OverviewHttpService { | ||
protected getLeaguePath(leagueId: string): string { | ||
switch (leagueId) { | ||
case TradeLeaguesHttpLeague.Standard: | ||
return 'standard'; | ||
case TradeLeaguesHttpLeague.Hardcore: | ||
return 'hardcore'; | ||
default: | ||
const exp = new RegExp(`${TradeLeaguesHttpLeague.Hardcore} .*`); | ||
if (exp.exec(leagueId)) { | ||
return 'challengehc'; | ||
} | ||
return 'challenge'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters