mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-25 09:30:01 +00:00 
			
		
		
		
	E.g. for "0" we have to contruct a PropertyName with Type::Number so it looks in the indexed properties as expected.
		
			
				
	
	
		
			88 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("plain property", () => {
 | |
|     let o = { foo: "bar" };
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty("foo");
 | |
|     expect(o).toHaveEnumerableProperty("foo");
 | |
|     expect(o).toHaveWritableProperty("foo");
 | |
|     expect(o).toHaveValueProperty("foo", "bar");
 | |
|     expect(o).not.toHaveGetterProperty("foo");
 | |
|     expect(o).not.toHaveSetterProperty("foo");
 | |
| });
 | |
| 
 | |
| test("symbol property", () => {
 | |
|     let s = Symbol("foo");
 | |
|     let o = { [s]: "bar" };
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty(s);
 | |
|     expect(o).toHaveEnumerableProperty(s);
 | |
|     expect(o).toHaveWritableProperty(s);
 | |
|     expect(o).toHaveValueProperty(s, "bar");
 | |
|     expect(o).not.toHaveGetterProperty(s);
 | |
|     expect(o).not.toHaveSetterProperty(s);
 | |
| });
 | |
| 
 | |
| test("getter property", () => {
 | |
|     let o = { get foo() {} };
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty("foo");
 | |
|     expect(o).toHaveEnumerableProperty("foo");
 | |
|     expect(o).not.toHaveWritableProperty("foo");
 | |
|     expect(o).not.toHaveValueProperty("foo");
 | |
|     expect(o).toHaveGetterProperty("foo");
 | |
|     expect(o).not.toHaveSetterProperty("foo");
 | |
| });
 | |
| 
 | |
| test("setter property", () => {
 | |
|     let o = { set foo(_) {} };
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty("foo");
 | |
|     expect(o).toHaveEnumerableProperty("foo");
 | |
|     expect(o).not.toHaveWritableProperty("foo");
 | |
|     expect(o).not.toHaveValueProperty("foo");
 | |
|     expect(o).not.toHaveGetterProperty("foo");
 | |
|     expect(o).toHaveSetterProperty("foo");
 | |
| });
 | |
| 
 | |
| test("indexed property", () => {
 | |
|     let o = { 0: "foo" };
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty(0);
 | |
|     expect(o).toHaveEnumerableProperty(0);
 | |
|     expect(o).toHaveWritableProperty(0);
 | |
|     expect(o).toHaveValueProperty(0, "foo");
 | |
|     expect(o).not.toHaveGetterProperty(0);
 | |
|     expect(o).not.toHaveSetterProperty(0);
 | |
| 
 | |
|     expect(o).toHaveConfigurableProperty("0");
 | |
|     expect(o).toHaveEnumerableProperty("0");
 | |
|     expect(o).toHaveWritableProperty("0");
 | |
|     expect(o).toHaveValueProperty("0", "foo");
 | |
|     expect(o).not.toHaveGetterProperty("0");
 | |
|     expect(o).not.toHaveSetterProperty("0");
 | |
| });
 | |
| 
 | |
| test("defined property", () => {
 | |
|     let o = {};
 | |
| 
 | |
|     const attributes = {
 | |
|         enumerable: false,
 | |
|         writable: true,
 | |
|         value: 10,
 | |
|     };
 | |
|     Object.defineProperty(o, "foo", attributes);
 | |
|     Object.defineProperty(o, 1, attributes);
 | |
| 
 | |
|     expect(o).not.toHaveConfigurableProperty("foo");
 | |
|     expect(o).not.toHaveEnumerableProperty("foo");
 | |
|     expect(o).toHaveWritableProperty("foo");
 | |
|     expect(o).toHaveValueProperty("foo", 10);
 | |
|     expect(o).not.toHaveGetterProperty("foo");
 | |
|     expect(o).not.toHaveSetterProperty("foo");
 | |
| 
 | |
|     expect(o).not.toHaveConfigurableProperty(1);
 | |
|     expect(o).not.toHaveEnumerableProperty(1);
 | |
|     expect(o).toHaveWritableProperty(1);
 | |
|     expect(o).toHaveValueProperty(1, 10);
 | |
|     expect(o).not.toHaveGetterProperty(1);
 | |
|     expect(o).not.toHaveSetterProperty(1);
 | |
| });
 |