-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve ngx meta core module unit tests (#829)
- Loading branch information
Showing
2 changed files
with
22 additions
and
8 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
23 changes: 20 additions & 3 deletions
23
projects/ngx-meta/src/core/src/ngx-meta-core.module.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,15 +1,32 @@ | ||
import { TestBed } from '@angular/core/testing' | ||
import { NgxMetaCoreModule } from './ngx-meta-core.module' | ||
import { DEFAULTS_TOKEN } from './defaults-token' | ||
import { ModuleWithProviders } from '@angular/core' | ||
import { GlobalMetadata } from '@davidlj95/ngx-meta/core' | ||
|
||
describe('Core module', () => { | ||
it('provides no defaults by default', () => { | ||
TestBed.configureTestingModule({ imports: [NgxMetaCoreModule.forRoot()] }) | ||
makeSut(NgxMetaCoreModule.forRoot()) | ||
expect(TestBed.inject(DEFAULTS_TOKEN, null, { optional: true })).toBeNull() | ||
}) | ||
|
||
it('provides no defaults if not specified', () => { | ||
TestBed.configureTestingModule({ imports: [NgxMetaCoreModule.forRoot({})] }) | ||
it('provides no defaults if options object is empty', () => { | ||
makeSut(NgxMetaCoreModule.forRoot({})) | ||
expect(TestBed.inject(DEFAULTS_TOKEN, null, { optional: true })).toBeNull() | ||
}) | ||
|
||
it('provides defaults if specified as options object', () => { | ||
const defaults: GlobalMetadata = { title: 'Hello World!' } | ||
makeSut(NgxMetaCoreModule.forRoot({ defaults })) | ||
|
||
expect(TestBed.inject(DEFAULTS_TOKEN, null, { optional: true })).toEqual( | ||
defaults, | ||
) | ||
}) | ||
}) | ||
|
||
const makeSut = ( | ||
moduleWithProviders: ModuleWithProviders<NgxMetaCoreModule>, | ||
) => { | ||
TestBed.configureTestingModule({ imports: [moduleWithProviders] }) | ||
} |