Sha256: bbdb25307138ed19247c3936b1d7ca781345e00ae2c90017783d33beb796cb1e

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

describe('modules.Monotype', function () {
  var Monotype = webfont.modules.Monotype,
      Font = webfont.Font,
      BrowserInfo = webfont.BrowserInfo,
      UserAgent = webfont.UserAgent,
      Version = webfont.Version;

  var configuration = {
    projectId: '01e2ff27-25bf-4801-a23e-73d328e6c7cc',
    api: 'https://fast.fonts.net/jsapidev'
  };

  var fakeDomHelper = null,
      global = null,
      script = {},
      monotype = null,
      load =  null,
      support = null;

  beforeEach(function () {
    global = {};

    fakeDomHelper = {
      loadScript: jasmine.createSpy('loadScript').andCallFake(function (src, callback) {
        script.onload = callback;
        return script;
      }),
      getLoadWindow: jasmine.createSpy('getLoadWindow').andReturn(global)
    };
    support = jasmine.createSpy('support');
    load = jasmine.createSpy('load');

    monotype = new Monotype(fakeDomHelper, configuration);
    monotype.load(load);

    global[Monotype.HOOK + configuration.projectId] = function () {
      return [{fontfamily: 'aachen bold'}, {fontfamily: 'kid print regular'}];
    };

    script.onload();
  });


  it('should create a script element', function () {
    expect(fakeDomHelper.loadScript).toHaveBeenCalled();
    expect(fakeDomHelper.loadScript.calls[0].args[0]).toEqual('https://fast.fonts.net/jsapidev/01e2ff27-25bf-4801-a23e-73d328e6c7cc.js');
    expect(load).toHaveBeenCalledWith([new Font('aachen bold'), new Font('kid print regular')]);
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webfontloader-1.6.28 spec/modules/monotype_spec.js