LCOV - code coverage report
Current view: top level - test/wpt/xhr/formdata - get.any.js (source / functions) Hit Total Coverage
Test: lcov.info Lines: 61 61 100.0 %
Date: 2025-01-24 02:02:48 Functions: 2 2 100.0 %
Branches: 4 4 100.0 %

           Branch data     Line data    Source code
       1            [ + ]:          1 : import assert from 'node:assert/strict';
       2                 :          1 : import { FormData } from '../../../../lib/whatwg-xhr.js';
       3                 :          1 : 
       4            [ + ]:          1 : export default (activeURL) => {
       5                 :          1 : 
       6                 :          1 :         assert.strictEqual(create_formdata(['key', 'value1'], ['key', 'value2']).get('key'), "value1");
       7                 :          1 :         assert.strictEqual(create_formdata(['key', 'value1'], ['key', 'value2']).get('nil'), null);
       8                 :          1 :         assert.strictEqual(create_formdata().get('key'), null);
       9                 :          1 : 
      10                 :          1 :         assert.deepStrictEqual(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('key'), ["value1", "value2"]);
      11                 :          1 :         assert.deepStrictEqual(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('nil'), []);
      12                 :          1 :         assert.deepStrictEqual(create_formdata().getAll('key'), []);
      13                 :          1 : 
      14            [ + ]:          1 :         function create_formdata() {
      15                 :          6 :                 const fd = new FormData();
      16                 :          6 : 
      17            [ + ]:          6 :                 for(let i = 0; i < arguments.length; i++){
      18                 :          8 :                         fd.append.apply(fd, arguments[i]);
      19                 :          6 :                 };
      20                 :          6 : 
      21                 :          6 :                 return fd;
      22                 :          6 :         }
      23                 :          1 : }
      24                 :          1 : 
      25                 :          1 : /*
      26                 :          1 :  * get.any.js
      27                 :          1 :  *
      28                 :          1 : 
      29                 :          1 : // META: title=FormData: get and getAll
      30                 :          1 : 
      31                 :          1 :     test(function() {
      32                 :          1 :         assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).get('key'), "value1");
      33                 :          1 :     }, 'testFormDataGet');
      34                 :          1 :     test(function() {
      35                 :          1 :         assert_equals(create_formdata(['key', 'value1'], ['key', 'value2']).get('nil'), null);
      36                 :          1 :     }, 'testFormDataGetNull1');
      37                 :          1 :     test(function() {
      38                 :          1 :         assert_equals(create_formdata().get('key'), null);
      39                 :          1 :     }, 'testFormDataGetNull2');
      40                 :          1 :     test(function() {
      41                 :          1 :         assert_array_equals(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('key'), ["value1", "value2"]);
      42                 :          1 :     }, 'testFormDataGetAll');
      43                 :          1 :     test(function() {
      44                 :          1 :         assert_array_equals(create_formdata(['key', 'value1'], ['key', 'value2']).getAll('nil'), []);
      45                 :          1 :     }, 'testFormDataGetAllEmpty1');
      46                 :          1 :     test(function() {
      47                 :          1 :         assert_array_equals(create_formdata().getAll('key'), []);
      48                 :          1 :     }, 'testFormDataGetAllEmpty2');
      49                 :          1 : 
      50                 :          1 :     function create_formdata() {
      51                 :          1 :         var fd = new FormData();
      52                 :          1 :         for (var i = 0; i < arguments.length; i++) {
      53                 :          1 :             fd.append.apply(fd, arguments[i]);
      54                 :          1 :         };
      55                 :          1 :         return fd;
      56                 :          1 :     }
      57                 :          1 : 
      58                 :          1 :  *
      59                 :          1 :  *
      60                 :          1 :  */
      61                 :          1 : 

Generated by: LCOV version 1.14