77use Fidum \VaporMetricsTile \Stores \VaporEnvironmentMetricsStore ;
88use Fidum \VaporMetricsTile \Tests \TestCase ;
99use Illuminate \Support \Collection ;
10- use Illuminate \Support \Facades \Request ;
1110
1211class BarChartTest extends TestCase
1312{
1413 public function testChartEmptyData ()
1514 {
16- $ chart = app (BarChart::class);
17- $ chartisan = $ chart ->handler (Request::merge ([]));
18- $ object = $ chartisan ->toObject ();
15+ $ factory = BarChart::make ([]);
16+ $ chart = $ factory ->chart ();
1917
20- $ this ->assertSame ([], $ object -> chart ->labels );
21- $ this ->assertSame ($ this ->expectedOptions ('hour ' ), $ chart ->options () );
22- $ this ->assertSame ([], $ object ->datasets [0 ]->values );
18+ $ this ->assertSame ([], $ chart ->labels );
19+ $ this ->assertSame ($ this ->expectedOptions ('hour ' ), $ chart ->options );
20+ $ this ->assertSame ([], $ chart ->datasets [0 ]->values );
2321 }
2422
2523 public function testChartDefaults ()
@@ -30,16 +28,15 @@ public function testChartDefaults()
3028 'averageFunctionDurationByInterval ' => $ data ->toArray (),
3129 ]);
3230
33- $ chart = app (BarChart::class);
34- $ chartisan = $ chart ->handler (Request::merge ([]));
35- $ object = $ chartisan ->toObject ();
31+ $ factory = BarChart::make ([]);
32+ $ chart = $ factory ->chart ();
3633
37- $ this ->assertSame ($ data ->keys ()->toArray (), $ object -> chart ->labels );
38- $ this ->assertSame ($ this ->expectedOptions ('hour ' ), $ chart ->options () );
34+ $ this ->assertSame ($ data ->keys ()->toArray (), $ chart ->labels );
35+ $ this ->assertSame ($ this ->expectedOptions ('hour ' ), $ chart ->options );
3936
4037 $ this ->assertSame (
4138 $ data ->map (fn ($ y , $ x ) => compact ('x ' , 'y ' ))->values ()->toArray (),
42- $ object ->datasets [0 ]->values ,
39+ $ chart ->datasets [0 ]->values ,
4340 );
4441 }
4542
@@ -51,16 +48,15 @@ public function testChartWithSettings()
5148 'totalCliFunctionInvocationsByInterval ' => $ data ->toArray (),
5249 ]);
5350
54- $ chart = app (BarChart::class);
55- $ chartisan = $ chart ->handler (Request::merge (['tileName ' => 'My Env Changed ' , 'type ' => 'cli-invocations-total ' ]));
56- $ object = $ chartisan ->toObject ();
51+ $ factory = BarChart::make (['tileName ' => 'My Env Changed ' , 'type ' => 'cli-invocations-total ' ]);
52+ $ chart = $ factory ->chart ();
5753
58- $ this ->assertSame ($ data ->keys ()->toArray (), $ object -> chart ->labels );
59- $ this ->assertSame ($ this ->expectedOptions ('day ' ), $ chart ->options () );
54+ $ this ->assertSame ($ data ->keys ()->toArray (), $ chart ->labels );
55+ $ this ->assertSame ($ this ->expectedOptions ('day ' ), $ chart ->options );
6056
6157 $ this ->assertSame (
6258 $ data ->map (fn ($ y , $ x ) => compact ('x ' , 'y ' ))->values ()->toArray (),
63- $ object ->datasets [0 ]->values ,
59+ $ chart ->datasets [0 ]->values ,
6460 );
6561 }
6662
@@ -69,23 +65,24 @@ public function testUnit(string $period, string $expectedUnit)
6965 {
7066 config ()->set ('dashboard.tiles.vapor_metrics.period ' , $ period );
7167
72- $ chart = app (BarChart::class);
68+ $ factory = BarChart::make ([]);
69+ $ chart = $ factory ->chart ();
7370
74- $ this ->assertSame ($ this ->expectedOptions ($ expectedUnit ), $ chart ->options () );
71+ $ this ->assertSame ($ this ->expectedOptions ($ expectedUnit ), $ chart ->options );
7572 }
7673
7774 public function unitProvider (): array
7875 {
7976 //1m, 5m, 30m, 1h, 8h, 1d (default), 3d, 7d, 1M
8077 return [
8178 ['1m ' , 'second ' ],
82- ['12m ' , 'minute ' ],
79+ ['5m ' , 'minute ' ],
8380 ['1h ' , 'minute ' ],
84- ['12h ' , 'hour ' ],
81+ ['8h ' , 'hour ' ],
8582 ['1d ' , 'hour ' ],
86- ['12d ' , 'day ' ],
83+ ['7d ' , 'day ' ],
8784 ['1M ' , 'day ' ],
88- ['12M ' , 'week ' ],
85+ ['2M ' , 'week ' ],
8986 ];
9087 }
9188
@@ -106,6 +103,9 @@ private function data(): Collection
106103 private function expectedOptions (string $ unit ): array
107104 {
108105 return [
106+ 'animation ' => [
107+ 'duration ' => 0 ,
108+ ],
109109 'responsive ' => true ,
110110 'maintainAspectRatio ' => false ,
111111 'legend ' => [
0 commit comments