mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 15:42:09 +00:00
23 lines
939 B
TypeScript
23 lines
939 B
TypeScript
import { expect } from 'chai'
|
|
import { TransformPlugin } from '../src/global-imports/transform'
|
|
|
|
describe('module:global-imports:build', () => {
|
|
const { transform: _transform } = TransformPlugin.raw({ ref: 'vue', computed: 'bar' }, {} as any)
|
|
const transform = (code: string) => _transform.call({} as any, code, '')
|
|
|
|
it('should correct inject', async () => {
|
|
const result = await transform('const a = ref(0)')
|
|
expect(result).to.equal('import { ref } from \'vue\';const a = ref(0)')
|
|
})
|
|
|
|
it('should ignore imported', async () => {
|
|
const result = await transform('import { ref } from "foo";const a = ref(0)')
|
|
expect(result).to.equal(null)
|
|
})
|
|
|
|
it('should ignore comments', async () => {
|
|
const result = await transform('// import { computed } from "foo"\n;const a = computed(0)')
|
|
expect(result).to.equal('import { computed } from \'bar\';// import { computed } from "foo"\n;const a = computed(0)')
|
|
})
|
|
})
|