import * as ko from 'knockout';
import { SHOWN_EVENT, SHOW_EVENT } from './ko.shareDocModal';
import huePubSub from 'utils/huePubSub';

import 'ext/bootstrap.2.3.2.min';

describe('ko.shareDocModal.js', () => {
  it('should render component', async () => {
    huePubSub.publish(SHOW_EVENT, {
      document: ko.observable({
        isShared: () => false,
        hasErrors: () => false,
        loading: () => false,
        selectedPerm: () => undefined,
        fileEntry: {
          canModify: () => false
        },
        definition: ko.observable({
          name: 'hello',
          perms: {
            read: {
              groups: [],
              users: []
            },
            write: {
              groups: [],
              users: []
            }
          }
        })
      }),
      loadDocument: () => {}
    });

    await new Promise(resolve => {
      huePubSub.subscribeOnce(SHOWN_EVENT, resolve);
    });

    expect(window.document.documentElement.outerHTML).toMatchSnapshot();
  });
});
