"use strict";

var _react = _interopRequireDefault(require("react"));
var _reactNative = require("@testing-library/react-native");
var _avatar = _interopRequireDefault(require("./avatar"));
var _themeContext = require("../../../theme/src/theme-context");
var _icon = _interopRequireDefault(require("../../atoms/icon/icon"));
var _withBadge = _interopRequireDefault(require("../badge/withBadge"));
var _stack = _interopRequireDefault(require("../../atoms/stack/stack"));
var _avatarGroup = _interopRequireDefault(require("./avatar-group"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
jest.useFakeTimers();
describe("Molecules/Avatar", () => {
  it("passes the snapshot test for different sizes", () => {
    const tree = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_stack.default, {
      direction: "horizontal",
      spacing: "s"
    }, /*#__PURE__*/_react.default.createElement(_avatar.default, {
      src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg",
      size: "xs"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg",
      size: "s"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg",
      size: "m"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg",
      size: "l"
    })), /*#__PURE__*/_react.default.createElement(_stack.default, {
      direction: "horizontal",
      spacing: "s",
      mt: "s"
    }, /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "red",
      name: "Rohit Agrawal",
      size: "xs"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "red",
      name: "John",
      size: "s"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "red",
      name: "Some guy",
      size: "m"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "red",
      name: "YOYO",
      size: "l"
    }))))).toJSON();
    expect(tree).toMatchSnapshot();
  });
  it("passes the snapshot test for fallback support", () => {
    const tree = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(_stack.default, {
      direction: "horizontal",
      spacing: "s"
    }, /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "red",
      name: "Rohit Agrawal"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      src: "https://4kwallpapers.com/imas/wallpapers/macos-big-sur-apple-layers-fluidic-colorful-wwdc-stock-2560x1440-1455.jpg",
      backgroundColor: "red",
      fallbackSource: {
        uri: "https://cdn.segmentnext.com/wp-content/themes/segmentnext/images/no-image-available.jpg"
      }
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      backgroundColor: "neutral.200",
      fallbackComponent: /*#__PURE__*/_react.default.createElement(_icon.default, {
        iconFamily: "FontAwesome",
        iconName: "user-circle",
        color: "neutral.600",
        rawSize: 40
      })
    })))).toJSON();
    expect(tree).toMatchSnapshot();
  });
  it("withBadge HOC works as expected", () => {
    const Wrapper = () => {
      const OnlineAvatar = (0, _withBadge.default)(undefined, {
        placement: "bottomRight",
        backgroundColor: "success.500",
        size: "s",
        minW: 15,
        h: 15,
        offset: 0
      })(_avatar.default);
      const OfflineAvatar = (0, _withBadge.default)(0, {
        placement: "bottomRight",
        backgroundColor: "danger.500",
        size: "s",
        offset: 0
      })(_avatar.default);
      const AvatarWithEdit = (0, _withBadge.default)( /*#__PURE__*/_react.default.createElement(_icon.default, {
        iconFamily: "Ionicons",
        iconName: "pencil",
        size: "s",
        color: "white"
      }), {
        placement: "bottomRight",
        size: "m",
        onPress: () => {
          console.log("PRESSED!");
        }
      })(_avatar.default);
      return /*#__PURE__*/_react.default.createElement(_stack.default, {
        direction: "horizontal",
        spacing: "s"
      }, /*#__PURE__*/_react.default.createElement(OnlineAvatar, {
        backgroundColor: "cyan",
        src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg"
      }), /*#__PURE__*/_react.default.createElement(OfflineAvatar, {
        backgroundColor: "cyan",
        name: "Rohit Agrawal"
      }), /*#__PURE__*/_react.default.createElement(AvatarWithEdit, {
        backgroundColor: "red"
      }));
    };
    const root = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(Wrapper, null)));
    const tree = root.toJSON();
    expect(tree).toMatchSnapshot();
    expect(root.getByText("0")).toBeTruthy();
  });
  it("passes the snapshot test when used in a group", () => {
    const tree = (0, _reactNative.render)( /*#__PURE__*/_react.default.createElement(_themeContext.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(_avatarGroup.default, {
      spacing: "2xl",
      max: 2,
      truncatedBackgroundColor: "neutral.200"
    }, /*#__PURE__*/_react.default.createElement(_avatar.default, {
      name: "Rohit Agrawal",
      src: "https://pbs.twimg.com/profile_images/1419369145058041856/eshLFaDy_400x400.jpg"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      name: "Rohit Agrawal",
      src: "https://avatars.githubusercontent.com/u/29514438?s=400&u=d194d5de8df93f55038130ccc66429f94f8f900f&v=4"
    }), /*#__PURE__*/_react.default.createElement(_avatar.default, {
      name: "Rohit Agrawal",
      src: "https://instagram.fdel1-3.fna.fbcdn.net/v/t51.2885-19/s320x320/160616189_1075891466264003_198594308312142696_n.jpg?_nc_ht=instagram.fdel1-3.fna.fbcdn.net&_nc_cat=111&_nc_ohc=-URhWepekUsAX_wt_-J&edm=ABfd0MgBAAAA&ccb=7-4&oh=00_AT-caDqy7XqUUTkGv5_QytlFTxtdZ2wVhZDgB4vU3Jl2qQ&oe=61DF5972&_nc_sid=7bff83"
    })))).toJSON();
    expect(tree).toMatchSnapshot();
  });
});
//# sourceMappingURL=avatar.spec.js.map