test_astro_hardhat/tests/libs/gcodeUtilts.test.ts
Florian Bouillon ff07f8f4a5 fet: Add changes lol
Signed-off-by: Florian BOUILLON <f.bouillon@aptatio.com>
2023-06-28 17:30:18 +02:00

51 lines
858 B
TypeScript

import { afterEach, assert, beforeEach, describe, expect, it, test, vi } 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)
})
})