30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { parseBranches, parsePriceOptions } from '../electron/main/reservation'
|
|
|
|
describe('reservation response parsers', () => {
|
|
it('returns only public room branch fields', () => {
|
|
const html = `<script>
|
|
const originalZizumData = [
|
|
{"num":22,"name":"STATION","phone":"010-4445-6082","category":"room","pass":"secret"},
|
|
{"num":25,"name":"무비무드","phone":"010-0000-0000","category":"movie"}
|
|
];
|
|
</script>`
|
|
|
|
expect(parseBranches(html)).toEqual([
|
|
{ num: 22, name: 'STATION', phone: '010-4445-6082' },
|
|
])
|
|
})
|
|
|
|
it('parses server-calculated per-person prices', () => {
|
|
const html = `<select name="person" id="person">
|
|
<option value='2' data-rev_price='60000' data-price='60000'>2명</option>
|
|
<option value='4' data-rev_price='120000' data-price='120000'>4명</option>
|
|
</select>`
|
|
|
|
expect(parsePriceOptions(html)).toEqual([
|
|
{ person: 2, totalPrice: 60_000 },
|
|
{ person: 4, totalPrice: 120_000 },
|
|
])
|
|
})
|
|
})
|