|
| 1 | +/* |
| 2 | + * Copyright (c) 2026 Nordic Semiconductor ASA |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause |
| 5 | + */ |
| 6 | + |
| 7 | +import { |
| 8 | + isValidNrf91x1FirmwareName, |
| 9 | + isValidNrf9160FirmwareName, |
| 10 | +} from '../ModemUpdateDialogView'; |
| 11 | + |
| 12 | +describe('Modem firmware filename validation', () => { |
| 13 | + describe('nRF9160 firmware names', () => { |
| 14 | + it('accepts names from https://www.nordicsemi.com/Products/nRF9160/Download', () => { |
| 15 | + expect(isValidNrf9160FirmwareName('mfw_nrf9160_1.1.0.zip')).toBe( |
| 16 | + true, |
| 17 | + ); |
| 18 | + expect(isValidNrf9160FirmwareName('mfw_nrf9160_1.3.7.zip')).toBe( |
| 19 | + true, |
| 20 | + ); |
| 21 | + }); |
| 22 | + |
| 23 | + it('accepts undefined as valid (no file selected)', () => { |
| 24 | + expect(isValidNrf9160FirmwareName(undefined)).toBe(true); |
| 25 | + }); |
| 26 | + |
| 27 | + describe('invalid names', () => { |
| 28 | + it('rejects wrong prefix', () => { |
| 29 | + expect(isValidNrf9160FirmwareName('fw_nrf9160_1.0.0.zip')).toBe( |
| 30 | + false, |
| 31 | + ); |
| 32 | + }); |
| 33 | + |
| 34 | + it('rejects non-zip file', () => { |
| 35 | + expect( |
| 36 | + isValidNrf9160FirmwareName('mfw_nrf9160_1.1.0.tar'), |
| 37 | + ).toBe(false); |
| 38 | + }); |
| 39 | + |
| 40 | + it('rejects nRF91x1 firmware names', () => { |
| 41 | + expect( |
| 42 | + isValidNrf9160FirmwareName('mfw_nrf91x1_2.0.4.zip'), |
| 43 | + ).toBe(false); |
| 44 | + expect( |
| 45 | + isValidNrf9160FirmwareName('mfw-pti_nrf91x1_2.3.8.zip'), |
| 46 | + ).toBe(false); |
| 47 | + }); |
| 48 | + }); |
| 49 | + }); |
| 50 | + |
| 51 | + describe('nRF91x1 firmware names', () => { |
| 52 | + it('accepts names from https://www.nordicsemi.com/Products/nRF9161/Download', () => { |
| 53 | + expect(isValidNrf91x1FirmwareName('mfw_nrf91x1_2.0.0.zip')).toBe( |
| 54 | + true, |
| 55 | + ); |
| 56 | + expect(isValidNrf91x1FirmwareName('mfw_nrf91x1_2.0.4.zip')).toBe( |
| 57 | + true, |
| 58 | + ); |
| 59 | + expect( |
| 60 | + isValidNrf91x1FirmwareName('mfw-pti_nrf91x1_2.3.1.zip'), |
| 61 | + ).toBe(true); |
| 62 | + expect( |
| 63 | + isValidNrf91x1FirmwareName('mfw-pti_nrf91x1_2.3.8.zip'), |
| 64 | + ).toBe(true); |
| 65 | + }); |
| 66 | + |
| 67 | + it('DECT names from https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nr-phy', () => { |
| 68 | + expect( |
| 69 | + isValidNrf91x1FirmwareName('mfw-nr+_nrf91x1_1.0.0.zip'), |
| 70 | + ).toBe(true); |
| 71 | + }); |
| 72 | + |
| 73 | + it('accepts undefined as valid (no file selected)', () => { |
| 74 | + expect(isValidNrf91x1FirmwareName(undefined)).toBe(true); |
| 75 | + }); |
| 76 | + |
| 77 | + describe('invalid names', () => { |
| 78 | + it('rejects wrong prefix', () => { |
| 79 | + expect(isValidNrf91x1FirmwareName('fw_nrf91x1_2.0.0.zip')).toBe( |
| 80 | + false, |
| 81 | + ); |
| 82 | + }); |
| 83 | + |
| 84 | + it('rejects non-zip file', () => { |
| 85 | + expect( |
| 86 | + isValidNrf91x1FirmwareName('mfw_nrf91x1_2.0.0.tar'), |
| 87 | + ).toBe(false); |
| 88 | + }); |
| 89 | + |
| 90 | + it('rejects nRF9160 firmware names', () => { |
| 91 | + expect( |
| 92 | + isValidNrf91x1FirmwareName('mfw_nrf9160_1.1.0.zip'), |
| 93 | + ).toBe(false); |
| 94 | + }); |
| 95 | + }); |
| 96 | + }); |
| 97 | +}); |
0 commit comments