Skip to content

Commit 83ff3aa

Browse files
author
Salma Alam-Naylor
committed
Tests for LearnIndex and PatternsIndex
1 parent 9de778f commit 83ff3aa

File tree

6 files changed

+151
-11
lines changed

6 files changed

+151
-11
lines changed

apps/fretonator-web/src/app/common/header/header.component.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ describe('HeaderComponent', () => {
6363
let home: DebugElement;
6464
let learn: DebugElement;
6565
let about: DebugElement;
66+
let contact: DebugElement;
67+
let donate: DebugElement;
6668

6769
beforeEach(() => {
6870
const links = fixture.debugElement.queryAll(selectors.links);
6971
home = links[0];
7072
learn = links[1];
7173
about = links[2];
74+
contact = links[3];
75+
donate = links[3];
7276
});
7377

7478
it('Home should link to /', () => {
@@ -82,6 +86,10 @@ describe('HeaderComponent', () => {
8286
it('About should link to /about', () => {
8387
expect(about.properties.href).toBe('/about');
8488
});
89+
90+
it('Contact should link to /contact', () => {
91+
expect(contact.properties.href).toBe('/contact');
92+
});
8593
});
8694

8795
describe('toggleMenu()', () => {

apps/fretonator-web/src/app/pages/home/home-index/__snapshots__/home-index.component.spec.ts.snap

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ exports[`HomeIndexComponent should create 1`] = `
347347
</h5>
348348
<app-fretboard>
349349
350+
350351
<div
351352
class="fretboard__toggle"
352353
>
@@ -1041,6 +1042,78 @@ exports[`HomeIndexComponent should create 1`] = `
10411042
/>
10421043
10431044
</div>
1045+
<div
1046+
class="fretboard"
1047+
>
1048+
1049+
1050+
1051+
<span
1052+
class="fretboard__help"
1053+
data-fret="0"
1054+
/>
1055+
1056+
<span
1057+
class="fretboard__help"
1058+
data-fret="1"
1059+
/>
1060+
1061+
<span
1062+
class="fretboard__help"
1063+
data-fret="2"
1064+
/>
1065+
1066+
<span
1067+
class="fretboard__help"
1068+
data-fret="3"
1069+
/>
1070+
1071+
<span
1072+
class="fretboard__help"
1073+
data-fret="4"
1074+
/>
1075+
1076+
<span
1077+
class="fretboard__help"
1078+
data-fret="5"
1079+
/>
1080+
1081+
<span
1082+
class="fretboard__help"
1083+
data-fret="6"
1084+
/>
1085+
1086+
<span
1087+
class="fretboard__help"
1088+
data-fret="7"
1089+
/>
1090+
1091+
<span
1092+
class="fretboard__help"
1093+
data-fret="8"
1094+
/>
1095+
1096+
<span
1097+
class="fretboard__help"
1098+
data-fret="9"
1099+
/>
1100+
1101+
<span
1102+
class="fretboard__help"
1103+
data-fret="10"
1104+
/>
1105+
1106+
<span
1107+
class="fretboard__help"
1108+
data-fret="11"
1109+
/>
1110+
1111+
<span
1112+
class="fretboard__help"
1113+
data-fret="12"
1114+
/>
1115+
1116+
</div>
10441117
</div>
10451118
<h4
10461119
class="fretonator__playCta"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`LearnIndexComponent should create 1`] = `LearnIndexComponentSpec {}`;
Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { LearnIndexComponent } from './learn-index.component';
4+
import { Component } from '@angular/core';
5+
import { LearnModule } from '../learn.module';
6+
import { RouterTestingModule } from '@angular/router/testing';
47

5-
xdescribe('LearnIndexComponent', () => {
6-
let component: LearnIndexComponent;
7-
let fixture: ComponentFixture<LearnIndexComponent>;
8+
describe('LearnIndexComponent', () => {
9+
@Component({
10+
selector: 'app-learn-index-spec',
11+
template: `
12+
<app-learn-index></app-learn-index>
13+
`
14+
})
15+
class LearnIndexComponentSpec {
16+
}
17+
let component: LearnIndexComponentSpec;
18+
let fixture: ComponentFixture<LearnIndexComponentSpec>;
819

920
beforeEach(async(() => {
1021
TestBed.configureTestingModule({
11-
declarations: [ LearnIndexComponent ]
22+
declarations: [ LearnIndexComponentSpec ],
23+
imports: [
24+
LearnModule,
25+
RouterTestingModule
26+
]
1227
})
1328
.compileComponents();
1429
}));
1530

1631
beforeEach(() => {
17-
fixture = TestBed.createComponent(LearnIndexComponent);
32+
fixture = TestBed.createComponent(LearnIndexComponentSpec);
1833
component = fixture.componentInstance;
1934
fixture.detectChanges();
2035
});
2136

2237
it('should create', () => {
2338
expect(component).toBeTruthy();
39+
expect(component).toMatchSnapshot();
2440
});
2541
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`PatternsIndexComponent should create 1`] = `PatternsIndexComponentSpec {}`;
Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,62 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22

33
import { PatternsIndexComponent } from './patterns-index.component';
4+
import { Component, DebugElement } from '@angular/core';
5+
import { LearnModule } from '../learn.module';
6+
import { By } from '@angular/platform-browser';
47

5-
xdescribe('PatternsIndexComponent', () => {
6-
let component: PatternsIndexComponent;
7-
let fixture: ComponentFixture<PatternsIndexComponent>;
8+
describe('PatternsIndexComponent', () => {
9+
const selectors = {
10+
chip: By.css('.chip')
11+
};
12+
const classNames = {
13+
activeChip: 'chip--active'
14+
};
15+
16+
@Component({
17+
selector: 'app-patterns-index-spec',
18+
template: `
19+
<app-patterns-index></app-patterns-index>
20+
`
21+
})
22+
class PatternsIndexComponentSpec {
23+
}
24+
25+
let component: PatternsIndexComponentSpec;
26+
let fixture: ComponentFixture<PatternsIndexComponentSpec>;
827

928
beforeEach(async(() => {
1029
TestBed.configureTestingModule({
11-
declarations: [ PatternsIndexComponent ]
30+
declarations: [PatternsIndexComponentSpec],
31+
imports: [
32+
LearnModule
33+
]
1234
})
13-
.compileComponents();
35+
.compileComponents();
1436
}));
1537

1638
beforeEach(() => {
17-
fixture = TestBed.createComponent(PatternsIndexComponent);
39+
fixture = TestBed.createComponent(PatternsIndexComponentSpec);
1840
component = fixture.componentInstance;
1941
fixture.detectChanges();
2042
});
2143

2244
it('should create', () => {
2345
expect(component).toBeTruthy();
46+
expect(component).toMatchSnapshot();
47+
});
48+
49+
describe('setPattern,', () => {
50+
let chip: DebugElement;
51+
52+
beforeEach(() => {
53+
chip = fixture.debugElement.queryAll(selectors.chip)[1];
54+
chip.nativeElement.click();
55+
fixture.detectChanges();
56+
});
57+
58+
it('should activate the clicked chip', () => {
59+
expect(chip.classes[classNames.activeChip]).toBeTruthy();
60+
});
2461
});
2562
});

0 commit comments

Comments
 (0)