Skip to content

Commit e3a8c46

Browse files
codomposerjosteink
authored andcommitted
remove low value tests that just test mocks
1 parent 82a74c9 commit e3a8c46

File tree

1 file changed

+1
-241
lines changed

1 file changed

+1
-241
lines changed

test/test.get.js

Lines changed: 1 addition & 241 deletions
Original file line numberDiff line numberDiff line change
@@ -55,247 +55,7 @@ describe("Get functions", () => {
5555
delete global.top;
5656
});
5757

58-
describe("get.last_active", () => {
59-
it("returns object with time, ip, mac_address, and time_relative", () => {
60-
// Mock the tracker globals
61-
gmail.tracker.globals = [];
62-
gmail.tracker.globals[17] = [];
63-
gmail.tracker.globals[17][15] = [
64-
null,
65-
1234567890,
66-
null,
67-
"192.168.1.1",
68-
null, null, null, null, null,
69-
"00:11:22:33:44:55",
70-
"2 hours ago"
71-
];
72-
73-
let result = gmail.get.last_active();
74-
75-
assert.ok(result);
76-
assert.equal(result.time, 1234567890);
77-
assert.equal(result.ip, "192.168.1.1");
78-
assert.equal(result.mac_address, "00:11:22:33:44:55");
79-
assert.equal(result.time_relative, "2 hours ago");
80-
});
81-
});
82-
83-
describe("get.loggedin_accounts", () => {
84-
it("returns array of logged in accounts", () => {
85-
// Mock the tracker mla
86-
gmail.tracker.mla = [
87-
null,
88-
[
89-
["[email protected]", null, null, 0, "User One"],
90-
["[email protected]", null, null, 1, "User Two"]
91-
]
92-
];
93-
94-
let result = gmail.get.loggedin_accounts();
95-
96-
assert.ok(Array.isArray(result));
97-
assert.equal(result.length, 2);
98-
assert.equal(result[0].email, "[email protected]");
99-
assert.equal(result[0].name, "User One");
100-
assert.equal(result[0].index, 0);
101-
assert.equal(result[1].email, "[email protected]");
102-
assert.equal(result[1].name, "User Two");
103-
assert.equal(result[1].index, 1);
104-
});
105-
106-
it("returns empty array when mla is not an array", () => {
107-
gmail.tracker.mla = null;
108-
109-
let result = gmail.get.loggedin_accounts();
110-
111-
assert.ok(Array.isArray(result));
112-
assert.equal(result.length, 0);
113-
});
114-
115-
it("returns empty array when mla is undefined", () => {
116-
gmail.tracker.mla = undefined;
117-
118-
let result = gmail.get.loggedin_accounts();
119-
120-
assert.ok(Array.isArray(result));
121-
assert.equal(result.length, 0);
122-
});
123-
});
124-
125-
describe("get.user_email", () => {
126-
it("returns email from tracker globals", () => {
127-
gmail.tracker.globals = [];
128-
gmail.tracker.globals[10] = "[email protected]";
129-
130-
let result = gmail.get.user_email();
131-
132-
assert.equal(result, "[email protected]");
133-
});
134-
135-
it("returns null when no email found in globals and no DOM elements", () => {
136-
gmail.tracker.globals = [];
137-
138-
let result = gmail.get.user_email();
139-
140-
assert.equal(result, null);
141-
});
142-
143-
it("returns email from DOM when not in globals", () => {
144-
gmail.tracker.globals = [];
145-
146-
// Override document.getElementsByClassName temporarily
147-
const originalGetElementsByClassName = global.document.getElementsByClassName;
148-
global.document.getElementsByClassName = (className) => {
149-
if (className === "eYSAde") {
150-
// Return an iterable array-like object
151-
// Note: the code looks for innerHTML WITHOUT "@" symbol
152-
const elements = [{ innerHTML: "userexample" }];
153-
elements[Symbol.iterator] = Array.prototype[Symbol.iterator];
154-
return elements;
155-
}
156-
return [];
157-
};
158-
159-
let result = gmail.get.user_email();
160-
161-
assert.equal(result, "userexample");
162-
163-
// Restore original
164-
global.document.getElementsByClassName = originalGetElementsByClassName;
165-
});
166-
});
167-
168-
describe("get.manager_email", () => {
169-
it("returns user email when not delegated inbox", () => {
170-
gmail.tracker.globals = [];
171-
gmail.tracker.globals[10] = "[email protected]";
172-
173-
// Mock is_delegated_inbox to return false
174-
gmail.helper.get.is_delegated_inbox = () => false;
175-
176-
let result = gmail.get.manager_email();
177-
178-
assert.equal(result, "[email protected]");
179-
});
180-
181-
it("returns delegated email when in delegated inbox", () => {
182-
// Mock is_delegated_inbox to return true
183-
gmail.helper.get.is_delegated_inbox = () => true;
184-
185-
// Mock delegated_to_email
186-
gmail.get.delegated_to_email = () => "[email protected]";
187-
188-
let result = gmail.get.manager_email();
189-
190-
assert.equal(result, "[email protected]");
191-
});
192-
});
193-
194-
describe("get.delegated_to_email", () => {
195-
it("returns null when not in delegated inbox", () => {
196-
gmail.helper.get.is_delegated_inbox = () => false;
197-
198-
let result = gmail.get.delegated_to_email();
199-
200-
assert.equal(result, null);
201-
});
202-
203-
it("returns delegated user email when in delegated inbox", () => {
204-
gmail.helper.get.is_delegated_inbox = () => true;
205-
206-
// Override window.location.pathname
207-
global.window.location.pathname = "/mail/u/1/";
208-
209-
// Mock loggedin_accounts
210-
gmail.tracker.mla = [
211-
null,
212-
[
213-
["[email protected]", null, null, 0, "User One"],
214-
["[email protected]", null, null, 1, "User Two"]
215-
]
216-
];
217-
218-
let result = gmail.get.delegated_to_email();
219-
220-
assert.equal(result, "[email protected]");
221-
});
222-
223-
it("returns null when delegated user not found in accounts", () => {
224-
gmail.helper.get.is_delegated_inbox = () => true;
225-
226-
// Override window.location.pathname
227-
global.window.location.pathname = "/mail/u/5/";
228-
229-
// Mock loggedin_accounts
230-
gmail.tracker.mla = [
231-
null,
232-
[
233-
["[email protected]", null, null, 0, "User One"],
234-
["[email protected]", null, null, 1, "User Two"]
235-
]
236-
];
237-
238-
let result = gmail.get.delegated_to_email();
239-
240-
assert.equal(result, null);
241-
});
242-
});
243-
244-
describe("get.localization", () => {
245-
it("returns locale from globals[17] ui subarray with URL", () => {
246-
gmail.tracker.globals = [];
247-
gmail.tracker.globals[17] = [
248-
["ui", "https://example.com?hl=en-US", null, null, null, null, null, null, "de", null]
249-
];
250-
251-
let result = gmail.get.localization();
252-
253-
// filter_locale strips region and returns only first 2 chars lowercase
254-
assert.equal(result, "en");
255-
});
256-
257-
it("returns locale from globals[17] ui subarray fallback to index 8", () => {
258-
gmail.tracker.globals = [];
259-
gmail.tracker.globals[17] = [
260-
["ui", null, null, null, null, null, null, null, "en", null]
261-
];
262-
263-
let result = gmail.get.localization();
264-
265-
assert.equal(result, "en");
266-
});
267-
268-
it("returns locale from globals[12] help article link", () => {
269-
gmail.tracker.globals = [];
270-
gmail.tracker.globals[17] = [];
271-
gmail.tracker.globals[12] = "https://support.google.com/mail?hl=fr";
272-
273-
let result = gmail.get.localization();
274-
275-
assert.equal(result, "fr");
276-
});
277-
278-
it("returns locale from globals[4]", () => {
279-
gmail.tracker.globals = [];
280-
gmail.tracker.globals[17] = [];
281-
gmail.tracker.globals[12] = null;
282-
gmail.tracker.globals[4] = "something.de.something";
283-
284-
let result = gmail.get.localization();
285-
286-
assert.equal(result, "de");
287-
});
288-
289-
it("returns null when no locale found", () => {
290-
gmail.tracker.globals = [];
291-
292-
let result = gmail.get.localization();
293-
294-
assert.equal(result, null);
295-
});
296-
});
297-
298-
// Tests migrated from test.parsing.js
58+
// Tests migrated from test.parsing.js (previously commented out)
29959
describe("get.current_page", () => {
30060
it("parses various hash values correctly", () => {
30161
const testCases = {

0 commit comments

Comments
 (0)