Sha256: c9ffb83916a62484c6712c423f5d720d744cec2814f84d249f45bd5b45a6748e

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: false

require File.expand_path('spec_helper', __dir__)

module Danger
  describe Danger::DangerAppSizeReport do
    it 'should be a plugin' do
      expect(Danger::DangerAppSizeReport.new(nil)).to be_a Danger::Plugin
    end

    describe 'with Dangerfile' do
      before do
        @dangerfile = testing_dangerfile
        @app_size_report = @dangerfile.app_size_report
      end

      it 'Converts App Size Report to JSON' do
        json_string = @app_size_report.report_json("#{File.dirname(__dir__)}/Resources/App\ Thinning\ Size\ Report.txt")

        expected_json = File.read("#{File.dirname(__dir__)}/Resources/expectedReportJSON.json")

        expect(json_string).to eq(expected_json)
      end

      it 'Generates IOS App Size Danger Report' do
        @app_size_report.flag_ios_violations(
          "#{File.dirname(__dir__)}/Resources/App\ Thinning\ Size\ Report.txt",
          build_type: 'Clip',
          size_limit: 12,
          limit_unit: 'MB'
        )

        expect(@dangerfile.status_report[:warnings]).to eq(['The size limit of 10 MB has been exceeded by one or more variants'])
      end

      it 'Generates Android App Size Danger Report' do
        @app_size_report.flag_android_violations(
          "#{File.dirname(__dir__)}/Resources/app.aab",
          "#{File.dirname(__dir__)}/Resources/testKey1",
          'testKey1',
          'testKey1',
          'testKey1',
          screen_densities: %w[MDPI HDPI XHDPI XXHDPI XXXHDPI],
          languages: %w[en de da es fr it nb nl sv],
          build_type: 'Instant',
          size_limit: 1.459,
          limit_unit: 'MB'
        )

        expect(@dangerfile.status_report[:warnings]).to eq(['The size limit of 1.459 MB has been exceeded by 18 variants'])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-app_size_report-1.0.0 spec/app_size_report_spec.rb