"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const typescript_1 = __importDefault(require("typescript"));
const assert_1 = __importDefault(require("assert"));
const vscode_languageserver_1 = require("vscode-languageserver");
const documents_1 = require("../../../../src/lib/documents");
const SelectionRangeProvider_1 = require("../../../../src/plugins/typescript/features/SelectionRangeProvider");
const LSAndTSDocResolver_1 = require("../../../../src/plugins/typescript/LSAndTSDocResolver");
const utils_1 = require("../../../../src/utils");
const ls_config_1 = require("../../../../src/ls-config");
const testDir = path_1.default.join(__dirname, '..');
describe('SelectionRangeProvider', () => {
    function setup() {
        const docManager = new documents_1.DocumentManager((textDocument) => new documents_1.Document(textDocument.uri, textDocument.text));
        const filePath = path_1.default.join(testDir, 'testfiles', 'selection-range', 'selection-range.svelte');
        const lsAndTsDocResolver = new LSAndTSDocResolver_1.LSAndTSDocResolver(docManager, [(0, utils_1.pathToUrl)(testDir)], new ls_config_1.LSConfigManager());
        const provider = new SelectionRangeProvider_1.SelectionRangeProviderImpl(lsAndTsDocResolver);
        const document = docManager.openDocument({
            uri: (0, utils_1.pathToUrl)(filePath),
            text: typescript_1.default.sys.readFile(filePath)
        });
        return { provider, document };
    }
    it('provides selection range', async () => {
        const { provider, document } = setup();
        const selectionRange = await provider.getSelectionRange(document, vscode_languageserver_1.Position.create(1, 9));
        assert_1.default.deepStrictEqual(selectionRange, {
            parent: {
                parent: undefined,
                // let a;
                range: {
                    end: {
                        character: 10,
                        line: 1
                    },
                    start: {
                        character: 4,
                        line: 1
                    }
                }
            },
            // a
            range: {
                end: {
                    character: 9,
                    line: 1
                },
                start: {
                    character: 8,
                    line: 1
                }
            }
        });
    });
    it('return null when in style', async () => {
        const { provider, document } = setup();
        const selectionRange = await provider.getSelectionRange(document, vscode_languageserver_1.Position.create(5, 0));
        assert_1.default.equal(selectionRange, null);
    });
});
//# sourceMappingURL=SelectionRangeProvider.test.js.map