newsuk/times-components

Remove date hacks

craigbilner opened this issue · 0 comments

Do you want to request a feature or report a bug?

feature

What is the current behaviour?

There's code such as:

beforeEach(() => {
    mockDate.set(1514764800000, 0);
  });

  afterEach(() => {
    mockDate.reset();
  });

and

 beforeEach(() => {
    global.Intl = {
      DateTimeFormat: () => ({
        resolvedOptions: () => ({ timeZone: "Europe/London" })
      })
    };
  });

  afterEach(() => {
    global.Intl = realIntl;
  });

sometimes to ensure snapshots pass, which is a maintenance overhead and hard for people to grok as it's global and runs in different environments

What is the expected behaviour?

Look at using property-matchers where possible and/or replace the test if it's doing too much (dependent on an external package)

If this is a feature request, what is the motivation or use case for changing
the behaviour?

simpler more obvious tests