Sha256: 474a4ed3396e98f26673450d0f54e154ce5848a4b5325d8a9063f9105336e326

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 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("CodePoints", function() {
  describe("#to_char", function() {
    it("converts unicode code points to the actual character", function() {
      expect(TwitterCldr.CodePoints.to_char(0x221E)).toEqual('∞');
    });
  });
  describe("#from_char", function() {
    it("converts a character to a unicode code point", function() {
      expect(TwitterCldr.CodePoints.from_char('∞')).toEqual(0x221E);
    });
  });
  describe("#to_chars", function() {
    it("should handle an empty array", function() {
      expect(TwitterCldr.CodePoints.to_chars([])).toEqual([]);
    });
    it("converts an array of unicode code points to an array of chars", function() {
      expect(TwitterCldr.CodePoints.to_chars([0x65, 0x73, 0x70])).toEqual(['e', 's', 'p']);
    });
  });
  describe("#from_chars", function() {
    it("should handle an empty array", function() {
      expect(TwitterCldr.CodePoints.from_chars([])).toEqual([]);
    });
    it("converts an array of chars to an array of unicode code points", function() {
      expect(TwitterCldr.CodePoints.from_chars(['e', 's', 'p'])).toEqual([0x65, 0x73, 0x70]);
    });
  });
  describe("#to_string", function() {
    it("should handle an empty array", function() {
      expect(TwitterCldr.CodePoints.to_string([])).toEqual('');
    });
    it("converts an array of unicode code points to a string", function() {
      expect(TwitterCldr.CodePoints.to_string([0x65, 0x73, 0x70, 0x61, 0xF1, 0x6F, 0x6C])).toEqual('español');
    });
  });
  describe("#from_string", function() {
    it("should handle an empty string", function() {
      expect(TwitterCldr.CodePoints.from_string('')).toEqual([]);
    });
    it("converts a string into an array of unicode code points", function() {
      expect(TwitterCldr.CodePoints.from_string('español')).toEqual([0x65, 0x73, 0x70, 0x61, 0xF1, 0x6F, 0x6C]);
    });
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twitter_cldr_js-2.4.0 spec/js/utils/code_points.spec.js