Correct user agent function name in test

This commit is contained in:
Tuan Dang
2023-08-08 22:57:38 +07:00
parent 28c24fc8c1
commit 221e601173
@@ -1,29 +1,29 @@
import { describe, expect, test } from "@jest/globals"; import { describe, expect, test } from "@jest/globals";
import { getChannelFromUserAgent } from "../../../src/utils/posthog"; import { getUserAgentType } from "../../../src/utils/posthog";
describe("posthog getChannelFromUserAgent", () => { describe("posthog getChannelFromUserAgent", () => {
test("should return 'web' when userAgent includes 'mozilla'", () => { test("should return 'web' when userAgent includes 'mozilla'", () => {
const userAgent = const userAgent =
"Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.115 Mobile Safari/537.36"; "Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.115 Mobile Safari/537.36";
const channel = getChannelFromUserAgent(userAgent); const channel = getUserAgentType(userAgent);
expect(channel).toBe("web"); expect(channel).toBe("web");
}); });
test("should return 'cli'", () => { test("should return 'cli'", () => {
const userAgent = "cli"; const userAgent = "cli";
const channel = getChannelFromUserAgent(userAgent); const channel = getUserAgentType(userAgent);
expect(channel).toBe("cli"); expect(channel).toBe("cli");
}); });
test("should return 'k8-operator'", () => { test("should return 'k8-operator'", () => {
const userAgent = "k8-operator"; const userAgent = "k8-operator";
const channel = getChannelFromUserAgent(userAgent); const channel = getUserAgentType(userAgent);
expect(channel).toBe("k8-operator"); expect(channel).toBe("k8-operator");
}); });
test("should return undefined if no userAgent", () => { test("should return undefined if no userAgent", () => {
const userAgent = undefined; const userAgent = undefined;
const channel = getChannelFromUserAgent(userAgent); const channel = getUserAgentType(userAgent);
expect(channel).toBe("other"); expect(channel).toBe("other");
}); });
}); });