These are chat archives for canjs/canjs

22nd
May 2017
Jeroen Cornelissen
@jeroencornelissen
May 22 2017 13:04
If you set type 'date' on a DefineMap property, the result is null.
I’ve submitted an issue: canjs/can-define#203
Frank Lemanschik
@frank-dspeed
May 22 2017 13:06
maybe you should set new Date().toString()
Jeroen Cornelissen
@jeroencornelissen
May 22 2017 13:07
@frank-dspeed all other browsers work, only in Safari this is an issue.
Matthew Phillips
@matthewp
May 22 2017 15:04
trying to find someone to look into this bug
Gira Minus
@gKreator
May 22 2017 17:07
Yeah i keep dates as strings
Pedro Mendes
@pmgmendes
May 22 2017 17:34
Hi all,
I'm struggling to setup a fixture that enables the testing of a model where the method getData is being overwritten to allow custom URL.
In the example bellow the fixture is matched (and the test passes) only if the query parameter "id" is not present in the url passed to Todo.get() nor in the fixture key.
Am I missing something?
var DefineMap = require("can-define/map/map");
var DefineList = require("can-define/list/list");
var connect = require("can-connect");
var set = require("can-set");
var QUnit = require("steal-qunit");
var fixture = require("can-fixture");

const Todo = DefineMap.extend({
  id: "string"
});

Todo.List = DefineList.extend({
  "#": Todo
});

Todo.algebra = new set.Algebra(set.props.id("id"));

Todo.connection = connect([
  require("can-connect/constructor/"),
  require("can-connect/can/map/"),
  require("can-connect/constructor/store/"),
  require("can-connect/data/callbacks/"),
  require("can-connect/data/parse/"),
  require("can-connect/data/url/")
], {
  Map: Todo,
  List: Todo.List,
  url: {
    getData: "{url}"
  }
});

QUnit.module("Todo module");

QUnit.test("full custom url", function(assert) {

  fixture("GET /todos?id=A", {id: "A"});

  QUnit.stop();
  Todo.get({url: "/todos?id=A"}).then(todo => {
    assert.equal(todo.id, "A");
    QUnit.start();
  });

});
Thomas Sieverding
@Bajix
May 22 2017 18:32
@pmgmendes you should use something like:
  url: {
    resource: config.hosts.api + ‘/todo'
  }
///
fixture({
  'GET /todos': store.findAll,
  'GET /todos/{_id}': store.findOne,
  'POST /todos': store.create,
  'PUT /todos/{_id}': store.update,
  'DELETE /todos/{_id}': store.destroy
});
I don’t think your url configration is parseable
If you need super fine-grain control, you should provide your own method
Pedro Mendes
@pmgmendes
May 22 2017 22:51

@Bajix Thanks for the reply.
Because the request is being done as expected at http://127.0.0.1:8080/todos?id=A I think the getData string is parsed correctly.
The main issue is related to the fixture not being returned because both exact and loose matches fail - can-fixture/core.js#get(xhrSettings).
When the fixture is initialized with no query params works just fine

 fixture("/todos", {id: "A"});

I'v also tried the fixture.store usage as you exemplified and documented in can-fixture/README.md

var todoStore = fixture.store([{id: "A"}], Todo.algebra);

fixture("GET /todos?id=A", todoStore.getData);

Still no luck though..

I would like to avoid writing my own common interface implementations just to provide a specific URL for the getData interface. I think I would end up repeating a big part of the boilerplate code in data/url (like makeAjax, etc).