forked from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
14,434 additions
and
14,413 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 +1,2 @@ | ||
node_modules | ||
node_modules | ||
.env |
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,19 @@ | ||
{ | ||
// 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 Test", | ||
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js", | ||
"args": [ | ||
"-i" | ||
], | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"envFile": "${workspaceFolder}/.env" | ||
} | ||
] | ||
} |
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,165 @@ | ||
test('throws invalid number', async() => { | ||
//todo - many tests are checked in 'test.yml' action | ||
}); | ||
const core = require('@actions/core'); | ||
|
||
const action = './src'; | ||
|
||
const webhook_url = process.env.MSTEAMS_WEBHOOK; | ||
const dry_run = process.env.DRY_RUN.toLowerCase() == "true"; | ||
|
||
const setInputsMock = (inputs) => | ||
jest.fn().mockImplementation((name, options) => inputs[name]); | ||
|
||
afterEach(() => { | ||
jest.resetModules(); | ||
}); | ||
|
||
test('One with everything', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
needs: JSON.stringify({ | ||
|
||
}), | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One with needs', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
needs: JSON.stringify({ | ||
|
||
}), | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require('./src'); | ||
}); | ||
|
||
test('One with steps', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
needs: JSON.stringify({ | ||
|
||
}), | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One failure', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
needs: JSON.stringify({ | ||
|
||
}), | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One with little info', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One without emails', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
title: "`Overwrote title in ${workflow_link}`", | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One with emails', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
title: "`Overwrote title in ${workflow_link}`", | ||
msteams_emails: "mm@mm.mm, yy@yy.yy, rr@rr.rr", | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One with overwrite', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
title: "`Overwrote title in ${workflow_link}`", | ||
job: JSON.stringify({ | ||
|
||
}), | ||
steps: JSON.stringify({ | ||
|
||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); | ||
|
||
test('One with raw data', () => { | ||
core.getInput = setInputsMock({ | ||
webhook_url, | ||
raw: JSON.stringify({ | ||
"type": "message", | ||
"attachments": | ||
[ | ||
{ | ||
"contentType": "application/vnd.microsoft.card.adaptive", | ||
"content": | ||
{ | ||
"type": "AdaptiveCard", | ||
"body": | ||
[ | ||
{ | ||
"type": "TextBlock", | ||
"size": "Medium", | ||
"weight": "Bolder", | ||
"text": "Test title text" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}), | ||
dry_run | ||
}); | ||
require(action); | ||
}); |
Oops, something went wrong.