Skip to content

Commit

Permalink
chore(test): move string unit tests to the dedicated file (#5826)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Mar 19, 2024
1 parent d9ef26b commit 289d220
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
23 changes: 22 additions & 1 deletion core/test/unit/src/util/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,28 @@
*/

import { expect } from "chai"
import { tailString, stripQuotes } from "../../../../src/util/string.js"
import { splitFirst, splitLast, stripQuotes, tailString } from "../../../../src/util/string.js"
import { describe } from "mocha"

describe("splitFirst", () => {
it("should split string on first occurrence of given delimiter", () => {
expect(splitFirst("foo:bar:boo", ":")).to.eql(["foo", "bar:boo"])
})

it("should return the whole string as first element when no delimiter is found in string", () => {
expect(splitFirst("foo", ":")).to.eql(["foo", ""])
})
})

describe("splitLast", () => {
it("should split string on last occurrence of given delimiter", () => {
expect(splitLast("foo:bar:boo", ":")).to.eql(["foo:bar", "boo"])
})

it("should return the whole string as last element when no delimiter is found in string", () => {
expect(splitLast("foo", ":")).to.eql(["", "foo"])
})
})

describe("tailString", () => {
it("should return string unchanged if it's shorter than maxLength", () => {
Expand Down
21 changes: 0 additions & 21 deletions core/test/unit/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
isValidDateInstance,
} from "../../../../src/util/util.js"
import { expectError } from "../../../helpers.js"
import { splitLast, splitFirst } from "../../../../src/util/string.js"
import { getRootLogger } from "../../../../src/logger/logger.js"
import { dedent } from "../../../../src/util/string.js"
import { safeDumpYaml } from "../../../../src/util/serialization.js"
Expand Down Expand Up @@ -169,26 +168,6 @@ describe("util", () => {
})
})

describe("splitFirst", () => {
it("should split string on first occurrence of given delimiter", () => {
expect(splitFirst("foo:bar:boo", ":")).to.eql(["foo", "bar:boo"])
})

it("should return the whole string as first element when no delimiter is found in string", () => {
expect(splitFirst("foo", ":")).to.eql(["foo", ""])
})
})

describe("splitLast", () => {
it("should split string on last occurrence of given delimiter", () => {
expect(splitLast("foo:bar:boo", ":")).to.eql(["foo:bar", "boo"])
})

it("should return the whole string as last element when no delimiter is found in string", () => {
expect(splitLast("foo", ":")).to.eql(["", "foo"])
})
})

describe("relationshipClasses", () => {
it("should correctly partition related items", () => {
const items = ["a", "b", "c", "d", "e", "f", "g", "ab", "bc", "cd", "de", "fg"]
Expand Down

0 comments on commit 289d220

Please sign in to comment.