在ember测试中访问Chrome URL对象

时间:2016-02-16 15:26:24

标签: ember.js ember-qunit

我正在测试一个ember组件,该组件将调用一个返回promise的外部方法,并从导航器的URL对象调用createObjectURL:

var query = from d in model.StringDatas
        where d.DCString.DCDistributionBox.DataLogger.ProjectID == projectID
        where d.TimeStamp >= fromDate
        where d.TimeStamp < tillDate
        group d by DbFunctions.AddMinutes(DateTime.MinValue, DbFunctions.DiffMinutes(DateTime.MinValue, d.TimeStamp) / minuteInterval * minuteInterval) into g
        select new
        {
            TimeStamp = g.Key,
            DCCurrentMin = g.Min(v => v.DCCurrent / v.DCString.CurrentMPP),
            DCCurrentMax = g.Max(v => v.DCCurrent / v.DCString.CurrentMPP),
            DCCurrentAvg = g.Average(v => v.DCCurrent / v.DCString.CurrentMPP),
            DCCurrentStDev = DbFunctions.StandardDeviation(g.Select(v => v.DCCurrent / v.DCString.CurrentMPP))
        };

var queryResult= query.ToList();

但是,测试将始终返回:

    @fetch(@get 'self').then((blob) =>
      url = URL.createObjectURL blob
      @set 'url', url
    )

我尝试创建服务并注入它,创建一个对象并将其传递给 @subject()方法,但仍然如此。 有没有办法在ember测试中访问 chrome 浏览器的window.URL对象?

1 个答案:

答案 0 :(得分:0)

我刚刚在这里找到答案:Failed to execute 'createObjectURL' on 'URL':

我需要先创建一个blob,然后将其传递给 createObjectURL 函数。