Sha256: 6fd35a50ce10f91a73758f9f85a310785beeeb05fce079b70401c1308d534152

Contents?: true

Size: 1.91 KB

Versions: 15

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'

describe SCSSLint::Linter::UnnecessaryMantissa do
  context 'when value is zero' do
    let(:scss) { <<-SCSS }
      p {
        margin: 0;
        padding: func(0);
        top: 0em;
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when value contains no mantissa' do
    let(:scss) { <<-SCSS }
      p {
        margin: 1;
        padding: func(1);
        top: 1em;
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when value contains a mantissa with a zero' do
    let(:scss) { <<-SCSS }
      p {
        margin: 1.0;
        padding: func(1.0);
        top: 1.0em;
      }
    SCSS

    it { should report_lint line: 2 }
    it { should report_lint line: 3 }
    it { should report_lint line: 4 }
  end

  context 'when value contains a mantissa with multiple zeroes' do
    let(:scss) { <<-SCSS }
      p {
        margin: 1.000;
        padding: func(1.000);
        top: 1.000em;
      }
    SCSS

    it { should report_lint line: 2 }
    it { should report_lint line: 3 }
    it { should report_lint line: 4 }
  end

  context 'when value contains a mantissa with multiple zeroes followed by a number' do
    let(:scss) { <<-SCSS }
      p {
        margin: 1.0001;
        padding: func(1.0001);
        top: 1.0001em;
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a decimal value appears in a single-quoted string' do
    let(:scss) { <<-SCSS }
      p {
        content: '1.0';
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a decimal value appears in a double-quoted string' do
    let(:scss) { <<-SCSS }
      p {
        content: "1.0";
      }
    SCSS

    it { should_not report_lint }
  end

  context 'when a decimal value appears in a URL' do
    let(:scss) { <<-SCSS }
      p {
        background: url(https://www.example.com/v1.0/image.jpg);
      }
    SCSS

    it { should_not report_lint }
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
scss_lint-0.60.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.59.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.58.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.57.1 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.57.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.56.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.55.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.54.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.53.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.52.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.51.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.50.3 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.50.2 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.50.1 spec/scss_lint/linter/unnecessary_mantissa_spec.rb
scss_lint-0.50.0 spec/scss_lint/linter/unnecessary_mantissa_spec.rb