Skip to content

Commit

Permalink
Merge branch 'master' of github.com:canjs/can-fixture
Browse files Browse the repository at this point in the history
Merged changes to master for #157 issue: adds warning when global fixture is called

Merged changes to master for #229 issue: ix the deprecated group’s name in the docs
  • Loading branch information
amechi101 committed May 1, 2019
2 parents 0f3a0fa + c237c6c commit dd69873
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 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,12 @@ canReflect.assignMap(fixture, {
});

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

window.fixture = function(){
canDev.warn("You are 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 @@ -1974,6 +1974,20 @@ if ("onabort" in XMLHttpRequest._XHR.prototype) {
xhr.send();
});

testHelpers.dev.devOnlyTest("window.fixture warns when called", function() {
var teardown = testHelpers.dev.willWarn(/You are 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();
});

testHelpers.dev.devOnlyTest("Works with steal-clone", function() {
steal.loader.import("steal-clone", { name: "can-fixture" })
.then(function(clone) {
Expand All @@ -1996,3 +2010,6 @@ if ("onabort" in XMLHttpRequest._XHR.prototype) {
stop();
});
} // END onabort check



0 comments on commit dd69873

Please sign in to comment.