Skip to content

Commit 24189e1

Browse files
committed
feat: egg test
1 parent 6513bca commit 24189e1

10 files changed

+183
-3
lines changed

Diff for: angular.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,8 @@
102102
}
103103
}
104104
},
105-
"defaultProject": "coolwebsite"
105+
"defaultProject": "coolwebsite",
106+
"cli": {
107+
"analytics": false
108+
}
106109
}

Diff for: src/app/app-routing.module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const routes: Routes = [
1010
{ path: "home", component: HomeComponent },
1111
{ path: "aboutme", component: AboutmeComponent },
1212
{ path: "snek", component: SnekComponent },
13+
{ path: "egg", component: EggComponent },
1314
{ path: "**", redirectTo: "home" }
1415
];
1516

Diff for: src/app/app.module.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ import { HomeComponent } from './home/home.component';
77
import { HeaderComponent } from './header/header.component';
88
import { AboutmeComponent } from './aboutme/aboutme.component';
99
import { SnekComponent } from './snek/snek.component';
10+
import { EggComponent } from './egg/egg.component';
11+
import { HttpClientModule } from '@angular/common/http';
1012

1113
@NgModule({
1214
declarations: [
1315
AppComponent,
1416
HomeComponent,
1517
HeaderComponent,
1618
AboutmeComponent,
17-
SnekComponent
19+
SnekComponent,
20+
EggComponent
1821
],
1922
imports: [
2023
BrowserModule,
21-
AppRoutingModule
24+
AppRoutingModule,
25+
HttpClientModule
2226
],
2327
providers: [],
2428
bootstrap: [AppComponent],

Diff for: src/app/egg/egg.component.css

Whitespace-only changes.

Diff for: src/app/egg/egg.component.html

Whitespace-only changes.

Diff for: src/app/egg/egg.component.spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { EggComponent } from './egg.component';
4+
5+
describe('EggComponent', () => {
6+
let component: EggComponent;
7+
let fixture: ComponentFixture<EggComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ EggComponent ]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(EggComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});

Diff for: src/app/egg/egg.component.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { PageRepositoryService } from '../page-repository.service';
3+
4+
@Component({
5+
selector: 'app-egg',
6+
templateUrl: './egg.component.html',
7+
styleUrls: ['./egg.component.css']
8+
})
9+
export class EggComponent implements OnInit {
10+
content: string = "";
11+
constructor(private pageRepository: PageRepositoryService) { }
12+
13+
ngOnInit(): void {
14+
this.pageRepository.getRandomPage().subscribe(res => {
15+
16+
});
17+
}
18+
19+
}

Diff for: src/app/header/header.component.html

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<button routerLink="/snek">Snek</button>
44
<button><a href="https://github.com/dlanaras" target="_blank">Github</a></button>
55
<button routerLink="/aboutme">About</button>
6+
<button routerLink="/egg">Egg</button>
67
</nav>

Diff for: src/app/page-repository.service.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { PageRepositoryService } from './page-repository.service';
4+
5+
describe('PageRepositoryService', () => {
6+
let service: PageRepositoryService;
7+
8+
beforeEach(() => {
9+
TestBed.configureTestingModule({});
10+
service = TestBed.inject(PageRepositoryService);
11+
});
12+
13+
it('should be created', () => {
14+
expect(service).toBeTruthy();
15+
});
16+
});

Diff for: src/app/page-repository.service.ts

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { Injectable } from '@angular/core';
3+
import { Observable } from 'rxjs';
4+
5+
@Injectable({
6+
providedIn: 'root'
7+
})
8+
export class PageRepositoryService {
9+
private readonly sitesList = [
10+
"https://longdogechallenge.com/",
11+
"https://checkbox.toys/scale/",
12+
"https://paint.toys/",
13+
"https://weirdorconfusing.com/",
14+
"https://binarypiano.com/",
15+
"https://sliding.toys/mystic-square/8-puzzle/",
16+
"https://alwaysjudgeabookbyitscover.com",
17+
"https://puginarug.com",
18+
"https://mondrianandme.com/",
19+
"https://onesquareminesweeper.com/",
20+
"http://floatingqrcode.com/",
21+
"https://cursoreffects.com",
22+
"https://thatsthefinger.com/",
23+
"https://cant-not-tweet-this.com/",
24+
"http://heeeeeeeey.com/",
25+
"http://corndog.io/",
26+
"http://eelslap.com/",
27+
"http://www.staggeringbeauty.com/",
28+
"http://burymewithmymoney.com/",
29+
"https://smashthewalls.com/",
30+
"https://jacksonpollock.org/",
31+
"http://endless.horse/",
32+
"http://drawing.garden/",
33+
"https://www.trypap.com/",
34+
"http://www.republiquedesmangues.fr/",
35+
"http://www.movenowthinklater.com/",
36+
"http://www.rrrgggbbb.com/",
37+
"http://www.koalastothemax.com/",
38+
"http://www.everydayim.com/",
39+
"http://randomcolour.com/",
40+
"http://maninthedark.com/",
41+
"http://cat-bounce.com/",
42+
"http://chrismckenzie.com/",
43+
"https://thezen.zone/",
44+
"http://ninjaflex.com/",
45+
"http://ihasabucket.com/",
46+
"http://corndogoncorndog.com/",
47+
"http://www.hackertyper.com/",
48+
"https://pointerpointer.com",
49+
"https://checkboxrace.com/",
50+
"http://imaninja.com/",
51+
"http://www.partridgegetslucky.com/",
52+
"http://www.ismycomputeron.com/",
53+
"http://www.nullingthevoid.com/",
54+
"http://www.muchbetterthanthis.com/",
55+
"http://www.yesnoif.com/",
56+
"http://lacquerlacquer.com",
57+
"http://potatoortomato.com/",
58+
"http://iamawesome.com/",
59+
"https://strobe.cool/",
60+
"http://thisisnotajumpscare.com/",
61+
"http://doughnutkitten.com/",
62+
"http://crouton.net/",
63+
"http://corgiorgy.com/",
64+
"http://www.wutdafuk.com/",
65+
"http://unicodesnowmanforyou.com/",
66+
"http://chillestmonkey.com/",
67+
"http://scroll-o-meter.club/",
68+
"http://www.crossdivisions.com/",
69+
"http://tencents.info/",
70+
"https://boringboringboring.com/",
71+
"http://www.patience-is-a-virtue.org/",
72+
"http://pixelsfighting.com/",
73+
"http://isitwhite.com/",
74+
"https://existentialcrisis.com/",
75+
"http://onemillionlols.com/",
76+
"http://www.omfgdogs.com/",
77+
"http://oct82.com/",
78+
"http://chihuahuaspin.com/",
79+
"http://www.blankwindows.com/",
80+
"http://tunnelsnakes.com/",
81+
"http://www.trashloop.com/",
82+
"http://www.ascii-middle-finger.com/",
83+
"http://spaceis.cool/",
84+
"http://www.doublepressure.com/",
85+
"http://www.donothingfor2minutes.com/",
86+
"http://buildshruggie.com/",
87+
"http://buzzybuzz.biz/",
88+
"https://paint.toys/calligram/",
89+
"http://yeahlemons.com/",
90+
"http://wowenwilsonquiz.com",
91+
"https://thepigeon.org/",
92+
"http://notdayoftheweek.com/",
93+
"http://www.amialright.com/",
94+
"https://greatbignothing.com/",
95+
"https://zoomquilt.org/",
96+
"https://dadlaughbutton.com/",
97+
"https://remoji.com/",
98+
"http://papertoilet.com/",
99+
"https://loopedforinfinity.com/",
100+
"https://www.bouncingdvdlogo.com/",
101+
"https://findtheinvisiblecow.com/",
102+
]
103+
104+
constructor(private http: HttpClient) { }
105+
106+
public getRandomPage() {
107+
return this.http.get(this.randomPage());
108+
}
109+
110+
private randomPage(): string {
111+
return this.sitesList[Math.floor(Math.random() * this.sitesList.length)];
112+
}
113+
}

0 commit comments

Comments
 (0)