From 16d9a2f30ccf5c608b658593feaffad255248ca9 Mon Sep 17 00:00:00 2001 From: Neha Batra Date: Tue, 5 Mar 2024 18:24:01 -0800 Subject: [PATCH] Eliminate redundant lines and add tests --- app.ts | 4 ---- test/app.test.ts | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 test/app.test.ts diff --git a/app.ts b/app.ts index 2a97505..ead8ac3 100644 --- a/app.ts +++ b/app.ts @@ -1,6 +1,2 @@ console.log("hello world"); console.log("nice to meet you!!"); -console.log("hello world"); -console.log("nice to meet you!!"); -console.log("hello world"); -console.log("nice to meet you!!"); diff --git a/test/app.test.ts b/test/app.test.ts new file mode 100644 index 0000000..2b031f5 --- /dev/null +++ b/test/app.test.ts @@ -0,0 +1,14 @@ +// Import a testing framework (e.g. Mocha, Jest, etc.) +const assert = require('assert'); +const { execSync } = require('child_process'); + +// Write a test suite for app.ts +describe('app.ts', function() { + // Write a test case that checks that app.ts prints "hello world" and "nice to meet you!!" to the console + it('should print hello world and nice to meet you!!', function() { + // Run app.ts and capture the output + const output = execSync('node app.ts').toString(); + // Assert that the output matches the expected strings + assert.match(output, /hello world\nnice to meet you!!\n/); + }); +});