Sha256: 8a603e6be553f650cb701eb97bfb0fdf3298764aa152a1f00888fb4b6dbdd2ea

Contents?: true

Size: 1.89 KB

Versions: 4

Compression:

Stored size: 1.89 KB

Contents

// Copyright 2012 Twitter, Inc
// http://www.apache.org/licenses/LICENSE-2.0

var TwitterCldr = require('../../../lib/assets/javascripts/twitter_cldr/en.js');

describe("PostalCodes", function() {
  describe("#all", function() {
    it("checks if some territories are supported", function() {
      expect(TwitterCldr.PostalCodes.territories()).toContain("jp");
    });
    it("checks if invalid territory codes are not supported", function() {
      expect(TwitterCldr.PostalCodes.territories()).not.toContain("xx");
    });
  });

  describe("#territory", function() {
    it("returns '\\d{6}' for the territory 'in'", function() {
      expect(TwitterCldr.PostalCodes.regex_for_territory("in")).toEqual(new RegExp("\\d{6}"));
    });
    it("returns null for invalid territories like 'xx' (say)", function() {
      expect(TwitterCldr.PostalCodes.regex_for_territory("xx")).toBe(null);
    });
  });

  describe("#validity", function() {
    it("returns 'true' for the territory 'us' and code '94103'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("us", "94103")).toBe(true);
    });
    it("returns 'true' for the territory 'gb' and code 'BS98 1TL'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("gb", "BS98 1TL")).toBe(true);
    });
    it("returns 'true' for the territory 'se' and code '280 12'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("se", "280 12")).toBe(true);
    });
    it("returns 'false' for the territory 'us' and code '9410'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("us", "9410")).toBe(false);
    });
    it("returns 'false' for the territory 'us' and code 'BS98 1TL'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("us", "BS98 1TL")).toBe(false);
    });
    it("returns 'false' for the territory 'gb' and code '280 12'", function() {
      expect(TwitterCldr.PostalCodes.is_valid("gb", "280 12")).toBe(false);
    });
  });

});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
twitter_cldr_js-2.4.0 spec/js/shared/postal_codes.spec.js
twitter_cldr_js-2.3.2 spec/js/shared/postal_codes.spec.js
twitter_cldr_js-2.3.1 spec/js/shared/postal_codes.spec.js
twitter_cldr_js-2.3.0 spec/js/shared/postal_codes.spec.js