Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
miyaoka committed Oct 2, 2024
1 parent b2a0412 commit dcae0f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/lib/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { parseSearchString, createSearchRegexp, searchQueryToSaerchString } from "./search";
import { parseSearchString, createSearchRegexp, searchQueryToSearchString } from "./search";

describe("parseInput", () => {
it("引用符で囲まれた文字列は空白があっても区切られないこと", () => {
Expand Down Expand Up @@ -134,7 +134,7 @@ describe("searchQueryToTerms", () => {
};
const expected = "example test";

expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("オプションを含むクエリを文字列に変換できること", () => {
Expand All @@ -144,7 +144,7 @@ describe("searchQueryToTerms", () => {
options: { tag: ["exampleTag"], status: ["live"] },
};
const expected = "example tag:exampleTag status:live";
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("ハッシュタグを含むクエリを文字列に変換できること", () => {
Expand All @@ -154,7 +154,7 @@ describe("searchQueryToTerms", () => {
options: {},
};
const expected = "example #tag1 #tag2";
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("単語、オプション、ハッシュタグを含むクエリを文字列に変換できること", () => {
Expand All @@ -164,7 +164,7 @@ describe("searchQueryToTerms", () => {
options: { tag: ["exampleTag"], status: ["live"] },
};
const expected = "example test tag:exampleTag status:live #tag1";
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("空のクエリを空文字列に変換できること", () => {
Expand All @@ -174,7 +174,7 @@ describe("searchQueryToTerms", () => {
options: {},
};
const expected = "";
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("オプションが空の配列の場合は無視されること", () => {
Expand All @@ -184,7 +184,7 @@ describe("searchQueryToTerms", () => {
options: { tag: [] },
};
const expected = "example";
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});

it("空白を含むオプションの値がクォートされること", () => {
Expand All @@ -194,6 +194,6 @@ describe("searchQueryToTerms", () => {
options: { tag: ["example tag"] },
};
const expected = 'example "the space" tag:"example tag"';
expect(searchQueryToSaerchString(searchQuery)).toEqual(expected);
expect(searchQueryToSearchString(searchQuery)).toEqual(expected);
});
});
2 changes: 1 addition & 1 deletion src/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function quoteIfSpace(str: string): string {
}

// SearchQueryを検索文字列に変換
export function searchQueryToSaerchString(searchQuery: SearchQuery): string {
export function searchQueryToSearchString(searchQuery: SearchQuery): string {
const { wordList, options, hashtagList } = searchQuery;
const optionStr = Object.entries(options)
.flatMap(([key, valueList]) => {
Expand Down
8 changes: 4 additions & 4 deletions src/store/searchStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { acceptHMRUpdate, defineStore } from "pinia";
import { computed, ref } from "vue";
import { useScrollStore } from "./scrollStore";
import { parseSearchString, searchQueryToSaerchString } from "@/lib/search";
import { parseSearchString, searchQueryToSearchString } from "@/lib/search";

export const useSearchStore = defineStore("searchStore", () => {
const scrollStore = useScrollStore();
Expand Down Expand Up @@ -62,7 +62,7 @@ export const useSearchStore = defineStore("searchStore", () => {
} else {
newStatusList = [...searchStatusList.value, "live"];
}
searchString.value = searchQueryToSaerchString({
searchString.value = searchQueryToSearchString({
...searchQuery.value,
options: { ...options, status: newStatusList },
});
Expand All @@ -78,7 +78,7 @@ export const useSearchStore = defineStore("searchStore", () => {

// 解除
if (talent === null) {
searchString.value = searchQueryToSaerchString({
searchString.value = searchQueryToSearchString({
...searchQuery.value,
options: { ...options, talent: [] },
});
Expand All @@ -91,7 +91,7 @@ export const useSearchStore = defineStore("searchStore", () => {
// セット
newTalentList = [talent];
}
searchString.value = searchQueryToSaerchString({
searchString.value = searchQueryToSearchString({
...searchQuery.value,
options: { ...options, talent: newTalentList },
});
Expand Down

0 comments on commit dcae0f2

Please sign in to comment.