Skip to content

Commit

Permalink
update dist/ and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishkeshan committed Nov 28, 2023
1 parent ef9ac67 commit ed36a8e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const cp = require('child_process')
const path = require('path')

const node = process.execPath
const ip = path.join(__dirname, '..', 'src', 'main.js')
const ip = path.join(__dirname, '..', 'dist', 'main.js')

function runTestWithEnv(env) {
const options = {
Expand Down Expand Up @@ -54,13 +54,28 @@ test('grants score if test passes', () => {
INPUT_COMMAND: 'echo Hello, World!',
'INPUT_EXPECTED-OUTPUT': 'Hello, World!',
'INPUT_COMPARISON-METHOD': 'exact',
'INPUT_MAX-SCORE': '100',
INPUT_TIMEOUT: 10,
'INPUT_MAX-SCORE': 100,
})

expect(result.max_score).toBe(100)
expect(result.tests[0].score).toBe(100)
})

test('does not grant score if test fails', () => {
const result = runTestWithEnv({
'INPUT_TEST-NAME': 'Max Score Test Fail',
INPUT_COMMAND: 'echo Hello, World!',
'INPUT_EXPECTED-OUTPUT': 'Hello, World!!',
'INPUT_COMPARISON-METHOD': 'exact',
INPUT_TIMEOUT: 10,
'INPUT_MAX-SCORE': 100,
})

expect(result.max_score).toBe(100)
expect(result.tests[0].score).toBe(0)
})

test('outputs error if test-name not provided', () => {
const result = runTestWithEnv({})

Expand Down
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function run() {
} else if (!compareOutput(output, inputs.expectedOutput, inputs.comparisonMethod)) {
status = 'fail'
message = `Output does not match expected. Got: ${output}`
score = 0
}

const result = {
Expand Down

0 comments on commit ed36a8e

Please sign in to comment.