forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile-search.spec.js
More file actions
63 lines (54 loc) · 2.14 KB
/
Copy pathfile-search.spec.js
File metadata and controls
63 lines (54 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
import { createStore, selectors, actions } from "../../utils/test-head";
const {
getFileSearchQuery,
getFileSearchModifiers,
getFileSearchResults
} = selectors;
describe("file text search", () => {
it("should update search results", () => {
const { dispatch, getState, cx } = createStore();
expect(getFileSearchResults(getState())).toEqual({
matches: [],
matchIndex: -1,
index: -1,
count: 0
});
const matches = [{ line: 1, ch: 3 }, { line: 3, ch: 2 }];
dispatch(actions.updateSearchResults(cx, 2, 3, matches));
expect(getFileSearchResults(getState())).toEqual({
count: 2,
index: 2,
matchIndex: 1,
matches: matches
});
});
it("should update the file search query", () => {
const { dispatch, getState, cx } = createStore();
let fileSearchQueryState = getFileSearchQuery(getState());
expect(fileSearchQueryState).toBe("");
dispatch(actions.setFileSearchQuery(cx, "foobar"));
fileSearchQueryState = getFileSearchQuery(getState());
expect(fileSearchQueryState).toBe("foobar");
});
it("should toggle a file search modifier", () => {
const { dispatch, getState, cx } = createStore();
let fileSearchModState = getFileSearchModifiers(getState());
expect(fileSearchModState.get("caseSensitive")).toBe(false);
dispatch(actions.toggleFileSearchModifier(cx, "caseSensitive"));
fileSearchModState = getFileSearchModifiers(getState());
expect(fileSearchModState.get("caseSensitive")).toBe(true);
});
it("should toggle a file search query cleaning", () => {
const { dispatch, getState, cx } = createStore();
dispatch(actions.setFileSearchQuery(cx, "foobar"));
let fileSearchQueryState = getFileSearchQuery(getState());
expect(fileSearchQueryState).toBe("foobar");
dispatch(actions.setFileSearchQuery(cx, ""));
fileSearchQueryState = getFileSearchQuery(getState());
expect(fileSearchQueryState).toBe("");
});
});