-
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.
feat(items/features): further development
- Loading branch information
1 parent
657b54c
commit 73527c3
Showing
22 changed files
with
664 additions
and
90 deletions.
There are no files selected for viewing
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,24 @@ | ||
import {ElementRef} from 'angular2/core'; | ||
|
||
import {it, inject, injectAsync, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {GraphComponent} from './graph.component'; | ||
|
||
describe('GraphComponent', () => { | ||
beforeEachProviders(() => [ | ||
ElementRef, | ||
|
||
GraphComponent | ||
]); | ||
|
||
|
||
it('should initialise', inject([GraphComponent], (component) => { | ||
expect(component.margin).toBeDefined(); | ||
expect(component.width).toBeDefined(); | ||
expect(component.height).toBeDefined(); | ||
expect(component.abilitiesWidth).toBeDefined(); | ||
expect(component.abilitiesHeight).toBeDefined(); | ||
expect(component.graphWidth).toBeDefined(); | ||
expect(component.graphHeight).toBeDefined(); | ||
})); | ||
}); |
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,13 @@ | ||
import {it, inject, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {ItemComponent} from './item.component'; | ||
|
||
describe('ItemComponent', () => { | ||
beforeEachProviders(() => [ | ||
ItemComponent | ||
]); | ||
|
||
it('should be initialised', inject([ItemComponent], (component) => { | ||
expect(component.item).not.toBeDefined(); | ||
})); | ||
}); |
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,74 @@ | ||
//import {spyOn} from 'jasmine'; | ||
import {it, inject, beforeEachProviders, beforeEach} from 'angular2/testing'; | ||
|
||
import {ItemsComponent} from './items.component'; | ||
|
||
describe('ItemsComponent', () => { | ||
beforeEachProviders(() => [ | ||
ItemsComponent | ||
]); | ||
|
||
beforeEach(inject([ItemsComponent], (component) => { | ||
component.config = { g: [100, 200, 300], gameTime: 200, sampleSize: 20 }; | ||
component.items = [ | ||
{ | ||
'id': 3341, | ||
'gold': { 'total': 0 } | ||
}, | ||
{ | ||
'id': 2003, | ||
'gold': { 'total': 50 } | ||
}, | ||
{ | ||
'id': 2003, | ||
'gold': { 'total': 50 } | ||
} | ||
]; | ||
})); | ||
|
||
it('should update on changes', inject([ItemsComponent], (component) => { | ||
spyOn(component, 'calculateTime'); | ||
spyOn(component, 'bundle'); | ||
expect(component.calculateTime).not.toHaveBeenCalled(); | ||
expect(component.bundle).not.toHaveBeenCalled(); | ||
component.ngOnChanges(); | ||
expect(component.calculateTime).toHaveBeenCalled(); | ||
expect(component.bundle).toHaveBeenCalled(); | ||
})); | ||
|
||
it('should calculate time', inject([ItemsComponent], (component) => { | ||
component.calculateTime(); | ||
expect(component.items[0].time).toBe(0); | ||
expect(component.items[1].time).toBe(5); | ||
expect(component.items[2].time).toBe(5); | ||
})); | ||
|
||
it('should not calculate time', inject([ItemsComponent], (component) => { | ||
component.items = [ | ||
{ | ||
'id': 123, | ||
'gold': { 'total': 400 } | ||
} | ||
]; | ||
component.calculateTime(); | ||
component.bundle(); | ||
expect(component.items[0].time).toBe(-1); | ||
})); | ||
|
||
it('should bundle', inject([ItemsComponent], (component) => { | ||
component.calculateTime(); | ||
component.bundle(); | ||
expect(component.items.length).toBe(2); | ||
expect(component.items[1].bundle).toBe(2); | ||
})); | ||
|
||
it('should not bundle', inject([ItemsComponent], (component) => { | ||
component.items = false; | ||
component.bundle(); | ||
expect(component.items).toBeFalsy(); | ||
|
||
component.items = [{ id: 1, bundle: 1 }, { id: 2, bundle: 1 }]; | ||
component.bundle(); | ||
expect(component.items[0].bundle).toBe(1); | ||
})); | ||
}); |
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,13 @@ | ||
import {it, inject, beforeEachProviders} from 'angular2/testing'; | ||
|
||
import {ItemComponent} from './item.component'; | ||
|
||
describe('ItemComponent', () => { | ||
beforeEachProviders(() => [ | ||
ItemComponent | ||
]); | ||
|
||
it('should be initialised', inject([ItemComponent], (component) => { | ||
expect(component.item).not.toBeDefined(); | ||
})); | ||
}); |
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,22 @@ | ||
import {Component, Input} from 'angular2/core'; | ||
import {NgIf} from 'angular2/common'; | ||
|
||
import {DDragonDirective} from '../../misc/ddragon.directive'; | ||
|
||
@Component({ | ||
selector: 'item', | ||
directives: [NgIf, DDragonDirective], | ||
template: ` | ||
<img [ddragon]="'item/' + item.image.full"> | ||
<div> | ||
<p class="name">{{item.name}}</p> | ||
<div class="gold"> | ||
<img [ddragon]="'ui/gold.png'"> | ||
<p>{{item.gold.total ? item.gold.total : 'Free'}}</p> | ||
</div> | ||
</div>` | ||
}) | ||
|
||
export class ItemComponent { | ||
@Input() item; | ||
} |
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
Oops, something went wrong.