|
| 1 | +const ExcelJS = verquire('exceljs'); |
| 2 | + |
| 3 | +describe('github issues', () => { |
| 4 | + describe('issue 10 - (dataValidation) The exported table inserts a drop-down menu for the cell. The cell cannot display drop-down options', () => { |
| 5 | + it('issue 10 - (dataValidation) Input content is 266 characters, more than 255 characters, throw error', async () => { |
| 6 | + async function test() { |
| 7 | + const workbook = new ExcelJS.Workbook(); |
| 8 | + const worksheet = workbook.addWorksheet('sheet'); |
| 9 | + const columns = [ |
| 10 | + { |
| 11 | + header: 'Test1', |
| 12 | + key: 'test1', |
| 13 | + width: 25, |
| 14 | + }, |
| 15 | + ]; |
| 16 | + worksheet.columns = columns; |
| 17 | + const cell = worksheet.getCell('A2'); |
| 18 | + const value = |
| 19 | + '"1234 Main St, Anytown 56789,5678 Elm Ave, Smallville 23456,9012 Oak Rd, Big City 34567,3456 Pine Dr, Tinytown 67890,7890 Maple Ln, Mediumtown 12345,2345 Hickory St, Suburbia 45678,6789 Cedar Cir, Urbanville 89012,0123 Birch Blvd, Countryside 23456,4567 Wal"'; |
| 20 | + cell.dataValidation = { |
| 21 | + type: 'list', |
| 22 | + allowBlank: true, |
| 23 | + formulae: [value], |
| 24 | + }; |
| 25 | + await workbook.xlsx.writeFile( |
| 26 | + './spec/integration/data/test-new-issue-10-1.xlsx' |
| 27 | + ); |
| 28 | + } |
| 29 | + let error; |
| 30 | + try { |
| 31 | + await test(); |
| 32 | + } catch (err) { |
| 33 | + error = err; |
| 34 | + } |
| 35 | + expect(error) |
| 36 | + .to.be.an('error') |
| 37 | + .with.property( |
| 38 | + 'message', |
| 39 | + 'The input cannot be larger than 255 characters. Please check the value of dataValidation.formulae' |
| 40 | + ); |
| 41 | + }); |
| 42 | + |
| 43 | + it('issue 2256 - (dataValidation) Input content is 255 characters, normal display', async () => { |
| 44 | + async function test() { |
| 45 | + const workbook = new ExcelJS.Workbook(); |
| 46 | + const worksheet = workbook.addWorksheet('sheet'); |
| 47 | + const columns = [ |
| 48 | + { |
| 49 | + header: 'Test1', |
| 50 | + key: 'test1', |
| 51 | + width: 25, |
| 52 | + }, |
| 53 | + ]; |
| 54 | + worksheet.columns = columns; |
| 55 | + const cell = worksheet.getCell('A2'); |
| 56 | + const value = |
| 57 | + '"1234 Main St, Anytown 56789,5678 Elm Ave, Smallville 23456,9012 Oak Rd, Big City 34567,3456 Pine Dr, Tinytown 67890,7890 Maple Ln, Mediumtown 12345,2345 Hickory St, Suburbia 45678,6789 Cedar Cir, Urbanville 89012,0123 Birch Blvd, Countryside 23456,4567 Wa"'; |
| 58 | + cell.dataValidation = { |
| 59 | + type: 'list', |
| 60 | + allowBlank: true, |
| 61 | + formulae: [value], |
| 62 | + }; |
| 63 | + await workbook.xlsx.writeFile( |
| 64 | + './spec/integration/data/test-new-issue-10-2.xlsx' |
| 65 | + ); |
| 66 | + } |
| 67 | + await test(); |
| 68 | + }); |
| 69 | + }); |
| 70 | +}); |
0 commit comments