-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
18b9ade
commit d388f44
Showing
18 changed files
with
601 additions
and
145 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
import {it, inject, beforeEach, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {ChampionPipe} from './champion.pipe'; | ||
|
||
|
||
describe('Shop ChampionPipe', () => { | ||
beforeEachProviders(() => [ | ||
ChampionPipe | ||
]); | ||
|
||
let items = []; | ||
let item1 = {}; | ||
let item2 = {}; | ||
let item3 = {}; | ||
|
||
beforeEach(() => { | ||
item1 = { | ||
id: 1, | ||
requiredChampion: 5 | ||
}; | ||
item2 = { | ||
id: 2, | ||
requiredChampion: 3 | ||
}; | ||
item3 = { | ||
id: 3 | ||
}; | ||
items = [item1, item2, item3]; | ||
}); | ||
|
||
it('should filter', inject([ChampionPipe], (pipe) => { | ||
expect(pipe.transform(items, [3])).toHaveEqualContent([item2, item3]); | ||
})); | ||
|
||
it('should not filter null', inject([ChampionPipe], (pipe) => { | ||
expect(pipe.transform(null, [3])).toBe(null); | ||
expect(pipe.transform(items, [null])).toBe(items); | ||
})); | ||
}); |
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,20 @@ | ||
import {Pipe, PipeTransform} from 'angular2/core'; | ||
|
||
@Pipe({ | ||
name: 'champion', | ||
pure: false | ||
}) | ||
|
||
export class ChampionPipe implements PipeTransform { | ||
transform(items: Array<any>, [champion]) { | ||
if (!items || !champion) { | ||
return items; | ||
} | ||
return items.filter((item) => { | ||
if (!item.requiredChampion) { | ||
return true; | ||
} | ||
return item.requiredChampion === champion; | ||
}); | ||
} | ||
} |
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 {it, inject, beforeEach, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {HidePipe} from './hide.pipe'; | ||
|
||
|
||
describe('Shop HidePipe', () => { | ||
beforeEachProviders(() => [ | ||
HidePipe | ||
]); | ||
|
||
let items = []; | ||
let item1 = {}; | ||
let item2 = {}; | ||
let item3 = {}; | ||
|
||
beforeEach(() => { | ||
item1 = { | ||
id: 1, | ||
hideFromAll: true | ||
}; | ||
item2 = { | ||
id: 2, | ||
hideFromAll: false | ||
}; | ||
item3 = { | ||
id: 3 | ||
}; | ||
items = [item1, item2, item3]; | ||
}); | ||
|
||
it('should filter', inject([HidePipe], (pipe) => { | ||
expect(pipe.transform(items)).toHaveEqualContent([item2, item3]); | ||
})); | ||
|
||
it('should not filter null', inject([HidePipe], (pipe) => { | ||
expect(pipe.transform(null)).toBe(null); | ||
})); | ||
}); |
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,17 @@ | ||
import {Pipe, PipeTransform} from 'angular2/core'; | ||
|
||
@Pipe({ | ||
name: 'hide', | ||
pure: false | ||
}) | ||
|
||
export class HidePipe implements PipeTransform { | ||
transform(items: Array<any>) { | ||
if (!items) { | ||
return items; | ||
} | ||
return items.filter((item) => { | ||
return !item.hideFromAll; | ||
}); | ||
} | ||
} |
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,45 @@ | ||
import {it, inject, beforeEach, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {MapPipe} from './map.pipe'; | ||
|
||
|
||
describe('Shop MapPipe', () => { | ||
beforeEachProviders(() => [ | ||
MapPipe | ||
]); | ||
|
||
let items = []; | ||
let item1 = {}; | ||
let item2 = {}; | ||
let item3 = {}; | ||
let item4 = {}; | ||
|
||
beforeEach(() => { | ||
item1 = { | ||
id: 1, | ||
maps: {1: true} | ||
}; | ||
item2 = { | ||
id: 2, | ||
maps: {1: true, 2: true} | ||
}; | ||
item3 = { | ||
id: 3, | ||
maps: {1: false} | ||
}; | ||
item4 = { | ||
id: 4 | ||
}; | ||
items = [item1, item2, item3, item4]; | ||
}); | ||
|
||
it('should filter', inject([MapPipe], (pipe) => { | ||
expect(pipe.transform(items, [2])).toHaveEqualContent([item2]); | ||
expect(pipe.transform(items, [1])).toHaveEqualContent([item1, item2]); | ||
})); | ||
|
||
it('should not filter null', inject([MapPipe], (pipe) => { | ||
expect(pipe.transform(null, [1])).toBe(null); | ||
expect(pipe.transform(items, [null])).toBe(items); | ||
})); | ||
}); |
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,20 @@ | ||
import {Pipe, PipeTransform} from 'angular2/core'; | ||
|
||
@Pipe({ | ||
name: 'map', | ||
pure: false | ||
}) | ||
|
||
export class MapPipe implements PipeTransform { | ||
transform(items: Array<any>, [map]) { | ||
if (!items || !map) { | ||
return items; | ||
} | ||
return items.filter((item) => { | ||
if (!item.maps || item.maps.length <= 0) { | ||
return false; | ||
} | ||
return item.maps[map]; | ||
}); | ||
} | ||
} |
Oops, something went wrong.