applait / finderjs

Finder and file picker library for Firefox OS
http://finder.js.org
MIT License
14 stars 7 forks source link

Write tests for reset method #7

Closed kaustavdm closed 9 years ago

kaustavdm commented 9 years ago

Write specs to ensure that the reset method cleans up data properly.

kumarrishav commented 9 years ago

@kaustavdm seems jai is working on this.

kaustavdm commented 9 years ago

@kumarrishav Oops, thanks! Assigned this to @jaipradeesh

dolftax commented 9 years ago
describe("reset function cleans up data properly", function () {

  var finder = new Applait.Finder();

  beforeEach(function() {
            finder.reset();
  });

  it("filematchcount, searchcompletecount and searchkey is cleared up", function() {

        expect(finder.filematchcount).toBe(0);
        expect(finder.searchcompletecount).toBe(0);
        expect(finder.searchkey).toBe("");
  });
});

@kaustavdm This should work, right?

kumarrishav commented 9 years ago

@jaipradeesh as there is only one function to test, i think there is no need of before each()

dolftax commented 9 years ago

@kumarrishav Yeah! I was in the middle of writing another function. But this was meant to ask Kaustav about the correct way of doing it.

kumarrishav commented 9 years ago

ok cool :)

kaustavdm commented 9 years ago

@jaipradeesh This scenario is slightly more complex. You need to trigger a search and then do the reset. Otherwise, there is nothing to reset and this test will always pass. False positive.

To trigger search, you need to create a mock of navigator.getDeviceStorages and of the enumerate method, so that you can trigger finder.search(searchkey).

Once the search is done, then you trigger reset and compare if everything has been cleaned or not.