Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up factor range and add factor method #14037

Merged
merged 15 commits into from
Aug 27, 2024
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
bryevdv committed Aug 26, 2024
commit b5de87c43122fd690aaa3e321f3186eb7211acea
19 changes: 9 additions & 10 deletions bokehjs/test/unit/models/ranges/factor_range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,41 @@ describe("factor_range module", () => {

describe("FactorMapper class", () => {
describe("compute_levels method", () => {
describe("should return 1 for L1 factors", () => {
it("should return 1 for L1 factors", () => {
expect(FactorMapper.compute_levels(["A", "B"])).to.be.equal(1)
})

describe("should return 2 for L2 factors", () => {
it("should return 2 for L2 factors", () => {
expect(FactorMapper.compute_levels([["A", "1"], ["B", "2"]])).to.be.equal(2)
})

describe("should return 3 for L3 factors", () => {
it("should return 3 for L3 factors", () => {
expect(FactorMapper.compute_levels([["A", "1", "foo"], ["B", "2", "foo"]])).to.be.equal(3)
})

describe("should throw for inconsistent factors", () => {
it("should throw for inconsistent factors", () => {
expect(() => FactorMapper.compute_levels(["A", ["B", "2"]])).to.throw(TypeError)
})
})

describe("factory conctructor for", () => {
describe("should configure L1FactorMapper for range of L1 Factors", () => {
describe("factory constructor for", () => {
it("should configure L1FactorMapper for range of L1 Factors", () => {
const mapper = FactorMapper.for(new FactorRange({factors: ["A", "B"]}))
expect(mapper.levels).to.be.equal(1)
expect(mapper.tops).to.be.null
expect(mapper.mids).to.be.null
})
describe("should configure L2FactorMapper for range of L2 Factors", () => {
it("should configure L2FactorMapper for range of L2 Factors", () => {
const mapper = FactorMapper.for(new FactorRange({factors: [["A", "1"], ["B", "2"]]}))
expect(mapper.levels).to.be.equal(2)
expect(mapper.tops).to.be.equal(["A", "B"])
expect(mapper.mids).to.be.null
})
describe("should configure L3FactorMapper for range of L3 Factors", () => {
it("should configure L3FactorMapper for range of L3 Factors", () => {
const mapper = FactorMapper.for(new FactorRange({factors: [["A", "1", "foo"], ["B", "2", "foo"]]}))
expect(mapper.levels).to.be.equal(3)
expect(mapper.tops).to.be.equal(["A", "B"])
// uncommenting this crashes the test
// expect(mapper.mids).to.be.equal([["1", "foo"], ["2", "foo"]])
expect(mapper.mids).to.be.equal([["A", "1"], ["B", "2"]])
})
})
})
Expand Down
Loading