-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from TAMULib/sprint11-staging
Sprint11 staging
- Loading branch information
Showing
52 changed files
with
1,514 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ deploy: | |
github_token: $GITHUB_TOKEN | ||
keep_history: true | ||
on: | ||
branch: master | ||
branch: sprint11-staging |
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
58 changes: 58 additions & 0 deletions
58
projects/wvr-elements/src/lib/core/component-registry.service.spec.ts
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,58 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { WvrBaseComponent } from '../shared/wvr-base.component'; | ||
import { WvrItWorksComponent } from '../wvr-it-works/wvr-it-works.component'; | ||
|
||
import { ComponentRegistryService } from './component-registry.service'; | ||
|
||
describe('ComponentRegistryService', () => { | ||
let service: ComponentRegistryService; | ||
let component: WvrItWorksComponent; | ||
let fixture: ComponentFixture<WvrItWorksComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule], | ||
declarations: [WvrItWorksComponent], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA] | ||
}) | ||
.compileComponents() | ||
.catch(err => { console.error(err); }); | ||
service = TestBed.inject(ComponentRegistryService); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WvrItWorksComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should register a new component', () => { | ||
expect(component.id >= 0) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should retrieve components', () => { | ||
expect(service.getComponent(component.id) === component) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should retrieve components by element', () => { | ||
// tslint:disable-next-line:no-string-literal | ||
expect(service.getComponentByElement(component['_eRef'].nativeElement as HTMLElement) === component) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should unregister components', () => { | ||
service.unRegisterComponent(component.id); | ||
expect(service.getComponent(component.id)) | ||
.toBeUndefined(); | ||
}); | ||
|
||
}); |
54 changes: 54 additions & 0 deletions
54
projects/wvr-elements/src/lib/core/component-registry.service.ts
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,54 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { WvrBaseComponent } from '../shared/wvr-base.component'; | ||
|
||
/** | ||
* A registry for each WvrBaseComponent currently present on the page. | ||
*/ | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ComponentRegistryService { | ||
|
||
/** Incrementing index of all registered components. */ | ||
private index = -1; | ||
|
||
/** Registry for all WvrBaseComponent. */ | ||
private readonly registry: Map<number | string, WvrBaseComponent> = new Map<number, WvrBaseComponent>(); | ||
|
||
/** Adds a WvrBaseComponent to the registry. */ | ||
register(component: WvrBaseComponent): number { | ||
|
||
// tslint:disable-next-line:no-string-literal | ||
const element = (component['_eRef'].nativeElement as HTMLElement); | ||
// tslint:disable-next-line:increment-decrement | ||
this.registry.set(++this.index, component); | ||
|
||
return this.index; | ||
} | ||
|
||
/** Removes a WvrBaseComponent from the registry. */ | ||
unRegisterComponent(id: number | string): void { | ||
this.registry.delete(id); | ||
} | ||
|
||
/** Retrieves a WvrBaseComponent from the registry. */ | ||
getComponent(id: number | string): WvrBaseComponent { | ||
return this.registry.get(id); | ||
} | ||
|
||
/** Retrieves a WvrBaseComponent from the registry by HTMLElement. */ | ||
getComponentByElement(element: HTMLElement): WvrBaseComponent { | ||
|
||
const hasNativeId = element.hasAttribute('wvr-id'); | ||
const htmlID = hasNativeId ? element.getAttribute('wvr-id') : element.getAttribute('id'); | ||
|
||
if (!htmlID) { | ||
return; | ||
} | ||
|
||
const id = parseInt(htmlID.replace(`${WvrBaseComponent.HTML_ID_BASE}-`, ''), 10); | ||
|
||
return this.getComponent(id); | ||
} | ||
|
||
} |
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
81 changes: 77 additions & 4 deletions
81
projects/wvr-elements/src/lib/core/wvr-animation.service.spec.ts
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,20 +1,93 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { ComponentFixture, TestBed, tick } from '@angular/core/testing'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { WvrItWorksComponent } from '../wvr-it-works/wvr-it-works.component'; | ||
import { WvrAnimationService } from './wvr-animation.service'; | ||
|
||
describe('WvrAnimationService', () => { | ||
let service: WvrAnimationService; | ||
let componentOne: WvrItWorksComponent; | ||
let componentTwo: WvrItWorksComponent; | ||
let fixtureOne: ComponentFixture<WvrItWorksComponent>; | ||
let fixtureTwo: ComponentFixture<WvrItWorksComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule], | ||
declarations: [WvrItWorksComponent], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [BrowserAnimationsModule] | ||
}); | ||
service = TestBed.inject(WvrAnimationService); | ||
|
||
fixtureOne = TestBed.createComponent(WvrItWorksComponent); | ||
componentOne = fixtureOne.componentInstance; | ||
componentOne.animate = `{ | ||
click: "rotateToggle" | ||
}`; | ||
componentOne.animateConfig = `{ | ||
rotateToggle: { | ||
timing: '1000ms ease-in', | ||
to: 180, | ||
from: 0 | ||
} | ||
}`; | ||
componentOne.animateId = 'animateComponentOne'; | ||
|
||
fixtureTwo = TestBed.createComponent(WvrItWorksComponent); | ||
componentTwo = fixtureTwo.componentInstance; | ||
componentTwo.animate = `{ | ||
click: "animationTrigger" | ||
}`; | ||
componentTwo.animateTarget = 'componentOne.animateId'; | ||
componentTwo.animateId = 'animateComponentTwo'; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should register new animation targets', () => { | ||
// tslint:disable-next-line:no-string-literal | ||
expect(service['_animationTargetsRegistry'].size) | ||
.toEqual(0); | ||
service.registerAnimationTargets(componentOne.animateId, componentOne); | ||
// tslint:disable-next-line:no-string-literal | ||
expect(service['_animationTargetsRegistry'].size) | ||
.toEqual(1); | ||
}); | ||
|
||
it('should register new animation states', () => { | ||
// tslint:disable-next-line:no-string-literal | ||
expect(componentOne['animationStateId']) | ||
.toBeUndefined(); | ||
|
||
// tslint:disable-next-line:no-string-literal | ||
componentOne['animationStateId'] = service.registerAnimationStates(); | ||
|
||
// tslint:disable-next-line:no-string-literal | ||
expect(componentOne['animationStateId']) | ||
.toBeDefined(); | ||
}); | ||
|
||
// it('should trigger animation target', () => { | ||
// componentOne.animationRootElem = fixtureOne.elementRef; | ||
// // tslint:disable-next-line:no-string-literal | ||
// componentOne['initializeAnimationRegistration'](); | ||
// // tslint:disable-next-line:no-string-literal | ||
// componentOne['initializeAnimationElement'](); | ||
// // tslint:disable-next-line:no-string-literal | ||
// componentTwo['initializeAnimationRegistration'](); | ||
// // tslint:disable-next-line:no-string-literal | ||
// componentTwo['initializeAnimationElement'](); | ||
|
||
// service.triggerAnimationTarget(componentTwo.animateTarget); | ||
// // tslint:disable-next-line:no-string-literal | ||
|
||
// }); | ||
|
||
}); |
Oops, something went wrong.