"use strict";

var _testUtils = require("react-dom/test-utils");

window.matchMedia = function (_query) {
  return {
    _matches: false,

    // $FlowFixMe - Flow doesn't like getters or setters
    get matches() {
      return this._matches;
    },

    // $FlowFixMe - Flow doesn't like getters or setters
    set matches(newValue) {
      var _this = this;

      var hasChanged = newValue !== this._matches;
      this._matches = newValue;

      if (hasChanged) {
        (0, _testUtils.act)(function () {
          _this.listeners.forEach(function (listener) {
            return listener();
          });
        });
      }
    },

    listeners: new Set(),
    addListener: function addListener(listener) {
      this.listeners.add(listener);
    }
  };
};