@redspher2021/node-red-contrib-binpacking
Version:
node-red bin packing
56 lines (52 loc) • 1.28 kB
JavaScript
const request = require('supertest')
const hostDemo = 'http://localhost:1880/binpacking'
const data = {
packages: [
{
name: 'bh',
width: 60,
height: 60,
length: 70,
weight: 28,
quantity: 1,
stackable: 'no',
allowedRotation: [
0
]
}
],
bins: [
{
name: 'avion',
width: 100,
height: 200,
length: 120,
weight: 400
},
{
name: 'break',
width: 100,
height: 100,
length: 120,
weight: 400
}
]
}
describe('Test related to binpacking', () => {
test('package should fit in the second bin', async () => {
const response = await request(`${hostDemo}`).post('/').send(data)
expect(response.body.result[1].success).toBe(true)
const metrics = response.body.result[1].metrics
expect(metrics).toBeDefined()
// usedVolume reflects post-stackability dims: 60 * 100 * 70 (height raised)
const expected = {
usedVolume: 420000.000, // 60 * 100 * 70
totalVolume: 1200000.000, // 100 * 100 * 120
availableVolume: 780000.000, // 1200000 - 420000
usedWeight: 28.00, // 28
totalWeight: 400.00, // 400
availableWeight: 372.00 // 400 - 28
}
expect(metrics).toEqual(expected)
})
})