-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
38f0fdb
commit 915a64a
Showing
24 changed files
with
528 additions
and
237 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
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
46 changes: 46 additions & 0 deletions
46
libs/components/forms/src/lib/modules/form-error/form-error.component.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,46 @@ | ||
import { Component } from '@angular/core'; | ||
import { TestBed } from '@angular/core/testing'; | ||
import { expect } from '@skyux-sdk/testing'; | ||
|
||
import { SkyFormErrorModule } from './form-error.module'; | ||
import { SKY_FORM_ERRORS_ENABLED } from './form-errors-enabled-token'; | ||
import { SkyFormErrorsModule } from './form-errors.module'; | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [SkyFormErrorsModule, SkyFormErrorModule], | ||
providers: [{ provide: SKY_FORM_ERRORS_ENABLED, useValue: true }], | ||
template: ` | ||
<sky-form-error errorName="required" errorText="This field is required" /> | ||
`, | ||
}) | ||
class FormErrorWithTokenComponent {} | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [SkyFormErrorsModule, SkyFormErrorModule], | ||
template: ` | ||
<sky-form-error errorName="required" errorText="This field is required" /> | ||
`, | ||
}) | ||
class FormErrorWithoutTokenComponent {} | ||
|
||
describe('Form error component', () => { | ||
it('renders an error message when form errors enabled token is provided', () => { | ||
const fixture = TestBed.createComponent(FormErrorWithTokenComponent); | ||
|
||
fixture.detectChanges(); | ||
|
||
expect( | ||
fixture.nativeElement.querySelector('.sky-form-error'), | ||
).toBeVisible(); | ||
}); | ||
|
||
it('throws an error when form errors enabled token is not provided', () => { | ||
expect(() => | ||
TestBed.createComponent(FormErrorWithoutTokenComponent), | ||
).toThrowError( | ||
'The `sky-form-error` component is not supported in the provided context.', | ||
); | ||
}); | ||
}); |
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
9 changes: 9 additions & 0 deletions
9
libs/components/forms/src/lib/modules/form-error/form-error.module.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,9 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { SkyFormErrorComponent } from './form-error.component'; | ||
|
||
@NgModule({ | ||
imports: [SkyFormErrorComponent], | ||
exports: [SkyFormErrorComponent], | ||
}) | ||
export class SkyFormErrorModule {} |
8 changes: 8 additions & 0 deletions
8
libs/components/forms/src/lib/modules/form-error/form-errors-enabled-token.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,8 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const SKY_FORM_ERRORS_ENABLED = new InjectionToken<boolean>( | ||
'SKY_FORM_ERRORS_ENABLED', | ||
); |
Oops, something went wrong.