-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(method): add a way to get message attrs
Add $ta method that gets message attributes fix #9
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 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
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`method works with vue components 1`] = `<div attr="Attr value">Inner data</div>`; |
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,58 @@ | ||
import { createLocalVue, mount } from '@vue/test-utils' | ||
|
||
import { FluentBundle, FluentResource } from '@fluent/bundle' | ||
import ftl from '@fluent/dedent' | ||
|
||
import FluentVue from '../../src' | ||
|
||
describe('method', () => { | ||
let options: any | ||
let bundle: FluentBundle | ||
|
||
beforeEach(() => { | ||
const localVue = createLocalVue() | ||
localVue.use(FluentVue) | ||
|
||
bundle = new FluentBundle('en-US') | ||
|
||
const fluent = new FluentVue({ | ||
bundles: [bundle] | ||
}) | ||
|
||
options = { | ||
fluent, | ||
localVue | ||
} | ||
}) | ||
|
||
it('works with vue components', () => { | ||
// Arrange | ||
bundle.addResource( | ||
new FluentResource(ftl` | ||
key = Inner data | ||
.attr = Attr value | ||
`) | ||
) | ||
|
||
const child = { | ||
props: { | ||
text: { type: String }, | ||
attrs: { type: Object } | ||
}, | ||
template: `<div :attr="attrs.attr">{{ text }}</div>` | ||
} | ||
|
||
const component = { | ||
components: { | ||
child | ||
}, | ||
template: `<child :text="$t('key')" :attrs="$ta('key')"></child>` | ||
} | ||
|
||
// Act | ||
const mounted = mount(component, options) | ||
|
||
// Assert | ||
expect(mounted).toMatchSnapshot() | ||
}) | ||
}) |