appendto/jquery-mockjax — Issue #54: Keep the mocking data object intact
Author: jsgoupil
Created: 2012-02-02 20:38:31+00:00
State: open

It seems the data object gets replaced in the mock object after calling matching an ajax call.
This seems the right thing to do when you are trying to match an exact object, but it doesn't work if you want to match subsequent ajax calls with a "wildcard".

This is the problem:

$.mockjax({
url: "/path/to/validate",
data: { remote: { test: function(data) {
return data !== "hello";
}
}
},
responseTime: 1000,
responseText: "false"
});

$.mockjax({
url: "/path/to/validate",
data: { remote: "hello" },
responseTime: 1000,
responseText: "true"
});

In this case, after calling ajax once, the first mockjax gets replaced and will not behave like it should afterwards...

Is there a way to achieve this problem?
Basically, any ajax calls that are not equal to "hello" should fail.