Sha256: 47212d14e079c026ae42d18feb21989c04c9c06c487fb95933c9924cbc65b96c

Contents?: true

Size: 1.37 KB

Versions: 13

Compression:

Stored size: 1.37 KB

Contents

describe("toBeCloseTo", function() {
  it("passes when within two decimal places by default", function() {
    var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
      result;

    result = matcher.compare(0, 0);
    expect(result.pass).toBe(true);

    result = matcher.compare(0, 0.001);
    expect(result.pass).toBe(true);
  });

  it("fails when not within two decimal places by default", function() {
    var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
      result;

    result = matcher.compare(0, 0.01);
    expect(result.pass).toBe(false);
  });

  it("accepts an optional precision argument", function() {
    var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
      result;

    result = matcher.compare(0, 0.1, 0);
    expect(result.pass).toBe(true);

    result = matcher.compare(0, 0.0001, 3);
    expect(result.pass).toBe(true);
  });

  it("rounds expected values", function() {
    var matcher = jasmineUnderTest.matchers.toBeCloseTo(),
      result;

    result = matcher.compare(1.23, 1.229);
    expect(result.pass).toBe(true);

    result = matcher.compare(1.23, 1.226);
    expect(result.pass).toBe(true);

    result = matcher.compare(1.23, 1.225);
    expect(result.pass).toBe(true);

    result = matcher.compare(1.23, 1.2249999);
    expect(result.pass).toBe(false);

    result = matcher.compare(1.23, 1.234);
    expect(result.pass).toBe(true);
  });
});

Version data entries

13 entries across 10 versions & 2 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.6.4/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.6.3/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.6.4 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.6.3 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.6.2 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.6.1 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.6.0 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
tdiary-5.0.4 vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.5.2 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.5.1 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js
jasmine-core-2.5.0 ./lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js