Skip to content

Commit

Permalink
Fix unit test not working on GitHub #52.B Trying different GitHub Ac…
Browse files Browse the repository at this point in the history
…tions test script.
  • Loading branch information
CookingWithCale committed Dec 18, 2023
1 parent a27ef71 commit 18558d8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 29 deletions.
41 changes: 26 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
name: Testing

on: [pull_request]

name: Jest
on: push
jobs:
tests:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Name.js ${{ matrix.node-version }}
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
node-version: "12"

# Speed up subsequent runs with caching
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# Install required deps for action
- name: Install Dependencies
run: npm install
- name: tests
run: npm run test

# Finally, run our tests
- name: Run the tests
run: npm test
6 changes: 4 additions & 2 deletions Source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ export function LIDSource(lid: LID128) {
}

// Extracts the timestamp, ticker, and source from a LID64.
export function LIDPack(timestamp: number, ticker: number, source:bigint)
export function LIDPack(timestamp: bigint | number, ticker: bigint | number,
source:bigint)
: LID128 {
return (BigInt(timestamp) << (LIDTickerBitCount + LIDSourceBitCount)) |
(BigInt(ticker) << LIDSourceBitCount) | source;
Expand Down Expand Up @@ -743,7 +744,8 @@ export function LID64SourceId(): bigint {
}

// Extracts the timestamp, ticker, and source from a LID64.
export function LID64Pack(timestamp: number, ticker: number, source: bigint)
export function LID64Pack(timestamp: bigint | number, ticker: bigint | number,
source: bigint)
: LID64 {
return (BigInt(timestamp) << (64n - LID64TimestampBitCount)) |
(BigInt(ticker) << LID64SourceBitCount) |
Expand Down
10 changes: 5 additions & 5 deletions Test/LID.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// http://github.com/AStarStartup/LinearId

const { randomInt: rng } = require('crypto');
const { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
import { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
LIDPrint, LIDSourceBitCount, LIDTickerBitCount, LIDTimestampBitCount,
LIDNext, LIDPack, LIDTicker, LIDTimestamp, LIDSource, LIDUnpack,
NumberCountDecimals, NumberPad, TimestampSecondsNextBigInt
} = require('linearid');
LIDNext, LIDPack, LIDTimestamp, LIDUnpack, NumberCountDecimals, NumberPad,
TimestampSecondsNextBigInt
} from '../Source';

import { expect, test } from '@jest/globals';
import { TestCount, TestLoopCount } from './Global';
Expand Down Expand Up @@ -102,5 +102,5 @@ test('LID.Test', () => {
LIDCompare(timestamp_e, Received, '::LIDTimestamp::B', i);
}
}
expect(LIDPrint(LIDNext())).not.toBe(true);
expect(LIDPrint(LIDNext(rng))).not.toBe(true);
});
6 changes: 3 additions & 3 deletions Test/LID64.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// http://github.com/AStarStartup/LinearId

const { randomInt: rng } = require('crypto');
const { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
import { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
LID64Print, LID64SourceBitCount, LID64TickerBitCount, LID64TimestampBitCount,
LID64Next, LID64Pack, LID64Ticker, LID64Timestamp, LID64Source, LID64Unpack,
NumberCountDecimals, NumberPad, TimestampSecondsNextBigInt
} = require('linearid');
} from '../Source';

import { expect, test } from '@jest/globals';
import { TestCount, TestLoopCount } from './Global';
Expand Down Expand Up @@ -89,5 +89,5 @@ test('LID64.Test', () => {
LID64Compare(timestamp_e, Received, '::LID64Timestamp::B', i);
}
}
expect(LID64Print(LID64Next())).not.toBe(true);
expect(LID64Print(LID64Next(rng))).not.toBe(true);
});
4 changes: 2 additions & 2 deletions Test/LLID.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// http://github.com/AStarStartup/LinearId

const { randomInt: rng } = require('crypto');
const { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
import { BigIntInRange, BinaryPad, BinaryPadBitCount, HexPad, HexPadBitCount,
LLIDPrint, LLIDTickerBitCount, LLIDTimestampBitCount, LLIDNext, LLIDPack,
LLIDTimestamp, LLIDUnpack, NumberCountDecimals, NumberPad,
TimestampSecondsNextBigInt } = require('linearid');
TimestampSecondsNextBigInt } from '../Source';

import { expect, test } from '@jest/globals';
import { TestCount, TestLoopCount, } from './Global';
Expand Down
4 changes: 2 additions & 2 deletions Test/Utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// http://github.com/AStarStartup/LinearId

const { randomInt } = require('crypto');
const { BigIntCountDecimals, BigIntInBitRange, BigIntIsInBitRange,
import { BigIntCountDecimals, BigIntInBitRange, BigIntIsInBitRange,
BigIntToBuffer, BigIntRandom, BinaryPad, BinaryPadBitCount, BufferToBigInt,
ByteCountBits, HexToBigInt, HexToBuffer, HexPadBitCount, NumberCountBits,
NumberCountBytes, NumberCountDecimals
} = require('linearid');
} from '../Source';

import { expect, test } from '@jest/globals';
import { NumberInTestRange, TestBitCount, TestBitsUpTo, TestCount,
Expand Down

0 comments on commit 18558d8

Please sign in to comment.