1- import { describe , it , expect } from 'vitest'
2- import { resolve , dirname } from 'path'
1+ import { dirname , resolve } from 'path'
32import { fileURLToPath } from 'url'
3+ import { describe , expect , it } from 'vitest'
44
5- import { rollup , RollupOptions } from 'rollup'
5+ import type { RollupOptions } from 'rollup'
6+ import { rollup } from 'rollup'
67import vue from 'rollup-plugin-vue'
78import { createVuePlugin } from 'vite-plugin-vue2'
89
910import fluentPlugin from '../src'
1011
1112const baseDir = dirname ( fileURLToPath ( import . meta. url ) )
1213
13- const testBundle = async ( options : RollupOptions ) : Promise < string > => {
14+ const testBundle = async ( options : RollupOptions ) : Promise < string > => {
1415 const bundle = await rollup ( {
1516 ...options ,
16- external : [ 'vue' , '@fluent/bundle' ]
17+ external : [ 'vue' , '@fluent/bundle' ] ,
1718 } )
1819
1920 const { output } = await bundle . generate ( { format : 'cjs' , exports : 'auto' } )
@@ -22,75 +23,76 @@ const testBundle = async (options: RollupOptions): Promise<string> => {
2223}
2324
2425describe ( 'rollup plugin' , ( ) => {
25- it ( 'generates custom block code' , async ( ) => {
26+ it ( 'generates custom block code' , async ( ) => {
2627 // Arrange
2728 // Act
2829 const code = await testBundle ( {
2930 input : resolve ( baseDir , 'fixtures/test.vue' ) ,
3031 plugins : [
3132 vue ( {
32- customBlocks : [ 'fluent' ]
33+ customBlocks : [ 'fluent' ] ,
3334 } ) ,
34- fluentPlugin ( )
35- ]
35+ fluentPlugin ( ) ,
36+ ] ,
3637 } )
3738
3839 // Assert
3940 expect ( code ) . toMatchSnapshot ( )
4041 } )
4142
42- it ( 'works with vue 2' , async ( ) => {
43+ it ( 'works with vue 2' , async ( ) => {
4344 // Arrange
4445 // Act
4546 const code = await testBundle ( {
4647 input : resolve ( baseDir , 'fixtures/test.vue' ) ,
4748 plugins : [
4849 createVuePlugin ( ) ,
49- fluentPlugin ( )
50- ]
50+ fluentPlugin ( ) ,
51+ ] ,
5152 } )
5253
5354 // Assert
5455 expect ( code ) . toMatchSnapshot ( )
5556 } )
5657
57- it ( 'custom blockType' , async ( ) => {
58+ it ( 'custom blockType' , async ( ) => {
5859 // Arrange
5960 // Act
6061 const code = await testBundle ( {
6162 input : resolve ( baseDir , 'fixtures/blockType.vue' ) ,
6263 plugins : [
6364 vue ( {
64- customBlocks : [ 'i18n' ]
65+ customBlocks : [ 'custom' ] ,
6566 } ) , fluentPlugin ( {
66- blockType : 'i18n'
67- } )
67+ blockType : 'custom' ,
68+ } ) ,
6869 ] ,
69- external : [ 'vue' , '@fluent/bundle' ]
70+ external : [ 'vue' , '@fluent/bundle' ] ,
7071 } )
7172
7273 // Assert
7374 expect ( code ) . toMatchSnapshot ( )
7475 } )
7576
76- it ( 'errors with no locale attr' , async ( ) => {
77+ it ( 'errors with no locale attr' , async ( ) => {
7778 // Arrange
78- const func = async ( ) : Promise < string > => await testBundle ( {
79+ const func = async ( ) : Promise < string > => await testBundle ( {
7980 input : resolve ( baseDir , 'fixtures/noLocale.vue' ) ,
8081 plugins : [
8182 vue ( {
82- customBlocks : [ 'fluent' ]
83+ customBlocks : [ 'fluent' ] ,
8384 } ) ,
84- fluentPlugin ( )
85+ fluentPlugin ( ) ,
8586 ] ,
86- external : [ 'vue' , '@fluent/bundle' ]
87+ external : [ 'vue' , '@fluent/bundle' ] ,
8788 } )
8889
8990 // TODO: Use rejects
9091 try {
9192 // Act
9293 await func ( )
93- } catch ( err ) {
94+ }
95+ catch ( err ) {
9496 // Assert
9597 expect ( err ) . toMatchSnapshot ( )
9698 }
0 commit comments