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
4 changed files
with
101 additions
and
3 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
55 changes: 53 additions & 2 deletions
55
www/md_base/src/app/common/directives/builditem/builditem.spec.coffee
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 |
---|---|---|
@@ -1,12 +1,63 @@ | ||
beforeEach module 'app' | ||
|
||
describe 'panel', -> | ||
describe 'builditem', -> | ||
|
||
$rootScope = $compile = null | ||
$rootScope = $compile = $httpBackend = buildbotService = null | ||
|
||
injected = ($injector) -> | ||
$compile = $injector.get('$compile') | ||
$rootScope = $injector.get('$rootScope') | ||
$httpBackend = $injector.get('$httpBackend') | ||
decorateHttpBackend($httpBackend) | ||
mqService = $injector.get('mqService') | ||
$q = $injector.get('$q') | ||
spyOn(mqService,"setBaseUrl").and.returnValue(null) | ||
spyOn(mqService,"startConsuming").and.returnValue($q.when( -> )) | ||
spyOn(mqService,"stopConsuming").and.returnValue(null) | ||
buildbotService = $injector.get('buildbotService') | ||
|
||
beforeEach inject injected | ||
|
||
it 'should display a build correctly', -> | ||
$rootScope.showBuilder = true | ||
|
||
$httpBackend.expectDataGET('builds/1') | ||
buildbotService.one('builds', 1).bind($rootScope) | ||
$httpBackend.flush() | ||
|
||
build = $rootScope.build | ||
build.started_at = (new Date()).getTime() / 1000 - 3600 | ||
|
||
$httpBackend.expectDataGET('builders/1') | ||
$httpBackend.expectGETSVGIcons() | ||
elem = $compile('<build-item build="build" show-builder="showBuilder">')($rootScope) | ||
$rootScope.$digest() | ||
$httpBackend.flush() | ||
|
||
innerRow = elem.children().eq(0) | ||
expect(innerRow.children().length).toBe(4) | ||
|
||
builderName = innerRow.children().eq(1).text().trim() | ||
buildNumber = innerRow.children().eq(2).text().trim() | ||
date = innerRow.children().eq(3).text().trim() | ||
|
||
expect(builderName).toBe('11') | ||
expect(buildNumber).toBe('#' + $rootScope.build.number) | ||
expect(date).toBe('an hour ago') | ||
|
||
it 'should able to hide builder name', -> | ||
$rootScope.showBuilder = false | ||
|
||
$httpBackend.expectDataGET('builds/1') | ||
buildbotService.one('builds', 1).bind($rootScope) | ||
$httpBackend.flush() | ||
|
||
$httpBackend.expectGETSVGIcons() | ||
elem = $compile('<build-item build="build" show-builder="showBuilder">')($rootScope) | ||
$rootScope.$digest() | ||
|
||
innerRow = elem.children().eq(0) | ||
expect(innerRow.children().length).toBe(3) | ||
expect(innerRow.children()[0].tagName.toLowerCase()).toBe('build-status') | ||
expect(innerRow.children().eq(1).hasClass('number')).toBe(true) | ||
expect(innerRow.children().eq(2).hasClass('time')).toBe(true) |
2 changes: 1 addition & 1 deletion
2
www/md_base/src/app/common/directives/buildstatus/buildstatus.spec.coffee
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
46 changes: 46 additions & 0 deletions
46
www/md_base/src/app/home/panels/recent_builds/recent_builds.spec.coffee
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,46 @@ | ||
beforeEach module 'app' | ||
|
||
describe 'recent builds', -> | ||
|
||
$rootScope = $compile = $httpBackend = null | ||
|
||
injected = ($injector) -> | ||
$compile = $injector.get('$compile') | ||
$rootScope = $injector.get('$rootScope') | ||
$httpBackend = $injector.get('$httpBackend') | ||
$q = $injector.get('$q') | ||
mqService = $injector.get('mqService') | ||
spyOn(mqService,"setBaseUrl").and.returnValue(null) | ||
spyOn(mqService,"startConsuming").and.returnValue($q.when( -> )) | ||
spyOn(mqService,"stopConsuming").and.returnValue(null) | ||
decorateHttpBackend($httpBackend) | ||
|
||
beforeEach inject injected | ||
|
||
it 'should display tiles normally', -> | ||
$httpBackend.expectDataGET('masters') | ||
$httpBackend.expectDataGET('buildslaves') | ||
$httpBackend.expectDataGET('builders') | ||
$httpBackend.expectDataGET('schedulers') | ||
elem = $compile('<overview></overview>')($rootScope) | ||
$httpBackend.flush() | ||
|
||
mastertile = elem.children().eq(0) | ||
count = mastertile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
extra = mastertile.children().eq(2).text().trim() | ||
expect(extra).toBe('0 active.') | ||
|
||
slavetile = elem.children().eq(1) | ||
count = slavetile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
extra = slavetile.children().eq(2).text().trim() | ||
expect(extra).toBe('1 connection.') | ||
|
||
builderstile = elem.children().eq(2) | ||
count = builderstile.children().eq(1).text().trim() | ||
expect(count).toBe('1') | ||
|
||
schedulerstile = elem.children().eq(3) | ||
count = schedulerstile.children().eq(1).text().trim() | ||
expect(count).toBe('1') |