Reset reverse when clicking another column to sort

This commit is contained in:
Kristina Lim
2018-07-20 09:27:16 +08:00
committed by Maikel Linke
parent 5179f7fd63
commit 47608525c6
2 changed files with 30 additions and 1 deletions

View File

@@ -13,3 +13,32 @@ describe "SortOptions service", ->
describe "initialising reverse", ->
it "sets reverse to true", ->
expect(SortOptions.reverse).toBe true
describe "sorting by a column", ->
describe "when selecting Column A once", ->
it "sorts by Column A", ->
SortOptions.toggle("column.a")
expect(SortOptions.predicate).toEqual "column.a"
expect(SortOptions.reverse).toBe false
describe "when selecting Column A twice", ->
it "sorts by Column A in reverse order", ->
SortOptions.toggle("column.a")
SortOptions.toggle("column.a")
expect(SortOptions.predicate).toEqual "column.a"
expect(SortOptions.reverse).toBe true
describe "when selecting Column A once then selecting Column B once", ->
it "sorts by Column B", ->
SortOptions.toggle("column.a")
SortOptions.toggle("column.b")
expect(SortOptions.predicate).toEqual "column.b"
expect(SortOptions.reverse).toBe false
describe "when selecting Column A twice then selecting Column B once", ->
it "sorts by Column B in reverse order", ->
SortOptions.toggle("column.a")
SortOptions.toggle("column.a")
SortOptions.toggle("column.b")
expect(SortOptions.predicate).toEqual "column.b"
expect(SortOptions.reverse).toBe false