LCOV - code coverage report
Current view: top level - test/wpt/xhr/formdata - set.any.js (source / functions) Hit Total Coverage
Test: lcov.info Lines: 75 75 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']).get('key'), 'value1');
       7                 :          1 :         assert.strictEqual(create_formdata(['key', 'value2'], ['key', 'value1']).get('key'), 'value1');
       8                 :          1 :         assert.strictEqual(create_formdata(['key', undefined]).get('key'), 'undefined');
       9                 :          1 :         assert.strictEqual(create_formdata(['key', undefined], ['key', 'value1']).get('key'), 'value1');
      10                 :          1 :         assert.strictEqual(create_formdata(['key', null]).get('key'), 'null');
      11                 :          1 :         assert.strictEqual(create_formdata(['key', null], ['key', 'value1']).get('key'), 'value1');
      12                 :          1 : 
      13                 :          1 :         const fd = new FormData();
      14                 :          1 :         fd.set('key', new Blob([]), 'blank.txt');
      15                 :          1 : 
      16                 :          1 :         const file = fd.get('key');
      17                 :          1 : 
      18                 :          1 :         assert(file instanceof File);
      19                 :          1 :         assert.strictEqual(file.name, 'blank.txt');
      20                 :          1 : 
      21            [ + ]:          1 :         function create_formdata() {
      22                 :          6 :                 const fd = new FormData();
      23                 :          6 : 
      24            [ + ]:          6 :                 for(let i = 0; i < arguments.length; i++){
      25                 :          9 :                         fd.set.apply(fd, arguments[i]);
      26                 :          6 :                 };
      27                 :          6 : 
      28                 :          6 :                 return fd;
      29                 :          6 :         }
      30                 :          1 : }
      31                 :          1 : 
      32                 :          1 : /*
      33                 :          1 :  * set.any.js
      34                 :          1 :  *
      35                 :          1 : 
      36                 :          1 : // META: title=FormData: set
      37                 :          1 : 
      38                 :          1 :     test(function() {
      39                 :          1 :         assert_equals(create_formdata(['key', 'value1']).get('key'), "value1");
      40                 :          1 :     }, 'testFormDataSet1');
      41                 :          1 :     test(function() {
      42                 :          1 :         assert_equals(create_formdata(['key', 'value2'], ['key', 'value1']).get('key'), "value1");
      43                 :          1 :     }, 'testFormDataSet2');
      44                 :          1 :     test(function() {
      45                 :          1 :         assert_equals(create_formdata(['key', undefined]).get('key'), "undefined");
      46                 :          1 :     }, 'testFormDataSetUndefined1');
      47                 :          1 :     test(function() {
      48                 :          1 :         assert_equals(create_formdata(['key', undefined], ['key', 'value1']).get('key'), "value1");
      49                 :          1 :     }, 'testFormDataSetUndefined2');
      50                 :          1 :     test(function() {
      51                 :          1 :         assert_equals(create_formdata(['key', null]).get('key'), "null");
      52                 :          1 :     }, 'testFormDataSetNull1');
      53                 :          1 :     test(function() {
      54                 :          1 :         assert_equals(create_formdata(['key', null], ['key', 'value1']).get('key'), "value1");
      55                 :          1 :     }, 'testFormDataSetNull2');
      56                 :          1 :     test(function() {
      57                 :          1 :         var fd = new FormData();
      58                 :          1 :         fd.set('key', new Blob([]), 'blank.txt');
      59                 :          1 :         var file = fd.get('key');
      60                 :          1 : 
      61                 :          1 :         assert_true(file instanceof File);
      62                 :          1 :         assert_equals(file.name, 'blank.txt');
      63                 :          1 :     }, 'testFormDataSetEmptyBlob');
      64                 :          1 : 
      65                 :          1 :     function create_formdata() {
      66                 :          1 :         var fd = new FormData();
      67                 :          1 :         for (var i = 0; i < arguments.length; i++) {
      68                 :          1 :             fd.set.apply(fd, arguments[i]);
      69                 :          1 :         };
      70                 :          1 :         return fd;
      71                 :          1 :     }
      72                 :          1 : 
      73                 :          1 :  *
      74                 :          1 :  *
      75                 :          1 :  */

Generated by: LCOV version 1.14