|
1 |
| -import { test } from 'vitest' |
| 1 | +import { test, expect, describe } from 'vitest' |
2 | 2 | import { withFixture } from '../common'
|
| 3 | +import { css, defineTest } from '../../src/testing' |
| 4 | +import { createClient } from '../utils/client' |
3 | 5 |
|
4 | 6 | function buildCompletion(c) {
|
5 | 7 | return async function completion({
|
@@ -670,3 +672,69 @@ withFixture('v4/workspaces', (c) => {
|
670 | 672 | })
|
671 | 673 | })
|
672 | 674 | })
|
| 675 | + |
| 676 | +defineTest({ |
| 677 | + name: 'v4: Completions show after a variant arbitrary value', |
| 678 | + fs: { |
| 679 | + 'app.css': css` |
| 680 | + @import 'tailwindcss'; |
| 681 | + `, |
| 682 | + }, |
| 683 | + prepare: async ({ root }) => ({ client: await createClient({ root }) }), |
| 684 | + handle: async ({ client }) => { |
| 685 | + let document = await client.open({ |
| 686 | + lang: 'html', |
| 687 | + text: '<div class="data-[foo]:">', |
| 688 | + }) |
| 689 | + |
| 690 | + // <div class="data-[foo]:"> |
| 691 | + // ^ |
| 692 | + let completion = await document.completions({ line: 0, character: 23 }) |
| 693 | + |
| 694 | + expect(completion?.items.length).toBe(12289) |
| 695 | + }, |
| 696 | +}) |
| 697 | + |
| 698 | +defineTest({ |
| 699 | + name: 'v4: Completions show after an arbitrary variant', |
| 700 | + fs: { |
| 701 | + 'app.css': css` |
| 702 | + @import 'tailwindcss'; |
| 703 | + `, |
| 704 | + }, |
| 705 | + prepare: async ({ root }) => ({ client: await createClient({ root }) }), |
| 706 | + handle: async ({ client }) => { |
| 707 | + let document = await client.open({ |
| 708 | + lang: 'html', |
| 709 | + text: '<div class="[&:hover]:">', |
| 710 | + }) |
| 711 | + |
| 712 | + // <div class="[&:hover]:"> |
| 713 | + // ^ |
| 714 | + let completion = await document.completions({ line: 0, character: 22 }) |
| 715 | + |
| 716 | + expect(completion?.items.length).toBe(12289) |
| 717 | + }, |
| 718 | +}) |
| 719 | + |
| 720 | +defineTest({ |
| 721 | + name: 'v4: Completions show after a variant with a bare value', |
| 722 | + fs: { |
| 723 | + 'app.css': css` |
| 724 | + @import 'tailwindcss'; |
| 725 | + `, |
| 726 | + }, |
| 727 | + prepare: async ({ root }) => ({ client: await createClient({ root }) }), |
| 728 | + handle: async ({ client }) => { |
| 729 | + let document = await client.open({ |
| 730 | + lang: 'html', |
| 731 | + text: '<div class="supports-not-hover:">', |
| 732 | + }) |
| 733 | + |
| 734 | + // <div class="supports-not-hover:"> |
| 735 | + // ^ |
| 736 | + let completion = await document.completions({ line: 0, character: 31 }) |
| 737 | + |
| 738 | + expect(completion?.items.length).toBe(12289) |
| 739 | + }, |
| 740 | +}) |
0 commit comments