-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #491 from ember-a11y/drewlee/test-helpers-fix
Fixes currentRouteName middleware reporter test failures
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { _getCurrentRouteName } from 'ember-a11y-testing/test-support/setup-middleware-reporter'; | ||
|
||
module('Unit | Utils | _getCurrentRouteName', function (hooks) { | ||
setupTest(hooks); | ||
|
||
test('gets the route name for the current test', function (assert) { | ||
function mockCurrentRouteName(): string { | ||
return 'index'; | ||
} | ||
|
||
const result = _getCurrentRouteName(mockCurrentRouteName); | ||
|
||
assert.strictEqual(result, 'index'); | ||
}); | ||
|
||
test('absorbs `currentRouteName` error when route name is null', function (assert) { | ||
function currentRouteNameMock(): string { | ||
throw new Error('currentRouteName shoudl be a string'); | ||
} | ||
|
||
const result = _getCurrentRouteName(currentRouteNameMock); | ||
|
||
assert.strictEqual(result, ''); | ||
}); | ||
|
||
test('bubbles up all other emitted errors', function (assert) { | ||
function mockCurrentRouteName(): string { | ||
throw new Error('Catastrophic error!'); | ||
} | ||
|
||
assert.throws(() => { | ||
_getCurrentRouteName(mockCurrentRouteName); | ||
}, /Catastrophic error!/); | ||
}); | ||
}); |