-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
1 parent
e6cd893
commit ee2201b
Showing
2 changed files
with
45 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,51 @@ | ||
import 'ember-source/types'; | ||
import '@glint/environment-ember-loose'; | ||
|
||
import Helper from '@ember/component/helper'; | ||
|
||
import { expectTypeOf } from 'expect-type'; | ||
import type Owner from '@ember/owner'; | ||
|
||
/************************ | ||
* The Helper | ||
************************/ | ||
import Helper from '@ember/component/helper'; | ||
import { pageTitle } from 'ember-page-title'; | ||
|
||
expectTypeOf(new pageTitle()).toMatchTypeOf<Helper<any>>(); | ||
let instance = new pageTitle({} as Owner); | ||
|
||
expectTypeOf(instance).toMatchTypeOf<Helper<any>>(); | ||
expectTypeOf<ReturnType<typeof instance['compute']>>().toBeString(/* an empty string, but still a string */); | ||
|
||
/************************ | ||
* The Service | ||
************************/ | ||
import PageTitleService from 'ember-page-title/services/page-title'; | ||
import type Service from '@ember/service'; | ||
|
||
let service = new PageTitleService({} as Owner); | ||
|
||
expectTypeOf(service).toMatchTypeOf<Service>(); | ||
expectTypeOf(service.tokens).toBeArray(); | ||
expectTypeOf(service.tokens[0]).toMatchTypeOf<object | undefined>(); | ||
expectTypeOf<NonNullable<typeof service.tokens[0]>>() | ||
.toMatchTypeOf<{ | ||
id: string, title?: string, | ||
separator?: string; | ||
prepend?: boolean; | ||
replace?: boolean; | ||
front?: unknown; | ||
}>(); | ||
|
||
expectTypeOf<PageTitleService['tokens']>().toBeArray(); | ||
expectTypeOf<PageTitleService['sortedTokens']>().toBeArray(); | ||
expectTypeOf<ReturnType<PageTitleService['toString']>>().toBeString(); | ||
expectTypeOf<PageTitleService['titleDidUpdate']>().toMatchTypeOf<(title: string) => void>(); | ||
expectTypeOf<PageTitleService['remove']>().toMatchTypeOf<(id: string) => void>(); | ||
|
||
expectTypeOf<PageTitleService['push']>() | ||
.toMatchTypeOf<(token: { id: string }) => void>(); | ||
expectTypeOf<PageTitleService['push']>() | ||
.toMatchTypeOf<(token: { id: string, title: string }) => void>(); | ||
|
||
// @ts-expect-error | ||
expectTypeOf<PageTitleService['push']>().toMatchTypeOf<(token: undefined) => void>(); |