This repository was archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Ensure that contributions are valid (#57)
* test: Fixed all the tests in Angular * feat: Validate content in the data.json * build: Added testing to the build script (closes #56)
- Loading branch information
1 parent
39a1aaf
commit 76c41e0
Showing
20 changed files
with
508 additions
and
141 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
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,27 +1,30 @@ | ||
import { TestBed, async } from '@angular/core/testing'; | ||
import { AppComponent } from './app.component'; | ||
import { MapComponent } from './map/map.component'; | ||
import { MenuComponent } from './menu/menu.component'; | ||
import { AgmCoreModule } from '@agm/core'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { CompanyService } from './company.service'; | ||
describe('AppComponent', () => { | ||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
AppComponent | ||
AppComponent, | ||
MapComponent, | ||
MenuComponent, | ||
], | ||
imports: [ | ||
RouterTestingModule.withRoutes([]), | ||
AgmCoreModule.forRoot({ | ||
apiKey: 'AIzaSyDqI3d8iyamjWvFSSGn1XlhTCxTBl6TBrk' | ||
}) | ||
], | ||
providers: [CompanyService] | ||
}).compileComponents(); | ||
})); | ||
it('should create the app', async(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app).toBeTruthy(); | ||
})); | ||
it(`should have as title 'app'`, async(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
const app = fixture.debugElement.componentInstance; | ||
expect(app.title).toEqual('app'); | ||
})); | ||
it('should render title in a h1 tag', async(() => { | ||
const fixture = TestBed.createComponent(AppComponent); | ||
fixture.detectChanges(); | ||
const compiled = fixture.debugElement.nativeElement; | ||
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!'); | ||
})); | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,50 @@ | ||
import {Injectable} from '@angular/core' | ||
import {Injectable} from '@angular/core'; | ||
|
||
import * as data from '../assets/data.json' | ||
import {SponsorshipTiers} from './sponsorship-tiers.enum' | ||
import * as data from '../assets/data.json'; | ||
import {SponsorshipTiers} from './sponsorship-tiers.enum'; | ||
|
||
@Injectable() | ||
export class CompanyService { | ||
|
||
companies | ||
techs | ||
companies; | ||
techs; | ||
|
||
constructor() { | ||
this.companies = data.default || [] | ||
this.companies.sort((a, b) => this.sortCompanies(a, b)) | ||
|
||
// this.techs = Array.from(this.companies.reduce((acc, curr) => { | ||
// curr.technology.forEach(tech => acc.add(tech)) | ||
// return acc | ||
// }, new Set()).values()) | ||
this.companies = data.default.filter(d => !!d) || []; | ||
this.companies.sort((a, b) => this.sortCompanies(a, b)); | ||
this.techs = [].concat.apply([], this.companies.map(c => c.technology)) | ||
.filter((item, pos, self) => self.indexOf(item) == pos) | ||
.filter((item, pos, self) => self.indexOf(item) === pos) | ||
.map(tech => ({ | ||
name: tech, | ||
percentage: Math.round(this.companies.length > 0 ? this.companies.filter(c => c.technology && c.technology.some(t => t === tech)).length / this.companies.length * 100 : 0) | ||
percentage: Math.round( | ||
this.companies.length > 0 ? | ||
this.companies.filter(c => c.technology && c.technology.some(t => t === tech)).length / this.companies.length * 100 : 0 | ||
) | ||
})) | ||
.sort((a,b) => a && b && a.percentage && b.percentage ? b.percentage - a.percentage : 0) | ||
.sort((a, b) => a && b && a.percentage && b.percentage ? b.percentage - a.percentage : 0); | ||
} | ||
|
||
filterByTech(tech) { | ||
this.companies = data.default || [] | ||
this.companies = this.companies.filter(company => company.technology.includes(tech)).sort((a, b) => this.sortCompanies(a, b)) | ||
this.companies = data.default.filter(d => !!d) || []; | ||
this.companies = this.companies.filter(company => company.technology.includes(tech)).sort((a, b) => this.sortCompanies(a, b)); | ||
} | ||
|
||
init() { | ||
this.companies = data.default || [] | ||
this.companies.sort((a, b) => this.sortCompanies(a, b)) | ||
this.companies = data.default.filter(d => !!d) || []; | ||
this.companies.sort((a, b) => this.sortCompanies(a, b)); | ||
} | ||
|
||
filterById(id) { | ||
this.companies = this.companies.filter(company => company.id === id).sort((a, b) => this.sortCompanies(a, b)) | ||
this.companies = this.companies.filter(company => company.id === id).sort((a, b) => this.sortCompanies(a, b)); | ||
} | ||
|
||
sortCompanies(a, b) { | ||
return this.compareTiers(a, b) !== 0 ? | ||
this.compareTiers(a, b) : | ||
a.name.toLowerCase().localeCompare(b.name.toLowerCase()) | ||
a.name.toLowerCase().localeCompare(b.name.toLowerCase()); | ||
} | ||
|
||
compareTiers(a, b) { | ||
return SponsorshipTiers[b.sponsorship as string] - SponsorshipTiers[a.sponsorship as string] | ||
return !!b && !!a ? SponsorshipTiers[b.sponsorship as string] - SponsorshipTiers[a.sponsorship as string] : 0; | ||
} | ||
} |
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
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,27 @@ | ||
export enum IndustryType { | ||
'Agriculture' = 'Agriculture', | ||
'Cloud-based solutions or services' = 'Cloud-based solutions or services', | ||
'Consulting' = 'Consulting', | ||
'Data and analytics' = 'Data and analytics', | ||
'Education and training' = 'Education and training', | ||
'Energy or utilities' = 'Energy or utilities', | ||
'Financial and banking' = 'Financial and banking', | ||
'Government or public administration' = 'Government or public administration', | ||
'Health care or social services' = 'Health care or social services', | ||
'Information technology' = 'Information technology', | ||
'Internet' = 'Internet', | ||
'Manufacturing' = 'Manufacturing', | ||
'Marketing' = 'Marketing', | ||
'Media, advertising, publishing, or entertainment' = 'Media, advertising, publishing, or entertainment', | ||
'Nonprofit' = 'Nonprofit', | ||
'Real estate' = 'Real estate', | ||
'Research - academic or scientific' = 'Research - academic or scientific', | ||
'Retail or ecommerce' = 'Retail or ecommerce', | ||
'Security' = 'Security', | ||
'Software as a service (saas) development' = 'Software as a service (saas) development', | ||
'Software development - other' = 'Software development - other', | ||
'Telecommunications' = 'Telecommunications', | ||
'Transportation' = 'Transportation', | ||
'Travel' = 'Travel', | ||
'Web development or design' = 'Web development or design', | ||
} |
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,5 +1,5 @@ | ||
<agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom"> | ||
<ng-container *ngFor="let d of companyService.companies"> | ||
<agm-marker [iconUrl]="d.sponsorship ? './assets/icons/'+d.sponsorship+'-dot.png' : ''" [zIndex]="getZIndex(d.sponsorship)" [latitude]="d.lat" [longitude]="d.lng" [title]="d.name" (markerClick)="goto(d.id)"></agm-marker> | ||
<agm-marker [iconUrl]="d?.sponsorship ? './assets/icons/'+d?.sponsorship+'-dot.png' : ''" [zIndex]="getZIndex(d?.sponsorship)" [latitude]="d?.lat" [longitude]="d?.lng" [title]="d?.name" (markerClick)="goto(d?.id)"></agm-marker> | ||
</ng-container> | ||
</agm-map> |
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,34 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { CompanyService } from '../company.service'; | ||
import { MapComponent } from './map.component'; | ||
import { AgmCoreModule } from '@agm/core'; | ||
|
||
describe('MapComponent', () => { | ||
let component: MapComponent; | ||
let fixture: ComponentFixture<MapComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
RouterTestingModule.withRoutes([]), | ||
AgmCoreModule.forRoot({ | ||
apiKey: 'AIzaSyDqI3d8iyamjWvFSSGn1XlhTCxTBl6TBrk' | ||
}) | ||
], | ||
declarations: [ MapComponent ], | ||
providers: [CompanyService] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MapComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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,28 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { CompanyService } from '../company.service'; | ||
import { MenuComponent } from './menu.component'; | ||
|
||
describe('MenuComponent', () => { | ||
let component: MenuComponent; | ||
let fixture: ComponentFixture<MenuComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [RouterTestingModule.withRoutes([])], | ||
declarations: [ MenuComponent ], | ||
providers: [CompanyService] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MenuComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.