const rxStyles = /(mui|MuiBox-root|makeStyles|Private)([^\s]*)-\d+/g;

const snapshotSerializers = [
  {
    test: (val) => {
      return val && typeof val === "string" && val.search(rxStyles) > -1;
    },
    print: (val) => {
      let str = val;
      str = str.replace(rxStyles, "$1$2-0");

      return `"${str}"`;
    },
  },
];

const addSnapshotSerializer = (expect) => {
  snapshotSerializers.forEach((serializer) => {
    expect.addSnapshotSerializer(serializer);
  });
};

export default addSnapshotSerializer;
