Skip to content

Commit

Permalink
update tests to eliminate ties.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Schroeder committed Jan 26, 2020
1 parent 044d311 commit ba71f0b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
26 changes: 26 additions & 0 deletions __tests__/selection-strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,32 @@ Object {
})

test('best short side fit', () => {
const rectangles = [
{
width: 100,
height: 25,
x: 0,
y: 0,
bin: 0,
id: '1'
},
{
width: 30,
height: 30,
x: 0,
y: 0,
bin: 0,
id: '2'
},
{
width: 10,
height: 200,
x: 0,
y: 0,
bin: 0,
id: '3'
}
]
const sorter = GetSelectionImplementation(SelectionStrategy.BEST_SHORT_SIDE_FIT)
const selected = sorter.select(rectangles, item1)

Expand Down
40 changes: 8 additions & 32 deletions __tests__/sort-strategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ const testItems = [
},
{
width: 30,
height: 10
},
{
width: 10,
height: 10
height: 11
},
{
width: 10,
Expand Down Expand Up @@ -57,17 +53,13 @@ Array [
"width": 10,
},
Object {
"height": 10,
"width": 10,
"height": 11,
"width": 30,
},
Object {
"height": 20,
"width": 40,
},
Object {
"height": 10,
"width": 30,
},
Object {
"height": 10,
"width": 40,
Expand All @@ -87,11 +79,7 @@ Array [
"width": 10,
},
Object {
"height": 10,
"width": 10,
},
Object {
"height": 10,
"height": 11,
"width": 30,
},
Object {
Expand All @@ -118,16 +106,12 @@ Array [
},
Object {
"height": 10,
"width": 10,
"width": 40,
},
Object {
"height": 10,
"height": 11,
"width": 30,
},
Object {
"height": 10,
"width": 40,
},
Object {
"height": 20,
"width": 40,
Expand All @@ -142,10 +126,6 @@ test('ratio sort', () => {

expect(items).toMatchInlineSnapshot(`
Array [
Object {
"height": 10,
"width": 10,
},
Object {
"height": 10,
"width": 10,
Expand All @@ -155,7 +135,7 @@ Array [
"width": 40,
},
Object {
"height": 10,
"height": 11,
"width": 30,
},
Object {
Expand All @@ -177,11 +157,7 @@ Array [
"width": 10,
},
Object {
"height": 10,
"width": 10,
},
Object {
"height": 10,
"height": 11,
"width": 30,
},
Object {
Expand Down

0 comments on commit ba71f0b

Please sign in to comment.