summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries/LibJS/Tests')
-rw-r--r--Libraries/LibJS/Tests/builtins/String/String.prototype-generic-functions.js1
-rw-r--r--Libraries/LibJS/Tests/builtins/String/String.prototype.charCodeAt.js21
2 files changed, 22 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/builtins/String/String.prototype-generic-functions.js b/Libraries/LibJS/Tests/builtins/String/String.prototype-generic-functions.js
index 3d7d7468b6..f5c0ffa854 100644
--- a/Libraries/LibJS/Tests/builtins/String/String.prototype-generic-functions.js
+++ b/Libraries/LibJS/Tests/builtins/String/String.prototype-generic-functions.js
@@ -1,6 +1,7 @@
test("basic functionality", () => {
const genericStringPrototypeFunctions = [
"charAt",
+ "charCodeAt",
"repeat",
"startsWith",
"indexOf",
diff --git a/Libraries/LibJS/Tests/builtins/String/String.prototype.charCodeAt.js b/Libraries/LibJS/Tests/builtins/String/String.prototype.charCodeAt.js
new file mode 100644
index 0000000000..e7ebd9d0d3
--- /dev/null
+++ b/Libraries/LibJS/Tests/builtins/String/String.prototype.charCodeAt.js
@@ -0,0 +1,21 @@
+test("basic functionality", () => {
+ expect(String.prototype.charAt).toHaveLength(1);
+
+ var s = "Foobar";
+ expect(typeof s).toBe("string");
+ expect(s).toHaveLength(6);
+
+ expect(s.charCodeAt(0)).toBe(70);
+ expect(s.charCodeAt(1)).toBe(111);
+ expect(s.charCodeAt(2)).toBe(111);
+ expect(s.charCodeAt(3)).toBe(98);
+ expect(s.charCodeAt(4)).toBe(97);
+ expect(s.charCodeAt(5)).toBe(114);
+ expect(s.charCodeAt(6)).toBe(NaN);
+ expect(s.charCodeAt(-1)).toBe(NaN);
+
+ expect(s.charCodeAt()).toBe(70);
+ expect(s.charCodeAt(NaN)).toBe(70);
+ expect(s.charCodeAt("foo")).toBe(70);
+ expect(s.charCodeAt(undefined)).toBe(70);
+});