diff --git a/fixture.js b/fixture.js index e7b2733..0a2704a 100644 --- a/fixture.js +++ b/fixture.js @@ -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 @@ -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); + }; } diff --git a/test/fixture_test.js b/test/fixture_test.js index e177bd7..ba99edf 100644 --- a/test/fixture_test.js +++ b/test/fixture_test.js @@ -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) { @@ -1996,3 +2010,6 @@ if ("onabort" in XMLHttpRequest._XHR.prototype) { stop(); }); } // END onabort check + + +