Skip to content

Commit

Permalink
#157 adds warning when global fixture is called
Browse files Browse the repository at this point in the history
  • Loading branch information
amechi101 committed Apr 5, 2019
1 parent 1559de9 commit 6147d97
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var fixture = core.add;
var Store = require("./store");
require("./xhr");
var canReflect = require("can-reflect");
var canDev = require("can-log/dev/dev");
var ns = require("can-namespace");
// HELPERS START

Expand Down Expand Up @@ -67,7 +68,14 @@ canReflect.assignMap(fixture, {
});

if(typeof window !== "undefined" && typeof require.resolve !== "function") {
window.fixture = fixture;
// window.fixture = fixture;

window.fixture = function(){
debugger
canDev.warn("You using the global fixture. Make sure you import can-fixture.");

return fixture.apply(this, arguments);
};
}


Expand Down
17 changes: 17 additions & 0 deletions test/fixture_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1980,3 +1980,20 @@ if ("onabort" in XMLHttpRequest._XHR.prototype) {
stop();
});
} // END onabort check



testHelpers.dev.devOnlyTest("window.fixture warns when called", function() {
debugger
var teardown = testHelpers.dev.willWarn(/You using the global fixture\. Make sure you import can-fixture\./, function(message, matched) {
if(matched) {
ok(true, "received warning");
}
});

window.fixture("GET /api/products", function(){
return {};
});

teardown();
});

0 comments on commit 6147d97

Please sign in to comment.