mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Replaces moment with Grafanas DateTime (#16919)
* Wip: Initial commit * Refactor: Replaces moment.utc( * Refactor: replaces the last isMoment statements * Refactor: Removes almost all moment imports * Refactor: Moves moment_wrapper to grafana/ui * Refactor: Renames momentWrapper * Refactor: Removes one more moment import * Refactor: Removes unitOfTime import * Fix: Fixes Prettier error * Refactor: Renames DateTimeType to DateTime * Refactor: Renames isDateTimeType to isDateTime * Refactor: Renames dateTime to dateTime * Feature: Bans moment imports and types
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import angular from 'angular';
|
||||
import * as dateMath from '@grafana/ui/src/utils/datemath';
|
||||
import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { ElasticDatasource } from '../datasource';
|
||||
import { toUtc, dateTime } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
|
||||
describe('ElasticDatasource', function(this: any) {
|
||||
const backendSrv = {
|
||||
@@ -66,7 +66,7 @@ describe('ElasticDatasource', function(this: any) {
|
||||
|
||||
ctx.ds.testDatasource();
|
||||
|
||||
const today = moment.utc().format('YYYY.MM.DD');
|
||||
const today = toUtc().format('YYYY.MM.DD');
|
||||
expect(requestOptions.url).toBe('http://es.com/asd-' + today + '/_mapping');
|
||||
});
|
||||
});
|
||||
@@ -105,8 +105,8 @@ describe('ElasticDatasource', function(this: any) {
|
||||
|
||||
query = {
|
||||
range: {
|
||||
from: moment.utc([2015, 4, 30, 10]),
|
||||
to: moment.utc([2015, 5, 1, 10]),
|
||||
from: toUtc([2015, 4, 30, 10]),
|
||||
to: toUtc([2015, 5, 1, 10]),
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
@@ -159,8 +159,8 @@ describe('ElasticDatasource', function(this: any) {
|
||||
|
||||
ctx.ds.query({
|
||||
range: {
|
||||
from: moment([2015, 4, 30, 10]),
|
||||
to: moment([2015, 5, 1, 10]),
|
||||
from: dateTime([2015, 4, 30, 10]),
|
||||
to: dateTime([2015, 5, 1, 10]),
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
@@ -441,8 +441,8 @@ describe('ElasticDatasource', function(this: any) {
|
||||
|
||||
ctx.ds.query({
|
||||
range: {
|
||||
from: moment([2015, 4, 30, 10]),
|
||||
to: moment([2015, 5, 1, 10]),
|
||||
from: dateTime([2015, 4, 30, 10]),
|
||||
to: dateTime([2015, 5, 1, 10]),
|
||||
},
|
||||
targets: [
|
||||
{
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
///<amd-dependency path="test/specs/helpers" name="helpers" />
|
||||
|
||||
import moment from 'moment';
|
||||
import { IndexPattern } from '../index_pattern';
|
||||
import { toUtc } from '@grafana/ui/src/utils/moment_wrapper';
|
||||
|
||||
describe('IndexPattern', () => {
|
||||
describe('when getting index for today', () => {
|
||||
test('should return correct index name', () => {
|
||||
const pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
|
||||
const expected = 'asd-' + moment.utc().format('YYYY.MM.DD');
|
||||
const expected = 'asd-' + toUtc().format('YYYY.MM.DD');
|
||||
|
||||
expect(pattern.getIndexForToday()).toBe(expected);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user