我正在尝试使用react测试库测试组件,而我的组件正在使用i18n,当我运行测试时出现此错误:
struct ethernetHeader{
unsigned char receiverMac[6];
unsigned char senderMac [6];
unsigned char type [2];
};
//Not sure how to convert unsigned char to Bit or atleast integer
struct IPv4Header{
//4 Bit Version
//4 Bit IHL
//8 Bit Type of Service
//16 Bit Packet length
//16 Bit Identification
// 3 Bit Flags
//13 Bit Fragment offset
//8 Bit TTL
//8 Bit protocol
//16 Bit Header Checksum
//32 Bit Source IP
//32 Bit Destination IP
//32 Bit Options -> NULL will be discarded
};
struct arpHeader{
//to be defined
};
struct frame{
struct ethernetHeader ethHdr;
struct IPv4Header ip4Hdr;
struct arpHeader arpHdr;
unsigned char buffer[2024];
};
while(1) {
//postpones execution if no event is available
event_mask = Event_pend(my_network_events,NON_EVENT_MASK,(EMAC_RX_EVENT | EMAC_TX_EVENT | EMAC_RX_NO_BUFFER),BIOS_WAIT_FOREVER);
/*no receiver buffer was available
* */
if(event_mask & EMAC_RX_NO_BUFFER) {
FreeEmacRxBuf();
EMACRxDMAPollDemand(EMAC0_BASE);
}
//
// Check for an RX Packet and read it.
//
if(event_mask & EMAC_RX_EVENT)
{
// Get the packet and set uip_len for uIP stack usage.
//
eth_rx_ptr = PacketReceive((int32_t *)(ð_len));
if(eth_len > ETH_BUFSIZE)
eth_len = ETH_BUFSIZE;//truncate received packet length if necessary
/* copy to private buffer and free */
memcpy(eth_buf,eth_rx_ptr,eth_len);
FreeEmacRxBuf();
eth_rx_ptr = NULL;
struct ethernetHeader header;
memcpy(header.receiverMac, ð_buf[0], 6);
memcpy(header.senderMac, ð_buf[6], 6);
memcpy(header.type, ð_buf[12],2);
}
}
如果我的测试通过了此行,但我需要i18n才能工作,该如何模拟呢?
这是我的test.js
TypeError: Cannot read property '_' of undefined
47 | color={color}
48 | variant={variant}
> 49 | data-tooltip={i18n._(tooltip)}
| ^
50 | onClick={callback}
51 | >
52 | <FontAwesomeIcon icon={faCross} />