-
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.
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
CrazyMax
committed
Aug 17, 2020
1 parent
512e4e9
commit 363c8ed
Showing
8 changed files
with
13,983 additions
and
10,311 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 |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - v2-working-branch # remove when merged to master | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| - v2-working-branch # remove when merged to master | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - | ||
| name: Checkout | ||
| uses: actions/checkout@v2.3.1 | ||
| - | ||
| name: Install | ||
| run: yarn install | ||
| - | ||
| name: Test | ||
| run: yarn run test | ||
| # - | ||
| # name: Upload coverage | ||
| # uses: codecov/codecov-action@v1.0.7 | ||
| # if: success() | ||
| # with: | ||
| # token: ${{ secrets.CODECOV_TOKEN }} | ||
| # file: ./coverage/clover.xml |
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,60 @@ | ||
| import * as context from '../src/context'; | ||
|
|
||
| describe('getInputList', () => { | ||
| it('handles single line correctly', async () => { | ||
| await setInput('foo', 'bar'); | ||
| const res = await context.getInputList('foo'); | ||
| console.log(res); | ||
| expect(res).toEqual(['bar']); | ||
| }); | ||
|
|
||
| it('handles multiple lines correctly', async () => { | ||
| setInput('foo', 'bar\nbaz'); | ||
| const res = await context.getInputList('foo'); | ||
| console.log(res); | ||
| expect(res).toEqual(['bar', 'baz']); | ||
| }); | ||
|
|
||
| it('handles comma correctly', async () => { | ||
| setInput('foo', 'bar,baz'); | ||
| const res = await context.getInputList('foo'); | ||
| console.log(res); | ||
| expect(res).toEqual(['bar', 'baz']); | ||
| }); | ||
|
|
||
| it('handles different new lines correctly', async () => { | ||
| setInput('foo', 'bar\r\nbaz'); | ||
| const res = await context.getInputList('foo'); | ||
| console.log(res); | ||
| expect(res).toEqual(['bar', 'baz']); | ||
| }); | ||
|
|
||
| it('handles different new lines and comma correctly', async () => { | ||
| setInput('foo', 'bar\r\nbaz,bat'); | ||
| const res = await context.getInputList('foo'); | ||
| console.log(res); | ||
| expect(res).toEqual(['bar', 'baz', 'bat']); | ||
| }); | ||
| }); | ||
|
|
||
| describe('asyncForEach', () => { | ||
| it('executes async tasks sequentially', async () => { | ||
| const testValues = [1, 2, 3, 4, 5]; | ||
| const results: number[] = []; | ||
|
|
||
| await context.asyncForEach(testValues, async value => { | ||
| results.push(value); | ||
| }); | ||
|
|
||
| expect(results).toEqual(testValues); | ||
| }); | ||
| }); | ||
|
|
||
| // See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67 | ||
| function getInputName(name: string): string { | ||
| return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`; | ||
| } | ||
|
|
||
| function setInput(name: string, value: string): void { | ||
| process.env[getInputName(name)] = value; | ||
| } |
Oops, something went wrong.