Skip to content

Commit fd6a984

Browse files
author
Andrii Kirmas
committed
#35 Test bem's resolver on options change
1 parent 394b21c commit fd6a984

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

src/bem.core.test.ts

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type {BemInGeneral} from "./bem.types"
2-
import type {BemOptions} from "./bem.core";
32
import {
43
bem2arr,
5-
getOptions,
64
setOptions
75
} from "./bem.core";
86

@@ -33,43 +31,23 @@ describe(bem2arr.name, () => {
3331
})
3432

3533
describe("optioning", () => {
36-
const defaultOpts: BemOptions = {
34+
afterAll(() => setOptions({
3735
elementDelimiter: "__",
3836
modDelimiter: "--",
39-
}
37+
}))
4038

41-
it("default", () => expect(
42-
getOptions()
43-
).toStrictEqual(
44-
defaultOpts
45-
))
46-
47-
it("set empty", () => expect((
48-
setOptions({}),
49-
getOptions()
50-
)).toStrictEqual(
51-
defaultOpts
52-
))
53-
54-
it("set another", () => {
55-
//TODO #29 test bem with not default options
56-
const opts: BemOptions = {
57-
elementDelimiter: "_",
58-
modDelimiter: "-",
59-
}
60-
setOptions(opts)
61-
62-
expect(
63-
getOptions()
64-
).toStrictEqual(
65-
opts
39+
it("another mod", () => {
40+
setOptions({modDelimiter: "-"})
41+
expect(bem2arr({
42+
base: {mod: "val"}
43+
}).join(" ")).toBe(
44+
"base base-mod-val"
6645
)
6746
})
6847

69-
it("revert to default", () => expect((
70-
setOptions(defaultOpts),
71-
getOptions()
72-
)).toStrictEqual(
73-
defaultOpts
74-
))
75-
})
48+
it("another el", () => {
49+
//#Useful in #30
50+
setOptions({elementDelimiter: "_"})
51+
expect(true).toBe(true)
52+
})
53+
})

src/bem.core.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export type BemOptions = {
1212

1313
export {
1414
bem2arr,
15-
setOptions,
16-
getOptions
15+
setOptions
1716
}
1817

1918
function bem2arr(query: BemInGeneral) {
@@ -62,10 +61,3 @@ function setOptions({
6261
modDelimiter = modDel
6362
elementDelimiter = elD
6463
}
65-
66-
function getOptions() {
67-
return {
68-
elementDelimiter,
69-
modDelimiter,
70-
}
71-
}

0 commit comments

Comments
 (0)