Skip to content

Instantly share code, notes, and snippets.

@theusindabike
Created May 23, 2023 19:53
Show Gist options
  • Save theusindabike/39e334feecef0c009faea2ce207ab133 to your computer and use it in GitHub Desktop.
Save theusindabike/39e334feecef0c009faea2ce207ab133 to your computer and use it in GitHub Desktop.
using mock-fs to create a text file
it('throws error if class-validator return error', async () => {
mockfs({
'test_dir/assets': {
'sales_sample.txt': mockfs.file({
content:
'2022-01-15T19:20:30-03:00CURSO DE BEM-ESTAR 0000012750JOSE CARLOS\n12021-12-03T11:46:02-03:00DOMINANDO INVESTIMENTOS 0000050000MARIA CANDIDA',
}),
},
});
const file = fs.readFileSync('test_dir/assets/sales_sample.txt');
mockfs.restore();
expect(
service.importTransactions({ buffer: file } as Express.Multer.File),
).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment