Deal with provider.open edge case in new provider-agnostic tests. Fixes issue #127.

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2014-03-03 19:11:31 -05:00
parent 7d6bd98a31
commit 23a9861e82
1 changed files with 8 additions and 4 deletions

View File

@ -3,7 +3,7 @@ define(["Filer", "util"], function(Filer, util) {
// We reuse the same set of tests for all adapters. // We reuse the same set of tests for all adapters.
// buildTestsFor() creates a set of tests bound to an // buildTestsFor() creates a set of tests bound to an
// adapter, and uses the provider set on the query string // adapter, and uses the provider set on the query string
// (defaults to Memory, see test-utils.js). // (defaults to best available/supported provider, see test-utils.js).
function buildTestsFor(adapterName, buildAdapter) { function buildTestsFor(adapterName, buildAdapter) {
function encode(str) { function encode(str) {
// TextEncoder is either native, or shimmed by Filer // TextEncoder is either native, or shimmed by Filer
@ -38,7 +38,7 @@ define(["Filer", "util"], function(Filer, util) {
}); });
}); });
describe("open a Memory provider with an " + adapterName + " adapter", function() { describe("open a provider with an " + adapterName + " adapter", function() {
beforeEach(util.setup); beforeEach(util.setup);
afterEach(util.cleanup); afterEach(util.cleanup);
@ -46,13 +46,17 @@ define(["Filer", "util"], function(Filer, util) {
var provider = createProvider(); var provider = createProvider();
provider.open(function(error, firstAccess) { provider.open(function(error, firstAccess) {
expect(error).not.to.exist; expect(error).not.to.exist;
expect(firstAccess).to.be.true; // NOTE: we test firstAccess logic in the individual provider tests
// (see tests/spec/providers/*) but can't easily/actually test it here,
// since the provider-agnostic code in test-utils pre-creates a
// FileSystem object, thus eating the first access info.
// See https://github.com/js-platform/filer/issues/127
done(); done();
}); });
}); });
}); });
describe("Read/Write operations on a Memory provider with an " + adapterName + " adapter", function() { describe("Read/Write operations on a provider with an " + adapterName + " adapter", function() {
beforeEach(util.setup); beforeEach(util.setup);
afterEach(util.cleanup); afterEach(util.cleanup);