-
Notifications
You must be signed in to change notification settings - Fork 63
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
40 changed files
with
76,321 additions
and
58,701 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
123,652 changes: 67,701 additions & 55,951 deletions
123,652
projects/demo/assets/documentation.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
60 changes: 60 additions & 0 deletions
60
projects/novo-elements/src/elements/chips/ChipInput.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,60 @@ | ||
import { Component } from '@angular/core'; | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { By } from '@angular/platform-browser'; | ||
import { NovoFieldElement, NovoFieldModule } from '../field'; | ||
import { NovoChipInput } from './ChipInput'; | ||
import { NovoChipsModule } from './Chips.module'; | ||
|
||
@Component({ | ||
selector: 'test-chip-input', | ||
template: ` | ||
<novo-field> | ||
<novo-chip-list [formControl]="chipsCtrl"> | ||
<input novoChipInput | ||
[formControl]="textCtrl"> | ||
</novo-chip-list> | ||
</novo-field> | ||
<div class="mock-overlay"></div>` | ||
}) | ||
class TestChipInputComponent { | ||
textCtrl = new FormControl(''); | ||
chipsCtrl = new FormControl([]); | ||
} | ||
|
||
describe('Directive: NovoChipInput', () => { | ||
let fixture: ComponentFixture<TestChipInputComponent>; | ||
let testComponent: TestChipInputComponent; | ||
let directive: NovoChipInput; | ||
let mockOverlay: HTMLElement; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [FormsModule, NovoChipsModule, ReactiveFormsModule, NovoFieldModule], | ||
declarations: [TestChipInputComponent] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TestChipInputComponent); | ||
testComponent = fixture.debugElement.componentInstance; | ||
directive = fixture.debugElement.query(By.directive(NovoChipInput)).injector.get(NovoChipInput); | ||
mockOverlay = fixture.debugElement.query(By.css('.mock-overlay')).nativeElement; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should clear the control value on blur', () => { | ||
fixture.detectChanges(); | ||
const blurEvent = new FocusEvent('blur', { | ||
relatedTarget: mockOverlay | ||
}); | ||
testComponent.textCtrl.setValue('value'); | ||
spyOn(NovoFieldElement.prototype, 'blurEventIsInField').and.returnValue(false); | ||
fixture.debugElement.query(By.directive(NovoChipInput)).triggerEventHandler('blur', blurEvent); | ||
expect(NovoFieldElement.prototype.blurEventIsInField).toHaveBeenCalledWith(blurEvent); | ||
expect(testComponent.textCtrl.value).toBeFalsy(); | ||
}); | ||
}); |
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
Oops, something went wrong.