Commit 7eefbca4 authored by Paul Slaughter's avatar Paul Slaughter

Add useFixturesFakeDate helper function

- This simply wraps useFakeDate but
  encapsualtes the args
parent a4a219c7
...@@ -2,7 +2,7 @@ import { GlSprintf, GlLink } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlSprintf, GlLink } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { useFakeDate } from 'helpers/fake_date'; import { useFixturesFakeDate } from 'helpers/fake_date';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
...@@ -21,8 +21,7 @@ const last90DaysData = getJSONFixture( ...@@ -21,8 +21,7 @@ const last90DaysData = getJSONFixture(
); );
describe('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue', () => { describe('ee_component/projects/pipelines/charts/components/deployment_frequency_charts.vue', () => {
// Set the current Date to the same value that is used when generating the fixtures useFixturesFakeDate();
useFakeDate(2015, 6, 3, 10);
let DeploymentFrequencyCharts; let DeploymentFrequencyCharts;
......
import { useFakeDate } from './jest';
// Also see spec/support/helpers/javascript_fixtures_helpers.rb
export const useFixturesFakeDate = () => useFakeDate(2015, 6, 3, 10);
export * from './fake_date'; export * from './fake_date';
export * from './jest'; export * from './jest';
export * from './fixtures';
...@@ -12,6 +12,7 @@ module JavaScriptFixturesHelpers ...@@ -12,6 +12,7 @@ module JavaScriptFixturesHelpers
included do |base| included do |base|
base.around do |example| base.around do |example|
# pick an arbitrary date from the past, so tests are not time dependent # pick an arbitrary date from the past, so tests are not time dependent
# Also see spec/frontend/__helpers__/fake_date/jest.js
Timecop.freeze(Time.utc(2015, 7, 3, 10)) { example.run } Timecop.freeze(Time.utc(2015, 7, 3, 10)) { example.run }
raise NoMethodError.new('You need to set `response` for the fixture generator! This will automatically happen with `type: :controller` or `type: :request`.', 'response') unless respond_to?(:response) raise NoMethodError.new('You need to set `response` for the fixture generator! This will automatically happen with `type: :controller` or `type: :request`.', 'response') unless respond_to?(:response)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment