goodsPriceEdit.helpers.test.mjs
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { isMarketingGoodsPriceLocked } from '../services/goodsPriceEdit.helpers.js'
describe('goodsPriceEdit.helpers', () => {
it('locks price when marketingFlag and activityId are both present', () => {
assert.equal(
isMarketingGoodsPriceLocked({
marketingFlag: 1,
activityId: 9,
goods: {}
}),
true
)
})
it('does not lock when marketingFlag is inactive', () => {
assert.equal(
isMarketingGoodsPriceLocked({
marketingFlag: 0,
activityId: 9
}),
false
)
})
it('does not lock when activityId is missing', () => {
assert.equal(
isMarketingGoodsPriceLocked({
marketingFlag: 1,
goods: { marketingFlag: 1 }
}),
false
)
})
it('reads marketing meta from goods body', () => {
assert.equal(
isMarketingGoodsPriceLocked({
goods: { marketingFlag: 1, activityId: 3 }
}),
true
)
})
})