forked from microsoft/action-publish-symbols
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tanmayghosh2507/taghos-jest
Preparing for first release
- Loading branch information
Showing
23 changed files
with
1,127 additions
and
10,627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @tanmayghosh2507 @wlhutchison @safalk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest: current file", | ||
//"env": { "NODE_ENV": "test" }, | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["${fileBasenameNoExtension}", "--config", "jest.config.js"], | ||
"console": "integratedTerminal", | ||
"disableOptimisticBPs": true, | ||
"windows": { | ||
"program": "${workspaceFolder}/node_modules/jest/bin/jest" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import * as io from '@actions/io' | ||
import * as core from '@actions/core' | ||
import {getEnvVar, getInputWithDefault, getTempFileName, parseBoolean} from '../src/helpers' | ||
const fs = require('fs') | ||
|
||
describe('Helper Unit Tests', () => { | ||
beforeEach(async () => { | ||
jest.mock('@actions/core') | ||
jest.spyOn(core, 'debug') | ||
jest.spyOn(core, 'info') | ||
jest.spyOn(core, 'error') | ||
}) | ||
|
||
it('getTempFileName successful - Generate Temp file', () => { | ||
// Arrange | ||
jest.mock('fs') | ||
jest.spyOn(fs, 'existsSync') | ||
fs.existsSync.mockReturnValueOnce(true).mockReturnValue(false) | ||
|
||
// Act | ||
getTempFileName() | ||
|
||
// Assert | ||
expect(core.error).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('getTempFileName successful - Exists even after 5 attempts', () => { | ||
// Arrange | ||
jest.mock('fs') | ||
jest.spyOn(fs, 'existsSync') | ||
fs.existsSync.mockReturnValue(true) | ||
|
||
// Act | ||
try { | ||
getTempFileName() | ||
} catch (err) { | ||
expect(err.message).toBe('Unable to create unique temp file name after 6 attempts') | ||
} | ||
|
||
// Assert | ||
expect(core.error).toHaveBeenCalled() | ||
}) | ||
|
||
it('parseBoolean returns true for string true', () => { | ||
var out = parseBoolean('true') | ||
|
||
expect(out).toBe(true) | ||
}) | ||
|
||
it('parseBoolean returns true for int 1', () => { | ||
var out = parseBoolean('1') | ||
|
||
expect(out).toBe(true) | ||
}) | ||
|
||
it('parseBoolean returns false for string false', () => { | ||
var out = parseBoolean('false') | ||
|
||
expect(out).toBe(false) | ||
}) | ||
|
||
it('parseBoolean returns false for int 0', () => { | ||
var out = parseBoolean('0') | ||
|
||
expect(out).toBe(false) | ||
}) | ||
|
||
it('getInputWithDefault returns provided input', () => { | ||
// Arrange | ||
jest.spyOn(core, 'getInput').mockReturnValue('sampleInput') | ||
|
||
// Act | ||
var out = getInputWithDefault('input', 'defaultValue') | ||
|
||
// Assert | ||
expect(out).toBe('sampleInput') | ||
}) | ||
|
||
it('getInputWithDefault returns default as no input provided', () => { | ||
// Arrange | ||
jest.spyOn(core, 'getInput').mockReturnValue('') | ||
|
||
// Act | ||
var out = getInputWithDefault('input', 'defaultValue') | ||
|
||
// Assert | ||
expect(out).toBe('defaultValue') | ||
}) | ||
|
||
it('getEnvVar success', () => { | ||
var out = getEnvVar('GITHUB_WORKFLOW') | ||
|
||
expect(out).toBe('1') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import * as hlp from '../src/helpers' | ||
|
||
test('test getTempPath', async () => { | ||
let tempPath = hlp.getTempPath() | ||
expect(tempPath.length).toBeGreaterThan(0) | ||
let tempPath = hlp.getTempPath() | ||
expect(tempPath.length).toBeGreaterThan(0) | ||
}) | ||
|
||
test('test getTempFileName', async () => { | ||
let tempFileName = hlp.getTempFileName() | ||
expect(tempFileName.length).toBeGreaterThan(0) | ||
}) | ||
let tempFileName = hlp.getTempFileName() | ||
expect(tempFileName.length).toBeGreaterThan(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import * as a from '../src/action' | ||
import * as path from 'path' | ||
import * as a from '../src/Action' | ||
|
||
test('getSymbolServiceUri', async () => { | ||
await a.run() | ||
}) | ||
await a.run() | ||
}) |
Oops, something went wrong.