Skip to content

Commit

Permalink
refactor: improve typing in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ndekeister-us committed Aug 10, 2022
1 parent 7ab04ac commit 4822b82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions tests/unit/initializers/embedded-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { module, test } from 'qunit'
import Resolver from 'ember-resolver'
import { run } from '@ember/runloop'

import type { TestContext } from '@ember/test-helpers'

type TestApplication = TestContext['owner'] & {
type TestApplication = Application & {
// Public types are currently incomplete, these 2 properties exist:
// https://github.com/emberjs/ember.js/blob/v3.26.1/packages/@ember/application/lib/application.js#L376-L377
_booted: boolean
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/services/embedded-test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { module, test } from 'qunit'
import { setupTest } from 'ember-qunit'

import type EmbeddedService from 'ember-cli-embedded/services/embedded'

module('Unit | Service | embedded', function (hooks) {
setupTest(hooks)

test('it fetches data from the config as a proxy', function (assert) {
this.owner.register('config:embedded', {
myKey: 'myValue',
})
const options = { myKey: 'myValue' };

this.owner.register('config:embedded', options)

const service = this.owner.lookup('service:embedded') as EmbeddedService
const service = this.owner.lookup('service:embedded') as EmbeddedService<typeof options>

assert.strictEqual(
service.get('myKey'),
'myValue'
)

assert.strictEqual(
// @ts-expect-error We try to access a property which don't exist
service.get('doesNotExist'),
undefined
)
Expand Down

0 comments on commit 4822b82

Please sign in to comment.