test_astro_hardhat/tests/libs/gcodeUtilts.test.ts
Florian Bouillon 71fd87a716 fix: check failed
Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
2023-07-04 16:14:27 +02:00

51 lines
817 B
TypeScript

import { describe, expect, it } from 'vitest'
import { getParams } from '../../src/libs/gcodeUtils'
describe('gcodeUtils', () => {
it('should get parameters', () => {
const gcode = `
balfs
dgfdf
sd
httphq
estimated_printing_time_normal_modewef
; test=a
fgd
;test =b
;test= c
;test = d
;number=1.12
;number2=-1
;invalid=
;invalid
;estimated_printing_time_normal_mode=1d 1h 1m 1s
sdffgaf
fgsdf
g
sfd
hh
ehf
`
expect(getParams(gcode)).toEqual({
test: 'a',
test_1: 'b',
test_2: 'c',
test_3: 'd',
number: 1.12,
number2: -1,
estimated_printing_time_normal_mode: '1d 1h 1m 1s',
estimated_printing_time_seconds: 90061
})
})
it('should get parameters', () => {
const gcode = `
;estimated_printing_time_normal_mode=1w 1d 1h 1m 1s
`
expect(() => getParams(gcode)).toThrow(/1w/g)
})
})