"use strict";

const assert = require("node:assert");
const { extractRouteParams, extractStates } = require("../src/completion");

test("extracts dynamic route params from filename", () => {
  const document = {
    fileName: "apps/sso/app/pages/organizations/[organization]/members/[member].wrn",
  };

  assert.deepEqual(extractRouteParams(document), ["organization", "member"]);
});

test("extracts WRN states", () => {
  const document = {
    getText() {
      return `
page Test {
    state token = ctx.params.token
    state loading = false
}
`;
    },
  };

  assert.deepEqual(extractStates(document), ["token", "loading"]);
});
