@shopify/theme-language-server-common
Version: 
<h1 align="center" style="position: relative;" > <br> <img src="https://github.com/Shopify/theme-check-vscode/blob/main/images/shopify_glyph.png?raw=true" alt="logo" width="141" height="160"> <br> Theme Language Server </h1>
47 lines (42 loc) • 1.53 kB
text/typescript
import { describe, beforeEach, it, expect } from 'vitest';
import { DocumentManager } from '../../documents';
import { HoverProvider } from '../HoverProvider';
describe('Module: TranslationHoverProvider', async () => {
  let provider: HoverProvider;
  beforeEach(async () => {
    provider = new HoverProvider(
      new DocumentManager(),
      {
        filters: async () => [],
        objects: async () => [],
        tags: async () => [],
        systemTranslations: async () => ({}),
      },
      async () => ({
        general: {
          password: 'password',
          username_html: '<b>username</b>',
          comments: {
            one: '{{ count }} comment',
            other: '{{ count }} comments',
          },
        },
      }),
    );
  });
  it('should return the hover description of the translation string', async () => {
    await expect(provider).to.hover(`{{ '█general.password' | t }}`, 'password');
    await expect(provider).to.hover(
      `{{ 'general█.username_html' | t }}`,
      expect.stringMatching('<b>username</b>'),
    );
    await expect(provider).to.hover(
      `{{ 'general█.comments' | translate }}`,
      expect.stringMatching(/one(.|\n)*comment(.|\n)*other(.|\n)*comments/),
    );
  });
  it('should return nothing if there are no translations for that string', async () => {
    await expect(provider).to.hover(`{{ 'general.█password' | not_a_translation_filter }}`, null);
    await expect(provider).to.hover(`{{ 'general.█nope' | t }}`, null);
  });
});