當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript change_tracker.ChangeTracker類代碼示例

本文整理匯總了TypeScript中app/features/dashboard/change_tracker.ChangeTracker的典型用法代碼示例。如果您正苦於以下問題:TypeScript ChangeTracker類的具體用法?TypeScript ChangeTracker怎麽用?TypeScript ChangeTracker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ChangeTracker類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('ChangeTracker', () => {
  let rootScope;
  let location;
  const timeout = () => {};
  let tracker: ChangeTracker;
  let dash;
  let scope;

  beforeEach(() => {
    dash = new DashboardModel({
      refresh: false,
      panels: [
        {
          id: 1,
          type: 'graph',
          gridPos: { x: 0, y: 0, w: 24, h: 6 },
          legend: { sortDesc: false },
        },
        {
          id: 2,
          type: 'row',
          gridPos: { x: 0, y: 6, w: 24, h: 2 },
          collapsed: true,
          panels: [
            { id: 3, type: 'graph', gridPos: { x: 0, y: 6, w: 12, h: 2 } },
            { id: 4, type: 'graph', gridPos: { x: 12, y: 6, w: 12, h: 2 } },
          ],
        },
        { id: 5, type: 'row', gridPos: { x: 0, y: 6, w: 1, h: 1 } },
      ],
    });

    scope = {
      appEvent: jest.fn(),
      onAppEvent: jest.fn(),
      $on: jest.fn(),
    };

    rootScope = {
      appEvent: jest.fn(),
      onAppEvent: jest.fn(),
      $on: jest.fn(),
    };

    location = {
      path: jest.fn(),
    };

    tracker = new ChangeTracker(dash, scope, undefined, location, window, timeout, contextSrv, rootScope);
  });

  it('No changes should not have changes', () => {
    expect(tracker.hasChanges()).toBe(false);
  });

  it('Simple change should be registered', () => {
    dash.title = 'google';
    expect(tracker.hasChanges()).toBe(true);
  });

  it('Should ignore a lot of changes', () => {
    dash.time = { from: '1h' };
    dash.refresh = true;
    dash.schemaVersion = 10;
    expect(tracker.hasChanges()).toBe(false);
  });

  it('Should ignore .iteration changes', () => {
    dash.iteration = new Date().getTime() + 1;
    expect(tracker.hasChanges()).toBe(false);
  });

  it('Should ignore row collapse change', () => {
    dash.toggleRow(dash.panels[1]);
    expect(tracker.hasChanges()).toBe(false);
  });

  it('Should ignore panel legend changes', () => {
    dash.panels[0].legend.sortDesc = true;
    dash.panels[0].legend.sort = 'avg';
    expect(tracker.hasChanges()).toBe(false);
  });

  it('Should ignore panel repeats', () => {
    dash.panels.push(new PanelModel({ repeatPanelId: 10 }));
    expect(tracker.hasChanges()).toBe(false);
  });
});
開發者ID:ArcticSnowman,項目名稱:grafana,代碼行數:88,代碼來源:change_tracker.test.ts

示例2: it

 it('Should ignore panel legend changes', () => {
   dash.panels[0].legend.sortDesc = true;
   dash.panels[0].legend.sort = 'avg';
   expect(tracker.hasChanges()).toBe(false);
 });
開發者ID:ArcticSnowman,項目名稱:grafana,代碼行數:5,代碼來源:change_tracker.test.ts

示例3: it

 it('Should ignore panel repeats', () => {
   dash.panels.push(new PanelModel({ repeatPanelId: 10 }));
   expect(tracker.hasChanges()).toBe(false);
 });
開發者ID:cboggs,項目名稱:grafana,代碼行數:4,代碼來源:change_tracker.jest.ts


注:本文中的app/features/dashboard/change_tracker.ChangeTracker類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。