Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiko732 committed Jul 21, 2024
1 parent 3c15ca8 commit f838a17
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion __tests__/algorithm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('FSRS apply_fuzz', () => {
})

describe('change Params', () => {
test('change FSRSParameters', () => {
test('change FSRSParameters[FSRS]', () => {
const f = fsrs()
// I(r,s),r=0.9 then I(r,s)=s
expect(f.interval_modifier).toEqual(1)
Expand Down Expand Up @@ -366,6 +366,54 @@ describe('change Params', () => {

f.parameters = {} // check default values
expect(f.parameters).toEqual(generatorParameters())

f.parameters.enable_short_term = false
expect(f.parameters.enable_short_term).toEqual(false)
})

test('change FSRSParameters[FSRSAlgorithm]', () => {
const params = generatorParameters()
const f = new FSRSAlgorithm(params)
// I(r,s),r=0.9 then I(r,s)=s
expect(f.interval_modifier).toEqual(1)
expect(f.parameters).toEqual(generatorParameters())

const request_retention = 0.8
const update_w = [
1.14, 1.01, 5.44, 14.67, 5.3024, 1.5662, 1.2503, 0.0028, 1.5489, 0.1763,
0.9953, 2.7473, 0.0179, 0.3105, 0.3976, 0.0, 2.0902, 0.48, 0.64,
]
f.parameters = generatorParameters({
request_retention: request_retention,
w: update_w,
enable_fuzz: true,
})
expect(f.parameters.request_retention).toEqual(request_retention)
expect(f.parameters.w).toEqual(update_w)
expect(f.parameters.enable_fuzz).toEqual(true)
expect(f.interval_modifier).toEqual(
f.calculate_interval_modifier(request_retention)
)

f.parameters.request_retention = default_request_retention
expect(f.interval_modifier).toEqual(
f.calculate_interval_modifier(default_request_retention)
)

f.parameters.w = default_w
expect(f.parameters.w).toEqual(default_w)

f.parameters.maximum_interval = 365
expect(f.parameters.maximum_interval).toEqual(365)

f.parameters.enable_fuzz = default_enable_fuzz
expect(f.parameters.enable_fuzz).toEqual(default_enable_fuzz)

f.parameters = {} // check default values
expect(f.parameters).toEqual(generatorParameters())

f.parameters.enable_short_term = false
expect(f.parameters.enable_short_term).toEqual(false)
})

test('calculate_interval_modifier', () => {
Expand Down

0 comments on commit f838a17

Please sign in to comment.