1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::DailyBuildGroupReportResultSerializer do
let(:report_result) do
[
double(date: '2020-05-20', group_name: 'rspec', data: { 'coverage' => 79.1 }),
double(date: '2020-05-20', group_name: 'karma', data: { 'coverage' => 90.1 }),
double(date: '2020-05-19', group_name: 'rspec', data: { 'coverage' => 77.1 }),
double(date: '2020-05-19', group_name: 'karma', data: { 'coverage' => 89.1 })
]
end
let(:serializer) { described_class.new.represent(report_result, param_type: 'coverage') }
describe '#to_json' do
let(:json) { Gitlab::Json.parse(serializer.to_json) }
it 'returns an array of group results' do
expect(json).to eq(
[
{
'group_name' => 'rspec',
'data' => [
{ 'date' => '2020-05-20', 'coverage' => 79.1 },
{ 'date' => '2020-05-19', 'coverage' => 77.1 }
]
},
{
'group_name' => 'karma',
'data' => [
{ 'date' => '2020-05-20', 'coverage' => 90.1 },
{ 'date' => '2020-05-19', 'coverage' => 89.1 }
]
}
])
end
end
end
|