-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Create a helper to show the last 8 characters of token Accessor ID (
#7327) * Create substr helper * Create a test for the new substr helper * Display the last 8 characters of token Accessor ID in the Token lists page
- Loading branch information
Showing
3 changed files
with
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
export default helper(function substr([str = '', start = 0, length], hash) { | ||
return str.substr(start, length); | ||
}); |
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,17 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('helper:substr', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it returns last 2 characters of string', async function(assert) { | ||
this.set('inputValue', 'd9a54409-648b-4327-974f-62a45c8c65f1'); | ||
|
||
await render(hbs`{{substr inputValue -4}}`); | ||
|
||
assert.dom('*').hasText('65f1'); | ||
}); | ||
}); |