Best JavaScript code snippet using cypress
S7RequestGrouper.test.js
Source:S7RequestGrouper.test.js
...1639 expect(result[0].Write).toEqual(true);1640 expect(result[0].Offset).toEqual(1);1641 expect(result[0].Length).toEqual(2);1642 expect(result[0].DBNumber).toEqual(1);1643 expect(Object.values(result[0].VariableConnections).length).toEqual(1);1644 expect(Object.values(result[0].VariableConnections)[0].variable).toEqual(1645 variable11646 );1647 expect(1648 Object.values(result[0].VariableConnections)[0].requestOffset1649 ).toEqual(0);1650 expect(Object.values(result[0].VariableConnections)[0].length).toEqual(2);1651 //Checking request 2 - containing only variable 21652 expect(result[1].AreaType).toEqual("DB");1653 expect(result[1].Write).toEqual(false);1654 expect(result[1].Offset).toEqual(3);1655 expect(result[1].Length).toEqual(2);1656 expect(result[1].DBNumber).toEqual(1);1657 expect(Object.values(result[1].VariableConnections).length).toEqual(1);1658 expect(Object.values(result[1].VariableConnections)[0].variable).toEqual(1659 variable21660 );1661 expect(1662 Object.values(result[1].VariableConnections)[0].requestOffset1663 ).toEqual(0);1664 expect(Object.values(result[1].VariableConnections)[0].length).toEqual(2);1665 //Checking request 3 - containing only variable 31666 expect(result[2].AreaType).toEqual("DB");1667 expect(result[2].Write).toEqual(true);1668 expect(result[2].Offset).toEqual(5);1669 expect(result[2].Length).toEqual(2);1670 expect(result[2].DBNumber).toEqual(2);1671 expect(Object.values(result[2].VariableConnections).length).toEqual(1);1672 expect(Object.values(result[2].VariableConnections)[0].variable).toEqual(1673 variable31674 );1675 expect(1676 Object.values(result[2].VariableConnections)[0].requestOffset1677 ).toEqual(0);1678 expect(Object.values(result[2].VariableConnections)[0].length).toEqual(2);1679 //Checking request 4 - containing only variable 41680 expect(result[3].AreaType).toEqual("DB");1681 expect(result[3].Write).toEqual(false);1682 expect(result[3].Offset).toEqual(7);1683 expect(result[3].Length).toEqual(2);1684 expect(result[3].DBNumber).toEqual(2);1685 expect(Object.values(result[3].VariableConnections).length).toEqual(1);1686 expect(Object.values(result[3].VariableConnections)[0].variable).toEqual(1687 variable41688 );1689 expect(1690 Object.values(result[3].VariableConnections)[0].requestOffset1691 ).toEqual(0);1692 expect(Object.values(result[3].VariableConnections)[0].length).toEqual(2);1693 //Checking request 5 - containing variables 5 and 61694 expect(result[4].AreaType).toEqual("I");1695 expect(result[4].Write).toEqual(false);1696 expect(result[4].Offset).toEqual(9);1697 expect(result[4].Length).toEqual(4);1698 expect(result[4].DBNumber).toEqual(0);1699 expect(Object.values(result[4].VariableConnections).length).toEqual(2);1700 expect(Object.values(result[4].VariableConnections)[0].variable).toEqual(1701 variable51702 );1703 expect(1704 Object.values(result[4].VariableConnections)[0].requestOffset1705 ).toEqual(0);1706 expect(Object.values(result[4].VariableConnections)[0].length).toEqual(2);1707 expect(Object.values(result[4].VariableConnections)[1].variable).toEqual(1708 variable61709 );1710 expect(1711 Object.values(result[4].VariableConnections)[1].requestOffset1712 ).toEqual(2);1713 expect(Object.values(result[4].VariableConnections)[1].length).toEqual(2);1714 //Checking request 6 - containing variables 7 and 81715 expect(result[5].AreaType).toEqual("Q");1716 expect(result[5].Write).toEqual(true);1717 expect(result[5].Offset).toEqual(13);1718 expect(result[5].Length).toEqual(4);1719 expect(result[5].DBNumber).toEqual(0);1720 expect(Object.values(result[5].VariableConnections).length).toEqual(2);1721 expect(Object.values(result[5].VariableConnections)[0].variable).toEqual(1722 variable71723 );1724 expect(1725 Object.values(result[5].VariableConnections)[0].requestOffset1726 ).toEqual(0);1727 expect(Object.values(result[5].VariableConnections)[0].length).toEqual(2);1728 expect(Object.values(result[5].VariableConnections)[1].variable).toEqual(1729 variable81730 );1731 expect(1732 Object.values(result[5].VariableConnections)[1].requestOffset1733 ).toEqual(2);1734 expect(Object.values(result[5].VariableConnections)[1].length).toEqual(2);1735 //Checking request 7 - containing only variable 91736 expect(result[6].AreaType).toEqual("M");1737 expect(result[6].Write).toEqual(true);1738 expect(result[6].Offset).toEqual(17);1739 expect(result[6].Length).toEqual(2);1740 expect(result[6].DBNumber).toEqual(0);1741 expect(Object.values(result[6].VariableConnections).length).toEqual(1);1742 expect(Object.values(result[6].VariableConnections)[0].variable).toEqual(1743 variable91744 );1745 expect(1746 Object.values(result[6].VariableConnections)[0].requestOffset1747 ).toEqual(0);1748 expect(Object.values(result[6].VariableConnections)[0].length).toEqual(2);1749 });1750 it("should create valid request - if all variables are sorted and suits to 1 request", async () => {1751 variablePayload1 = {1752 name: "var1",1753 type: "s7Int16",1754 offset: 1,1755 areaType: "DB",1756 dbNumber: 1,1757 write: false1758 };1759 variablePayload2 = {1760 name: "var2",1761 type: "s7Int16",1762 offset: 3,1763 areaType: "DB",1764 dbNumber: 1,1765 write: false1766 };1767 variablePayload3 = {1768 name: "var3",1769 type: "s7Int16",1770 offset: 5,1771 areaType: "DB",1772 dbNumber: 1,1773 write: false1774 };1775 variablePayload4 = {1776 name: "var4",1777 type: "s7Int16",1778 offset: 7,1779 areaType: "DB",1780 dbNumber: 1,1781 write: false1782 };1783 variablePayload5 = {1784 name: "var5",1785 type: "s7Int16",1786 offset: 9,1787 areaType: "DB",1788 dbNumber: 1,1789 write: false1790 };1791 variablePayload6 = {1792 name: "var6",1793 type: "s7Int16",1794 offset: 11,1795 areaType: "DB",1796 dbNumber: 1,1797 write: false1798 };1799 variablePayload7 = {1800 name: "var7",1801 type: "s7Int16",1802 offset: 13,1803 areaType: "DB",1804 dbNumber: 1,1805 write: false1806 };1807 variablePayload8 = {1808 name: "var8",1809 type: "s7Int16",1810 offset: 15,1811 areaType: "DB",1812 dbNumber: 1,1813 write: false1814 };1815 variablePayload9 = {1816 name: "var9",1817 type: "s7Int16",1818 offset: 17,1819 areaType: "DB",1820 dbNumber: 1,1821 write: false1822 };1823 let result = await exec();1824 expect(result.length).toEqual(1);1825 //Checking request 1 - containing only variable 11826 expect(result[0].AreaType).toEqual("DB");1827 expect(result[0].Write).toEqual(false);1828 expect(result[0].Offset).toEqual(1);1829 expect(result[0].Length).toEqual(18);1830 expect(result[0].DBNumber).toEqual(1);1831 expect(Object.values(result[0].VariableConnections).length).toEqual(9);1832 //Checking variable connection 11833 expect(Object.values(result[0].VariableConnections)[0].variable).toEqual(1834 variable11835 );1836 expect(1837 Object.values(result[0].VariableConnections)[0].requestOffset1838 ).toEqual(0);1839 expect(Object.values(result[0].VariableConnections)[0].length).toEqual(2);1840 //Checking variable connection 21841 expect(Object.values(result[0].VariableConnections)[1].variable).toEqual(1842 variable21843 );1844 expect(1845 Object.values(result[0].VariableConnections)[1].requestOffset1846 ).toEqual(2);1847 expect(Object.values(result[0].VariableConnections)[1].length).toEqual(2);1848 //Checking variable connection 31849 expect(Object.values(result[0].VariableConnections)[2].variable).toEqual(1850 variable31851 );1852 expect(1853 Object.values(result[0].VariableConnections)[2].requestOffset1854 ).toEqual(4);1855 expect(Object.values(result[0].VariableConnections)[2].length).toEqual(2);1856 //Checking variable connection 41857 expect(Object.values(result[0].VariableConnections)[3].variable).toEqual(1858 variable41859 );1860 expect(1861 Object.values(result[0].VariableConnections)[3].requestOffset1862 ).toEqual(6);1863 expect(Object.values(result[0].VariableConnections)[3].length).toEqual(2);1864 //Checking variable connection 51865 expect(Object.values(result[0].VariableConnections)[4].variable).toEqual(1866 variable51867 );1868 expect(1869 Object.values(result[0].VariableConnections)[4].requestOffset1870 ).toEqual(8);1871 expect(Object.values(result[0].VariableConnections)[4].length).toEqual(2);1872 //Checking variable connection 61873 expect(Object.values(result[0].VariableConnections)[5].variable).toEqual(1874 variable61875 );1876 expect(1877 Object.values(result[0].VariableConnections)[5].requestOffset1878 ).toEqual(10);1879 expect(Object.values(result[0].VariableConnections)[5].length).toEqual(2);1880 //Checking variable connection 71881 expect(Object.values(result[0].VariableConnections)[6].variable).toEqual(1882 variable71883 );1884 expect(1885 Object.values(result[0].VariableConnections)[6].requestOffset1886 ).toEqual(12);1887 expect(Object.values(result[0].VariableConnections)[6].length).toEqual(2);1888 //Checking variable connection 81889 expect(Object.values(result[0].VariableConnections)[7].variable).toEqual(1890 variable81891 );1892 expect(1893 Object.values(result[0].VariableConnections)[7].requestOffset1894 ).toEqual(14);1895 expect(Object.values(result[0].VariableConnections)[7].length).toEqual(2);1896 //Checking variable connection 91897 expect(Object.values(result[0].VariableConnections)[8].variable).toEqual(1898 variable91899 );1900 expect(1901 Object.values(result[0].VariableConnections)[8].requestOffset1902 ).toEqual(16);1903 expect(Object.values(result[0].VariableConnections)[8].length).toEqual(2);1904 });1905 it("should create valid request - if all variables are not sorted but suits to 1 request", async () => {1906 variablePayload1 = {1907 name: "var1",1908 type: "s7Int16",1909 offset: 1,1910 areaType: "DB",1911 dbNumber: 1,1912 write: false1913 };1914 variablePayload2 = {1915 name: "var2",1916 type: "s7Int16",1917 offset: 3,1918 areaType: "DB",1919 dbNumber: 1,1920 write: false1921 };1922 variablePayload3 = {1923 name: "var3",1924 type: "s7Int16",1925 offset: 5,1926 areaType: "DB",1927 dbNumber: 1,1928 write: false1929 };1930 variablePayload4 = {1931 name: "var4",1932 type: "s7Int16",1933 offset: 7,1934 areaType: "DB",1935 dbNumber: 1,1936 write: false1937 };1938 variablePayload5 = {1939 name: "var5",1940 type: "s7Int16",1941 offset: 9,1942 areaType: "DB",1943 dbNumber: 1,1944 write: false1945 };1946 variablePayload6 = {1947 name: "var6",1948 type: "s7Int16",1949 offset: 11,1950 areaType: "DB",1951 dbNumber: 1,1952 write: false1953 };1954 variablePayload7 = {1955 name: "var7",1956 type: "s7Int16",1957 offset: 13,1958 areaType: "DB",1959 dbNumber: 1,1960 write: false1961 };1962 variablePayload8 = {1963 name: "var8",1964 type: "s7Int16",1965 offset: 15,1966 areaType: "DB",1967 dbNumber: 1,1968 write: false1969 };1970 variablePayload9 = {1971 name: "var9",1972 type: "s7Int16",1973 offset: 17,1974 areaType: "DB",1975 dbNumber: 1,1976 write: false1977 };1978 variables = [1979 variable9,1980 variable8,1981 variable7,1982 variable6,1983 variable5,1984 variable4,1985 variable3,1986 variable2,1987 variable11988 ];1989 let result = await exec();1990 expect(result.length).toEqual(1);1991 //Checking request 11992 expect(result[0].AreaType).toEqual("DB");1993 expect(result[0].Write).toEqual(false);1994 expect(result[0].Offset).toEqual(1);1995 expect(result[0].Length).toEqual(18);1996 expect(result[0].DBNumber).toEqual(1);1997 expect(Object.values(result[0].VariableConnections).length).toEqual(9);1998 //Checking variable connection 11999 expect(Object.values(result[0].VariableConnections)[0].variable).toEqual(2000 variable12001 );2002 expect(2003 Object.values(result[0].VariableConnections)[0].requestOffset2004 ).toEqual(0);2005 expect(Object.values(result[0].VariableConnections)[0].length).toEqual(2);2006 //Checking variable connection 22007 expect(Object.values(result[0].VariableConnections)[1].variable).toEqual(2008 variable22009 );2010 expect(2011 Object.values(result[0].VariableConnections)[1].requestOffset2012 ).toEqual(2);2013 expect(Object.values(result[0].VariableConnections)[1].length).toEqual(2);2014 //Checking variable connection 32015 expect(Object.values(result[0].VariableConnections)[2].variable).toEqual(2016 variable32017 );2018 expect(2019 Object.values(result[0].VariableConnections)[2].requestOffset2020 ).toEqual(4);2021 expect(Object.values(result[0].VariableConnections)[2].length).toEqual(2);2022 //Checking variable connection 42023 expect(Object.values(result[0].VariableConnections)[3].variable).toEqual(2024 variable42025 );2026 expect(2027 Object.values(result[0].VariableConnections)[3].requestOffset2028 ).toEqual(6);2029 expect(Object.values(result[0].VariableConnections)[3].length).toEqual(2);2030 //Checking variable connection 52031 expect(Object.values(result[0].VariableConnections)[4].variable).toEqual(2032 variable52033 );2034 expect(2035 Object.values(result[0].VariableConnections)[4].requestOffset2036 ).toEqual(8);2037 expect(Object.values(result[0].VariableConnections)[4].length).toEqual(2);2038 //Checking variable connection 62039 expect(Object.values(result[0].VariableConnections)[5].variable).toEqual(2040 variable62041 );2042 expect(2043 Object.values(result[0].VariableConnections)[5].requestOffset2044 ).toEqual(10);2045 expect(Object.values(result[0].VariableConnections)[5].length).toEqual(2);2046 //Checking variable connection 72047 expect(Object.values(result[0].VariableConnections)[6].variable).toEqual(2048 variable72049 );2050 expect(2051 Object.values(result[0].VariableConnections)[6].requestOffset2052 ).toEqual(12);2053 expect(Object.values(result[0].VariableConnections)[6].length).toEqual(2);2054 //Checking variable connection 82055 expect(Object.values(result[0].VariableConnections)[7].variable).toEqual(2056 variable82057 );2058 expect(2059 Object.values(result[0].VariableConnections)[7].requestOffset2060 ).toEqual(14);2061 expect(Object.values(result[0].VariableConnections)[7].length).toEqual(2);2062 //Checking variable connection 92063 expect(Object.values(result[0].VariableConnections)[8].variable).toEqual(2064 variable92065 );2066 expect(2067 Object.values(result[0].VariableConnections)[8].requestOffset2068 ).toEqual(16);2069 expect(Object.values(result[0].VariableConnections)[8].length).toEqual(2);2070 });2071 it("should create valid request - if all variables are sorted and suits to 2 request due to gap between registers", async () => {2072 variablePayload1 = {2073 name: "var1",2074 type: "s7Int16",2075 offset: 1,2076 areaType: "DB",2077 dbNumber: 1,2078 write: false2079 };2080 variablePayload2 = {2081 name: "var2",2082 type: "s7Int16",2083 offset: 3,2084 areaType: "DB",2085 dbNumber: 1,2086 write: false2087 };2088 variablePayload3 = {2089 name: "var3",2090 type: "s7Int16",2091 offset: 5,2092 areaType: "DB",2093 dbNumber: 1,2094 write: false2095 };2096 variablePayload4 = {2097 name: "var4",2098 type: "s7Int16",2099 offset: 7,2100 areaType: "DB",2101 dbNumber: 1,2102 write: false2103 };2104 variablePayload5 = {2105 name: "var5",2106 type: "s7Int16",2107 offset: 10,2108 areaType: "DB",2109 dbNumber: 1,2110 write: false2111 };2112 variablePayload6 = {2113 name: "var6",2114 type: "s7Int16",2115 offset: 12,2116 areaType: "DB",2117 dbNumber: 1,2118 write: false2119 };2120 variablePayload7 = {2121 name: "var7",2122 type: "s7Int16",2123 offset: 14,2124 areaType: "DB",2125 dbNumber: 1,2126 write: false2127 };2128 variablePayload8 = {2129 name: "var8",2130 type: "s7Int16",2131 offset: 16,2132 areaType: "DB",2133 dbNumber: 1,2134 write: false2135 };2136 variablePayload9 = {2137 name: "var9",2138 type: "s7Int16",2139 offset: 18,2140 areaType: "DB",2141 dbNumber: 1,2142 write: false2143 };2144 let result = await exec();2145 expect(result.length).toEqual(2);2146 //Checking request 12147 expect(result[0].AreaType).toEqual("DB");2148 expect(result[0].Write).toEqual(false);2149 expect(result[0].Offset).toEqual(1);2150 expect(result[0].Length).toEqual(8);2151 expect(result[0].DBNumber).toEqual(1);2152 expect(Object.values(result[0].VariableConnections).length).toEqual(4);2153 //Checking variable connection 12154 expect(Object.values(result[0].VariableConnections)[0].variable).toEqual(2155 variable12156 );2157 expect(2158 Object.values(result[0].VariableConnections)[0].requestOffset2159 ).toEqual(0);2160 expect(Object.values(result[0].VariableConnections)[0].length).toEqual(2);2161 //Checking variable connection 22162 expect(Object.values(result[0].VariableConnections)[1].variable).toEqual(2163 variable22164 );2165 expect(2166 Object.values(result[0].VariableConnections)[1].requestOffset2167 ).toEqual(2);2168 expect(Object.values(result[0].VariableConnections)[1].length).toEqual(2);2169 //Checking variable connection 32170 expect(Object.values(result[0].VariableConnections)[2].variable).toEqual(2171 variable32172 );2173 expect(2174 Object.values(result[0].VariableConnections)[2].requestOffset2175 ).toEqual(4);2176 expect(Object.values(result[0].VariableConnections)[2].length).toEqual(2);2177 //Checking variable connection 42178 expect(Object.values(result[0].VariableConnections)[3].variable).toEqual(2179 variable42180 );2181 expect(2182 Object.values(result[0].VariableConnections)[3].requestOffset2183 ).toEqual(6);2184 expect(Object.values(result[0].VariableConnections)[3].length).toEqual(2);2185 //Checking request 22186 expect(result[1].AreaType).toEqual("DB");2187 expect(result[1].Write).toEqual(false);2188 expect(result[1].Offset).toEqual(10);2189 expect(result[1].Length).toEqual(10);2190 expect(result[1].DBNumber).toEqual(1);2191 expect(Object.values(result[1].VariableConnections).length).toEqual(5);2192 //Checking variable connection 52193 expect(Object.values(result[1].VariableConnections)[0].variable).toEqual(2194 variable52195 );2196 expect(2197 Object.values(result[1].VariableConnections)[0].requestOffset2198 ).toEqual(0);2199 expect(Object.values(result[1].VariableConnections)[0].length).toEqual(2);2200 //Checking variable connection 62201 expect(Object.values(result[1].VariableConnections)[1].variable).toEqual(2202 variable62203 );2204 expect(2205 Object.values(result[1].VariableConnections)[1].requestOffset2206 ).toEqual(2);2207 expect(Object.values(result[1].VariableConnections)[1].length).toEqual(2);2208 //Checking variable connection 72209 expect(Object.values(result[1].VariableConnections)[2].variable).toEqual(2210 variable72211 );2212 expect(2213 Object.values(result[1].VariableConnections)[2].requestOffset2214 ).toEqual(4);2215 expect(Object.values(result[1].VariableConnections)[2].length).toEqual(2);2216 //Checking variable connection 82217 expect(Object.values(result[1].VariableConnections)[3].variable).toEqual(2218 variable82219 );2220 expect(2221 Object.values(result[1].VariableConnections)[3].requestOffset2222 ).toEqual(6);2223 expect(Object.values(result[1].VariableConnections)[3].length).toEqual(2);2224 //Checking variable connection 92225 expect(Object.values(result[1].VariableConnections)[4].variable).toEqual(2226 variable92227 );2228 expect(2229 Object.values(result[1].VariableConnections)[4].requestOffset2230 ).toEqual(8);2231 expect(Object.values(result[1].VariableConnections)[4].length).toEqual(2);2232 });2233 it("should create valid request - if all variables are sorted and suits to 2 max request length", async () => {2234 maxReqLength = 10;2235 variablePayload1 = {2236 name: "var1",2237 type: "s7Int16",2238 offset: 1,2239 areaType: "DB",2240 dbNumber: 1,2241 write: false2242 };2243 variablePayload2 = {2244 name: "var2",2245 type: "s7Int16",2246 offset: 3,2247 areaType: "DB",2248 dbNumber: 1,2249 write: false2250 };2251 variablePayload3 = {2252 name: "var3",2253 type: "s7Int16",2254 offset: 5,2255 areaType: "DB",2256 dbNumber: 1,2257 write: false2258 };2259 variablePayload4 = {2260 name: "var4",2261 type: "s7Int16",2262 offset: 7,2263 areaType: "DB",2264 dbNumber: 1,2265 write: false2266 };2267 variablePayload5 = {2268 name: "var5",2269 type: "s7Int16",2270 offset: 9,2271 areaType: "DB",2272 dbNumber: 1,2273 write: false2274 };2275 variablePayload6 = {2276 name: "var6",2277 type: "s7Int16",2278 offset: 11,2279 areaType: "DB",2280 dbNumber: 1,2281 write: false2282 };2283 variablePayload7 = {2284 name: "var7",2285 type: "s7Int16",2286 offset: 13,2287 areaType: "DB",2288 dbNumber: 1,2289 write: false2290 };2291 variablePayload8 = {2292 name: "var8",2293 type: "s7Int16",2294 offset: 15,2295 areaType: "DB",2296 dbNumber: 1,2297 write: false2298 };2299 variablePayload9 = {2300 name: "var9",2301 type: "s7Int16",2302 offset: 17,2303 areaType: "DB",2304 dbNumber: 1,2305 write: false2306 };2307 let result = await exec();2308 expect(result.length).toEqual(2);2309 //Checking request 12310 expect(result[0].AreaType).toEqual("DB");2311 expect(result[0].Write).toEqual(false);2312 expect(result[0].Offset).toEqual(1);2313 expect(result[0].Length).toEqual(10);2314 expect(result[0].DBNumber).toEqual(1);2315 expect(Object.values(result[0].VariableConnections).length).toEqual(5);2316 //Checking variable connection 12317 expect(Object.values(result[0].VariableConnections)[0].variable).toEqual(2318 variable12319 );2320 expect(2321 Object.values(result[0].VariableConnections)[0].requestOffset2322 ).toEqual(0);2323 expect(Object.values(result[0].VariableConnections)[0].length).toEqual(2);2324 //Checking variable connection 22325 expect(Object.values(result[0].VariableConnections)[1].variable).toEqual(2326 variable22327 );2328 expect(2329 Object.values(result[0].VariableConnections)[1].requestOffset2330 ).toEqual(2);2331 expect(Object.values(result[0].VariableConnections)[1].length).toEqual(2);2332 //Checking variable connection 32333 expect(Object.values(result[0].VariableConnections)[2].variable).toEqual(2334 variable32335 );2336 expect(2337 Object.values(result[0].VariableConnections)[2].requestOffset2338 ).toEqual(4);2339 expect(Object.values(result[0].VariableConnections)[2].length).toEqual(2);2340 //Checking variable connection 42341 expect(Object.values(result[0].VariableConnections)[3].variable).toEqual(2342 variable42343 );2344 expect(2345 Object.values(result[0].VariableConnections)[3].requestOffset2346 ).toEqual(6);2347 expect(Object.values(result[0].VariableConnections)[3].length).toEqual(2);2348 //Checking variable connection 52349 expect(Object.values(result[0].VariableConnections)[4].variable).toEqual(2350 variable52351 );2352 expect(2353 Object.values(result[0].VariableConnections)[4].requestOffset2354 ).toEqual(8);2355 expect(Object.values(result[0].VariableConnections)[4].length).toEqual(2);2356 //Checking request 22357 expect(result[1].AreaType).toEqual("DB");2358 expect(result[1].Write).toEqual(false);2359 expect(result[1].Offset).toEqual(11);2360 expect(result[1].Length).toEqual(8);2361 expect(result[1].DBNumber).toEqual(1);2362 expect(Object.values(result[1].VariableConnections).length).toEqual(4);2363 //Checking variable connection 52364 expect(Object.values(result[1].VariableConnections)[0].variable).toEqual(2365 variable62366 );2367 expect(2368 Object.values(result[1].VariableConnections)[0].requestOffset2369 ).toEqual(0);2370 expect(Object.values(result[1].VariableConnections)[0].length).toEqual(2);2371 //Checking variable connection 62372 expect(Object.values(result[1].VariableConnections)[1].variable).toEqual(2373 variable72374 );2375 expect(2376 Object.values(result[1].VariableConnections)[1].requestOffset2377 ).toEqual(2);2378 expect(Object.values(result[1].VariableConnections)[1].length).toEqual(2);2379 //Checking variable connection 72380 expect(Object.values(result[1].VariableConnections)[2].variable).toEqual(2381 variable82382 );2383 expect(2384 Object.values(result[1].VariableConnections)[2].requestOffset2385 ).toEqual(4);2386 expect(Object.values(result[1].VariableConnections)[2].length).toEqual(2);2387 //Checking variable connection 82388 expect(Object.values(result[1].VariableConnections)[3].variable).toEqual(2389 variable92390 );2391 expect(2392 Object.values(result[1].VariableConnections)[3].requestOffset2393 ).toEqual(6);2394 expect(Object.values(result[1].VariableConnections)[3].length).toEqual(2);2395 });2396 });...
require-aligned-object-values.js
Source:require-aligned-object-values.js
1var Checker = require('../../../lib/checker');2var expect = require('chai').expect;3var reportAndFix = require('../../lib/assertHelpers').reportAndFix;4describe('rules/require-aligned-object-values', function() {5 var checker;6 beforeEach(function() {7 checker = new Checker();8 checker.registerDefaultRules();9 });10 describe('all option', function() {11 var rules = { requireAlignedObjectValues: 'all' };12 beforeEach(function() {13 checker.configure(rules);14 });15 it('should not report for empty object', function() {16 expect(checker.checkString('var x = {};')).to.have.no.errors();17 });18 it('should not report for single-line object', function() {19 expect(checker.checkString('var x = {a: 1, bcd: 2};')).to.have.no.errors();20 });21 it('should not report if aligned', function() {22 expect(checker.checkString(23 'var x = {\n' +24 'a : 1,\n' +25 'bcd : 2\n' +26 '};'27 )).to.have.no.errors();28 });29 it('should not report shorthand properties', function() {30 expect(checker.checkString(31 'var x = {\n' +32 'bcd : 2,\n' +33 'a,\n' +34 'efg : 2\n' +35 '};'36 )).to.have.no.errors();37 });38 it('should not report es6-methods. #1013', function() {39 expect(checker.checkString('var x = { a() { } };')).to.have.no.errors();40 });41 it('should not report es5 getters/setters #1037', function() {42 expect(checker.checkString('var x = { get a() { } };')).to.have.no.errors();43 expect(checker.checkString('var x = { set a(val) { } };')).to.have.no.errors();44 });45 it('should not report if aligned with computed property names #1404', function() {46 expect(checker.checkString([47 'var myObject = {',48 '[myKey] : "myKeyValue",',49 '[otherKey]: "myOtherValue"',50 '};'51 ].join('\n'))).to.have.no.errors();52 });53 it('should report invalid alignment', function() {54 expect(checker.checkString(55 'var x = {\n' +56 'a : 1,\n' +57 '\n' +58 'foo : function() {},\n' +59 'bcd : 2\n' +60 '};'61 )).to.have.one.validation.error.from('requireAlignedObjectValues');62 });63 it('should report if not aligned with computed property names #1404', function() {64 expect(checker.checkString([65 'var myObject = {',66 '[myKey] : "myKeyValue",',67 '[otherKey] : "myOtherValue"',68 '};'69 ].join('\n'))).to.have.one.validation.error.from('requireAlignedObjectValues');70 });71 it('should not report on an import plus aligned computed property names (#1587)', function() {72 expect(checker.checkString([73 'import React, {PropTypes} from \'react\';\n',74 'import {ImmutableComponentPure} from \'common/ImmutableComponent.js\'',75 'let myObject = {',76 '[myKey] : "myKeyValue",',77 '[$main.pod] : "myOtherValue"',78 '};'79 ].join('\n'))).to.have.no.errors();80 });81 it('should not report es7 object spread. Ref #1624', function() {82 expect(checker.checkString(83 'var x = {\n' +84 'bcd : 2,\n' +85 '...a,\n' +86 'efg : 2\n' +87 '};'88 )).to.have.no.errors();89 });90 describe('alignment check for any number of spaces', function() {91 reportAndFix({92 name: 'illegal object values alignment',93 rules: rules,94 input: 'var x = {\n' +95 'a: 1,\n' +96 '\n' +97 'foo: function() {},\n' +98 'bcd: 2\n' +99 '};',100 output: 'var x = {\n' +101 'a : 1,\n' +102 '\n' +103 'foo: function() {},\n' +104 'bcd: 2\n' +105 '};'106 });107 reportAndFix({108 name: 'illegal object values alignment',109 rules: rules,110 input: 'var x = {\n' +111 'a : 1,\n' +112 '\n' +113 'foo : function() {},\n' +114 'bcd : 2\n' +115 '};',116 output: 'var x = {\n' +117 'a : 1,\n' +118 '\n' +119 'foo : function() {},\n' +120 'bcd : 2\n' +121 '};'122 });123 });124 describe.skip('in conjunction with disallowSpaceAfterObjectKeys', function() {125 reportAndFix({126 name: 'illegal object values alignment',127 rules: {128 disallowSpaceAfterObjectKeys: {allExcept: ['aligned']},129 requireAlignedObjectValues: 'all'130 },131 errors: 4,132 input: 'var x = {\n' +133 'a : 1,\n' +134 'foo : function() {},\n' +135 'bcd : 2\n' +136 '};',137 output: 'var x = {\n' +138 'a: 1,\n' +139 'foo: function() {},\n' +140 'bcd: 2\n' +141 '};'142 });143 });144 });145 describe('ignoreFunction option', function() {146 it('should not report function with skipWithFunction', function() {147 checker.configure({ requireAlignedObjectValues: 'skipWithFunction' });148 expect(checker.checkString(149 'var x = {\n' +150 'a : 1,\n' +151 'foo : function() {},\n' +152 'bcd : 2\n' +153 '};'154 )).to.have.no.errors();155 });156 it('should not report function with ignoreFunction', function() {157 checker.configure({ requireAlignedObjectValues: 'ignoreFunction' });158 expect(checker.checkString(159 'var x = {\n' +160 'a : 1,\n' +161 'foo : function() {},\n' +162 'bcd : 2\n' +163 '};'164 )).to.have.no.errors();165 });166 });167 describe('ignoreLineBreak option', function() {168 it('should not report with line break between properties', function() {169 checker.configure({ requireAlignedObjectValues: 'skipWithLineBreak' });170 expect(checker.checkString(171 'var x = {\n' +172 'a : 1,\n' +173 '\n' +174 'bcd : 2\n' +175 '};'176 )).to.have.no.errors();177 });178 it('should report invalid alignment in nested object', function() {179 checker.configure({ requireAlignedObjectValues: 'skipWithLineBreak' });180 expect(checker.checkString(181 'var x = {\n' +182 'a : 1,\n' +183 '\n' +184 'nested : {\n' +185 'sdf : \'sdf\',\n' +186 'e : 1\n' +187 '},\n' +188 'bcd : 2\n' +189 '};'190 )).to.have.one.validation.error.from('requireAlignedObjectValues');191 });192 it('should not report with line break between properties', function() {193 checker.configure({ requireAlignedObjectValues: 'ignoreLineBreak' });194 expect(checker.checkString(195 'var x = {\n' +196 'a : 1,\n' +197 '\n' +198 'bcd : 2\n' +199 '};'200 )).to.have.no.errors();201 });202 it('should report invalid alignment in nested object', function() {203 checker.configure({ requireAlignedObjectValues: 'ignoreLineBreak' });204 expect(checker.checkString(205 'var x = {\n' +206 'a : 1,\n' +207 '\n' +208 'nested : {\n' +209 'sdf : \'sdf\',\n' +210 'e : 1\n' +211 '},\n' +212 'bcd : 2\n' +213 '};'214 )).to.have.one.validation.error.from('requireAlignedObjectValues');215 });216 });217 describe('incorrect configuration', function() {218 it('should not accept objects without correct key', function() {219 expect(function() {220 checker.configure({ requireAlignedObjectValues: 'skipsWithFunction' });221 }).to.throw('AssertionError');222 });223 });...
object-values.js
Source:object-values.js
...10 var descriptor = Object.getOwnPropertyDescriptor(Object, "values");11 assertTrue(descriptor.writable);12 assertFalse(descriptor.enumerable);13 assertTrue(descriptor.configurable);14 assertThrows(() => new Object.values({}), TypeError);15}16TestMeta();17function TestBasic() {18 var x = 16;19 var O = {20 d: 1,21 c: 3,22 [Symbol.iterator]: void 0,23 0: 123,24 1000: 456,25 [x * x]: "ducks",26 [`0x${(x * x).toString(16)}`]: "quack"27 };28 O.a = 2;29 O.b = 4;30 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });31 assertEquals([123, "ducks", 456, 1, 3, "quack", 2, 4], Object.values(O));32 assertEquals(Object.values(O), Object.keys(O).map(key => O[key]));33 assertTrue(Array.isArray(Object.values({})));34 assertEquals(0, Object.values({}).length);35}36TestBasic();37function TestToObject() {38 assertThrows(function() { Object.values(); }, TypeError);39 assertThrows(function() { Object.values(null); }, TypeError);40 assertThrows(function() { Object.values(void 0); }, TypeError);41}42TestToObject();43function TestOrder() {44 var O = {45 a: 1,46 [Symbol.iterator]: null47 };48 O[456] = 123;49 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });50 var priv = %CreatePrivateSymbol("Secret");51 O[priv] = 56;52 var log = [];53 var P = new Proxy(O, {54 ownKeys(target) {55 log.push("[[OwnPropertyKeys]]");56 return Reflect.ownKeys(target);57 },58 get(target, name) {59 log.push(`[[Get]](${JSON.stringify(name)})`);60 return Reflect.get(target, name);61 },62 getOwnPropertyDescriptor(target, name) {63 log.push(`[[GetOwnProperty]](${JSON.stringify(name)})`);64 return Reflect.getOwnPropertyDescriptor(target, name);65 },66 set(target, name, value) {67 assertUnreachable();68 }69 });70 assertEquals([123, 1], Object.values(P));71 assertEquals([72 "[[OwnPropertyKeys]]",73 "[[GetOwnProperty]](\"456\")",74 "[[Get]](\"456\")",75 "[[GetOwnProperty]](\"a\")",76 "[[Get]](\"a\")",77 "[[GetOwnProperty]](\"HIDDEN\")"78 ], log);79}80TestOrder();81function TestOrderWithDuplicates() {82 var O = {83 a: 1,84 [Symbol.iterator]: null85 };86 O[456] = 123;87 Object.defineProperty(O, "HIDDEN", { enumerable: false, value: NaN });88 O[priv] = 56;89 var priv = %CreatePrivateSymbol("private");90 var log = [];91 var P = new Proxy(O, {92 ownKeys(target) {93 log.push("[[OwnPropertyKeys]]");94 return [ "a", Symbol.iterator, "a", "456", "HIDDEN", "HIDDEN", "456" ];95 },96 get(target, name) {97 log.push(`[[Get]](${JSON.stringify(name)})`);98 return Reflect.get(target, name);99 },100 getOwnPropertyDescriptor(target, name) {101 log.push(`[[GetOwnProperty]](${JSON.stringify(name)})`);102 return Reflect.getOwnPropertyDescriptor(target, name);103 },104 set(target, name, value) {105 assertUnreachable();106 }107 });108 assertEquals([1, 1, 123, 123], Object.values(P));109 assertEquals([110 "[[OwnPropertyKeys]]",111 "[[GetOwnProperty]](\"a\")",112 "[[Get]](\"a\")",113 "[[GetOwnProperty]](\"a\")",114 "[[Get]](\"a\")",115 "[[GetOwnProperty]](\"456\")",116 "[[Get]](\"456\")",117 "[[GetOwnProperty]](\"HIDDEN\")",118 "[[GetOwnProperty]](\"HIDDEN\")",119 "[[GetOwnProperty]](\"456\")",120 "[[Get]](\"456\")",121 ], log);122}123TestOrderWithDuplicates();124function TestPropertyFilter() {125 var object = { prop3: 30 };126 object[2] = 40;127 object["prop4"] = 50;128 Object.defineProperty(object, "prop5", { value: 60, enumerable: true });129 Object.defineProperty(object, "prop6", { value: 70, enumerable: false });130 Object.defineProperty(object, "prop7", {131 enumerable: true, get() { return 80; }});132 var sym = Symbol("prop8");133 object[sym] = 90;134 values = Object.values(object);135 assertEquals(5, values.length);136 assertEquals([40,30,50,60,80], values);137}138TestPropertyFilter();139function TestWithProxy() {140 var obj1 = {prop1:10};141 var proxy1 = new Proxy(obj1, { });142 assertEquals([10], Object.values(proxy1));143 var obj2 = {};144 Object.defineProperty(obj2, "prop2", { value: 20, enumerable: true });145 Object.defineProperty(obj2, "prop3", {146 get() { return 30; }, enumerable: true });147 var proxy2 = new Proxy(obj2, {148 getOwnPropertyDescriptor(target, name) {149 return Reflect.getOwnPropertyDescriptor(target, name);150 }151 });152 assertEquals([20, 30], Object.values(proxy2));153 var obj3 = {};154 var count = 0;155 var proxy3 = new Proxy(obj3, {156 get(target, property, receiver) {157 return count++ * 5;158 },159 getOwnPropertyDescriptor(target, property) {160 return { configurable: true, enumerable: true };161 },162 ownKeys(target) {163 return [ "prop0", "prop1", Symbol("prop2"), Symbol("prop5") ];164 }165 });166 assertEquals([0, 5], Object.values(proxy3));167}168TestWithProxy();169function TestMutateDuringEnumeration() {170 var aDeletesB = {171 get a() {172 delete this.b;173 return 1;174 },175 b: 2176 };177 assertEquals([1], Object.values(aDeletesB));178 var aRemovesB = {179 get a() {180 Object.defineProperty(this, "b", { enumerable: false });181 return 1;182 },183 b: 2184 };185 assertEquals([1], Object.values(aRemovesB));186 var aAddsB = { get a() { this.b = 2; return 1; } };187 assertEquals([1], Object.values(aAddsB));188 var aMakesBEnumerable = {};189 Object.defineProperty(aMakesBEnumerable, "a", {190 get() {191 Object.defineProperty(this, "b", { enumerable: true });192 return 1;193 },194 enumerable: true195 });196 Object.defineProperty(aMakesBEnumerable, "b", {197 value: 2, configurable:true, enumerable: false });198 assertEquals([1, 2], Object.values(aMakesBEnumerable));199}200TestMutateDuringEnumeration();201(function TestElementKinds() {202 var O1 = { name: "1" }, O2 = { name: "2" }, O3 = { name: "3" };203 var PI = 3.141592653589793;204 var E = 2.718281828459045;205 function fastSloppyArguments(a, b, c) {206 delete arguments[0];207 arguments[0] = a;208 return arguments;209 }210 function slowSloppyArguments(a, b, c) {211 delete arguments[0];212 arguments[0] = a;213 Object.defineProperties(arguments, {214 0: {215 enumerable: true,216 value: a217 },218 9999: {219 enumerable: false,220 value: "Y"221 }222 });223 arguments[10000] = "X";224 return arguments;225 }226 var element_kinds = {227 FAST_SMI_ELEMENTS: [ [1, 2, 3], [1, 2, 3] ],228 FAST_HOLEY_SMI_ELEMENTS: [ [, , 3], [ 3 ] ],229 FAST_ELEMENTS: [ [O1, O2, O3], [O1, O2, O3] ],230 FAST_HOLEY_ELEMENTS: [ [, , O3], [O3] ],231 FAST_DOUBLE_ELEMENTS: [ [E, NaN, PI], [E, NaN, PI] ],232 FAST_HOLEY_DOUBLE_ELEMENTS: [ [, , NaN], [NaN] ],233 DICTIONARY_ELEMENTS: [ Object.defineProperties({ 10000: "world" }, {234 100: { enumerable: true, value: "hello" },235 99: { enumerable: false, value: "nope" }236 }), [ "hello", "world" ] ],237 FAST_SLOPPY_ARGUMENTS_ELEMENTS: [238 fastSloppyArguments("a", "b", "c"), ["a", "b", "c"] ],239 SLOW_SLOPPY_ARGUMENTS_ELEMENTS: [240 slowSloppyArguments("a", "b", "c"), [ "a", "b", "c", "X"]],241 FAST_STRING_WRAPPER_ELEMENTS: [ new String("str"), ["s", "t", "r"] ],242 SLOW_STRING_WRAPPER_ELEMENTS: [243 Object.defineProperties(new String("str"), {244 10000: { enumerable: false, value: "X" },245 9999: { enumerable: true, value: "Y" }246 }), ["s", "t", "r", "Y"] ],247 };248 for (let [kind, [object, expected]] of Object.entries(element_kinds)) {249 let result1 = Object.values(object);250 assertEquals(expected, result1, `fast Object.values() with ${kind}`);251 let proxy = new Proxy(object, {});252 let result2 = Object.values(proxy);253 assertEquals(result1, result2, `slow Object.values() with ${kind}`);254 }...
Object.es7-test.js
Source:Object.es7-test.js
...76 const foo = Object.defineProperties({}, {77 x: {value: 10, enumerable: true},78 y: {value: 20},79 });80 expect(Object.values(foo)).toEqual([10]);81 const bar = {x: 10, y: 20};82 expect(Object.values(bar)).toEqual([10, 20]);83 });84 it('should work with proto-less objects', () => {85 const foo = Object.create(null, {86 x: {value: 10, enumerable: true},87 y: {value: 20},88 });89 expect(Object.values(foo)).toEqual([10]);90 });91 it('should return only own values', () => {92 const foo = Object.create({z: 30}, {93 x: {value: 10, enumerable: true},94 y: {value: 20},95 });96 expect(Object.values(foo)).toEqual([10]);97 });98 it('should convert to object primitive string', () => {99 expect(Object.values('ab')).toEqual(['a', 'b']);100 });101 });...
disallow-space-before-object-values.js
Source:disallow-space-before-object-values.js
1var Checker = require('../../../lib/checker');2var expect = require('chai').expect;3describe('rules/disallow-space-before-object-values', function() {4 var checker;5 beforeEach(function() {6 checker = new Checker();7 checker.registerDefaultRules();8 checker.configure({ disallowSpaceBeforeObjectValues: true });9 });10 it('should report with space after keys colons', function() {11 expect(checker.checkString('var x = { a:1, b: 2 };'))12 .to.have.one.validation.error.from('disallowSpaceBeforeObjectValues');13 expect(checker.checkString('var x = { abc : 1, b: 2 };')).to.have.error.count.equal(2);14 expect(checker.checkString('var x = { abc:(true), z: (function() { return _z > 0; }) };'))15 .to.have.one.validation.error.from('disallowSpaceBeforeObjectValues');16 expect(checker.checkString('var x = { abc : (true), b: ("1")};')).to.have.error.count.equal(2);17 expect(checker.checkString('var x = { a: ((1 > 2) && 3)};'))18 .to.have.one.validation.error.from('disallowSpaceBeforeObjectValues');19 });20 it('should not report with no space after keys colons and parenthesised expression in property value', function() {21 expect(checker.checkString('var x = { a:(1 > 2)};')).to.have.no.errors();22 expect(checker.checkString('var x = { 0x7f :(y?(z ? 1: 2):(3)) };')).to.have.no.errors();23 expect(checker.checkString('var x = { a:((1 > 2) && 3)};')).to.have.no.errors();24 expect(checker.checkString('var x = { a :(( 1 > 2) && 3)};')).to.have.no.errors();25 });26 it('should not report with no space after keys colons', function() {27 expect(checker.checkString('var x = { a:1, bcd :2 };')).to.have.no.errors();28 });29 it('should not report shorthand object properties', function() {30 expect(checker.checkString('var x = { a, b };')).to.have.no.errors();31 expect(checker.checkString('var x = {a, b};')).to.have.no.errors();32 });33 it('should report mixed shorthand and normal object properties', function() {34 expect(checker.checkString('var x = { a : 1, b };'))35 .to.have.one.validation.error.from('disallowSpaceBeforeObjectValues');36 });37 it('should not report es6-methods. #1013', function() {38 expect(checker.checkString('var x = { a() { } };')).to.have.no.errors();39 });40 it('should not report es7 object spread. Ref #1624', function() {41 expect(checker.checkString('var x = { ...a };')).to.have.no.errors();42 });43 it('should not report es5 getters/setters #1037', function() {44 expect(checker.checkString('var x = { get a() { } };')).to.have.no.errors();45 expect(checker.checkString('var x = { set a(val) { } };')).to.have.no.errors();46 });...
values.js
Source:values.js
...5if ("values" in Object) {6 assertEq(Object.values.length, 1);7 var o, values;8 o = { a: 3, b: 2 };9 values = Object.values(o);10 assertDeepEq(values, [3, 2]);11 o = { get a() { return 17; }, b: 2 };12 values = Object.values(o),13 assertDeepEq(values, [17, 2]);14 o = { __iterator__: function() { return Iterator({a: 2, b: 3}); } };15 values = Object.values(o);16 assertDeepEq(values, [o.__iterator__]);17 o = { a: 1, b: 2 };18 delete o.a;19 o.a = 3;20 values = Object.values(o);21 assertDeepEq(values, [2, 3]);22 o = [0, 1, 2];23 values = Object.values(o);24 assertDeepEq(values, [0, 1, 2]);25 o = /./.exec("abc");26 values = Object.values(o);27 assertDeepEq(values, ["a", 0, "abc"]);28 o = { a: 1, b: 2, c: 3 };29 delete o.b;30 o.b = 5;31 values = Object.values(o);32 assertDeepEq(values, [1, 3, 5]);33 function f() { }34 f.prototype.p = 1;35 o = new f();36 o.g = 1;37 values = Object.values(o);38 assertDeepEq(values, [1]);39 var o = {get a() {delete this.b; return 1}, b: 2, c: 3};40 values = Object.values(o);41 assertDeepEq(values, [1, 3]);42 assertThrowsInstanceOf(() => Object.values(), TypeError);43 assertThrowsInstanceOf(() => Object.values(undefined), TypeError);44 assertThrowsInstanceOf(() => Object.values(null), TypeError);45 assertDeepEq(Object.values(1), []);46 assertDeepEq(Object.values(true), []);47 if (typeof Symbol === "function")48 assertDeepEq(Object.values(Symbol("foo")), []);49 assertDeepEq(Object.values("foo"), ["f", "o", "o"]);50 values = Object.values({51 get a(){52 Object.defineProperty(this, "b", {enumerable: false});53 return "A";54 },55 b: "B"56 });57 assertDeepEq(values, ["A"]);58 let ownKeysCallCount = 0;59 let getOwnPropertyDescriptorCalls = [];60 let target = { a: 1, b: 2, c: 3 };61 o = new Proxy(target, {62 ownKeys() {63 ownKeysCallCount++;64 return ["c", "a"];65 },66 getOwnPropertyDescriptor(target, key) {67 getOwnPropertyDescriptorCalls.push(key);68 return Object.getOwnPropertyDescriptor(target, key);69 }70 });71 values = Object.values(o);72 assertEq(ownKeysCallCount, 1);73 assertDeepEq(values, [3, 1]);74 assertDeepEq(getOwnPropertyDescriptorCalls, ["c", "a"]);75}76if (typeof reportCompare === "function")...
shimmed.js
Source:shimmed.js
...17 et.end();18 });19 var supportsStrictMode = (function () { return typeof this === 'undefined'; }());20 t.test('bad object value', { skip: !supportsStrictMode }, function (st) {21 st.throws(function () { return Object.values(undefined); }, TypeError, 'undefined is not an object');22 st.throws(function () { return Object.values(null); }, TypeError, 'null is not an object');23 st.end();24 });25 runTests(Object.values, t);26 t.end();...
primitive-numbers.js
Source:primitive-numbers.js
...4esid: sec-object.values5description: Object.values accepts number primitives.6author: Jordan Harband7---*/8assert.sameValue(Object.values(0).length, 0, '0 has zero values');9assert.sameValue(Object.values(-0).length, 0, '-0 has zero values');10assert.sameValue(Object.values(Infinity).length, 0, 'Infinity has zero values');11assert.sameValue(Object.values(-Infinity).length, 0, '-Infinity has zero values');12assert.sameValue(Object.values(NaN).length, 0, 'NaN has zero values');13assert.sameValue(Object.values(Math.PI).length, 0, 'Math.PI has zero values');...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('Test', () => {2 it('test', () => {3 const obj = { a: 1, b: 2, c: 3 };4 const values = Object.values(obj);5 expect(values).to.deep.equal([1, 2, 3]);6 });7});8describe('Test', () => {9 it('test', () => {10 const obj = { a: 1, b: 2, c: 3 };11 const entries = Object.entries(obj);12 expect(entries).to.deep.equal([13 ]);14 });15});16describe('Test', () => {17 it('test', () => {18 const obj = { a: 1, b: 2, c: 3 };19 const keys = Object.keys(obj);20 expect(keys).to.deep.equal(['a', 'b', 'c']);21 });22});23describe('Test', () => {24 it('test', () => {25 const obj = { a: 1, b: 2, c: 3 };26 const obj2 = Object.assign({}, obj);27 expect(obj2).to.deep.equal({ a: 1, b: 2, c: 3 });28 });29});30describe('Test', () => {31 it('test', () => {32 ];33 const obj = Object.fromEntries(entries);34 expect(obj).to.deep.equal({ a: 1, b: 2, c: 3 });35 });36});37describe('Test', () => {38 it('test', () => {39 const obj = { a: 1, b: 2, c: 3 };40 const names = Object.getOwnPropertyNames(obj);41 expect(names).to.deep.equal(['a', 'b', 'c']);42 });43});44describe('Test', () => {45 it('test', () => {46 expect(Object.is(1,
Using AI Code Generation
1const obj = { a: 1, b: 2, c: 3 }2const values = Object.values(obj)3const obj = { a: 1, b: 2, c: 3 }4const values = Object.values(obj)5const obj = { a: 1, b: 2, c: 3 }6const values = _.values(obj)7How to use Object.values() in JavaScript?8How to use Object.values() in Node.js?9How to use Object.values() in Lodash?10How to use Object.values() in React.js?11How to use Object.values() in Angular?12How to use Object.values() in Vue.js?13How to use Object.values() in TypeScript?14How to use Object.values() in Python?15How to use Object.values() in PHP?16How to use Object.values() in Ruby?17How to use Object.values() in Java?18How to use Object.values() in C++?19How to use Object.values() in C#?20How to use Object.values() in Go?21How to use Object.values() in Swift?22How to use Object.values() in Kotlin?23How to use Object.values() in Dart?24How to use Object.values() in Scala?25How to use Object.values() in Rust?26How to use Object.values() in Perl?27How to use Object.values() in R?28How to use Object.values() in Julia?
Using AI Code Generation
1describe('Cypress Object.values', () => {2 it('Object.values', () => {3 const obj = { a: 1, b: 2, c: 3 };4 const values = Object.values(obj);5 expect(values).to.deep.equal([1, 2, 3]);6 });7});8{9}
Using AI Code Generation
1describe('Object.values', () => {2 it('Object.values', () => {3 const obj = { a: 1, b: 2, c: 3 };4 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);5 });6});7describe('Object.values', () => {8 it('Object.values', () => {9 const obj = { a: 1, b: 2, c: 3 };10 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);11 });12});13describe('Object.values', () => {14 it('Object.values', () => {15 const obj = { a: 1, b: 2, c: 3 };16 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);17 });18});19describe('Object.values', () => {20 it('Object.values', () => {21 const obj = { a: 1, b: 2, c: 3 };22 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);23 });24});25describe('Object.values', () => {26 it('Object.values', () => {27 const obj = { a: 1, b: 2, c: 3 };28 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);29 });30});31describe('Object.values', () => {32 it('Object.values', () => {33 const obj = { a: 1, b: 2, c: 3 };34 expect(Object.values(obj)).to.deep.eq([1, 2, 3]);35 });36});37describe('Object.values', () => {38 it('Object.values', () => {39 const obj = { a: 1, b: 2, c: 3 };40 expect(Object.values(obj)).to.deep.eq([1,
Using AI Code Generation
1describe('Test', () => {2 it('Test', () => {3 cy.get('input[name="q"]').type('test')4 cy.get('input[name="btnK"]').click()5 cy.get('div#search').should('have.text', 'test')6 })7})8Your name to display (optional):9Your name to display (optional):10Your name to display (optional):
Using AI Code Generation
1describe('Test', () => {2 it('test', () => {3 cy.get('#dropdown').select('Option 1')4 cy.get('#dropdown').then(($element) => {5 const values = Object.values($element[0].options)6 console.log(values)7 values.forEach((value) => {8 console.log(value.text)9 })10 })11 })12})13describe('Test', () => {14 it('test', () => {15 cy.get('#dropdown').select('Option 1')16 cy.get('#dropdown').then(($element) => {17 const values = Object.keys($element[0].options)18 console.log(values)19 values.forEach((value) => {20 console.log(value.text)21 })22 })23 })24})25describe('Test', () => {26 it('test', () => {27 cy.get('#dropdown').select('Option 1')28 cy.get('#dropdown').then(($element) => {29 const values = Object.assign({}, $element[0].options)30 console.log(values)31 values.forEach((value) => {32 console.log(value.text)33 })34 })35 })36})37describe('Test', () => {38 it('test', () => {
Using AI Code Generation
1cy.get('.dropdown').then($el => {2 const options = $el.find('option')3 const values = Object.values(options)4 values.forEach(value => {5 cy.get('.dropdown').select(text)6 })7})8cy.get('.dropdown').then($el => {9 const options = $el.find('option')10 const keys = Object.keys(options)11 keys.forEach(key => {12 cy.get('.dropdown').select(text)13 })14})15cy.get('.dropdown').then($el => {16 const options = $el.find('option')17 const entries = Object.entries(options)18 entries.forEach(entry => {19 cy.get('.dropdown').select(text)20 })21})22cy.get('.dropdown').then($el => {23 const options = $el.find('option')24 const properties = Object.getOwnPropertyNames(options)25 properties.forEach(property => {26 cy.get('.dropdown').select(text)27 })28})29cy.get('.dropdown').then($el => {30 const options = $el.find('option')31 const symbols = Object.getOwnPropertySymbols(options)32 symbols.forEach(symbol => {33 cy.get('.dropdown').select(text)34 })35})36cy.get('.dropdown').then($el => {37 const options = $el.find('option')38 const isSame = Object.is(options, options)39 if (isSame) {40 options.forEach(option => {41 cy.get('.dropdown').select(text)42 })43 }44})45cy.get('.dropdown').then($el => {46 const options = $el.find('option')47 const newOptions = Object.setPrototypeOf(options, options)48 newOptions.forEach(option => {49 cy.get('.dropdown').select(text)50 })51})52cy.get('.dropdown').then($el => {53 const options = $el.find('option')
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!