"use strict";

var config = require('./config');

var skin = require('./skin');

function createStyle() {
  return {
    use: jest.fn(),
    unuse: jest.fn() //TODO Test it

  };
}

describe('skin', function () {
  beforeAll(function () {
    config.testConfig();
  });
  it('rejects loading if loader not configured', function () {
    return skin.loadSkin().then(function () {
      throw new Error('This should not be reached');
    }).catch(function (e) {
      expect(e.message).toBe('Skin loader have not been configured yet, check startup sequence');
    });
  });
  it('resolves with styles and uses them', function () {
    var style = createStyle();
    skin.setSkinLoader(function () {
      return Promise.resolve(style);
    });
    return skin.loadSkin().then(function (stl) {
      expect(stl).toBe(style);
      expect(stl.use).toBeCalledTimes(1);
    });
  });
});