Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1055,3 +1055,135 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter architectura ci:publish

## Assert

lint-assert:
needs: setup
runs-on: ubuntu-latest
# if: ${{ needs.setup.outputs.ts-files-changed == 'true' }}
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 9
run_install: false

- name: Dependencies cache unpacking
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Building workspace dependencies
run: pnpm --filter testing-ground ci:build

- name: Lint with ESlint
run: pnpm --filter assert ci:lint

typescript-syntax-check-assert:
needs: setup
runs-on: ubuntu-latest
# if: ${{ needs.setup.outputs.ts-files-changed == 'true' }}
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 9
run_install: false

- name: Dependencies cache unpacking
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Building workspace dependencies
run: pnpm --filter testing-ground ci:build

- name: Check TypeScript syntax
run: pnpm --filter assert ci:ts:check

test-assert:
needs: setup
runs-on: ubuntu-latest
# if: ${{ needs.setup.outputs.ts-files-changed == 'true' }}
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 9
run_install: false

- uses: actions/setup-node@v4
with:
node-version: "22.x"

- name: Dependencies cache unpacking
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Building workspace dependencies
run: pnpm --filter testing-ground ci:build

- name: Test with Node Test runner
run: pnpm --filter assert ci:test:unit

publish-assert:
if: ${{ github.ref == 'refs/heads/main' && ! failure() && ! cancelled() && github.event_name == 'push' }}
needs:
[
spell-check-global,
lint-assert,
typescript-syntax-check-assert,
test-assert,
]
runs-on: ubuntu-latest
environment: npm
steps:
- name: Check out repository code
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 9
run_install: false

- name: Dependencies cache unpacking
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Building workspace dependencies
run: pnpm --filter testing-ground ci:build

- name: Package build
run: pnpm --filter assert ci:build

- name: Publish package
id: package-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter assert ci:publish
6 changes: 4 additions & 2 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
"npm"
],
"words": [
"Vitruvius",
"architectura",
"fulfill",
"fulfills",
],
"ignoreWords": [
"Vitruvius",
"architectura",
"Lebacq",
"Zamralik",
"vars",
Expand Down
20 changes: 20 additions & 0 deletions packages/assert/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"src": "./src",
"include": [
"**/src/**"
],
"extension": [
".mts"
],
"reporter": [
"html"
],
"report-dir": "./reports/c8",
"skip-full": true,
"check-coverage": true,
"all": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
10 changes: 10 additions & 0 deletions packages/assert/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/node_modules/**
build
temp/logs/*.log
yarn.lock
package-lock.json
nodemon.json
yarn-error.log
.vscode/
**/database/**
coverage/
21 changes: 21 additions & 0 deletions packages/assert/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 VitruviusLabs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions packages/assert/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import configurations from "../../eslint.config.mjs";

export default configurations;
16 changes: 16 additions & 0 deletions packages/assert/mock/mock-assertion-instantiation.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { AssertionInstantiationInterface } from "../src/definition/interface/assertion-instantiation.interface.mjs";
import { FluentAssertion, RootAssertion } from "../src/assertion/_internal.mjs";

function mockAssertionInstantiation(): Required<AssertionInstantiationInterface>
{
const ROOT: RootAssertion = new RootAssertion("root");
const PARENT: FluentAssertion = new FluentAssertion({ root: ROOT, parent: ROOT, name: "parent" });

return {
root: ROOT,
parent: PARENT,
name: "the tested value",
};
}

export { mockAssertionInstantiation };
13 changes: 13 additions & 0 deletions packages/assert/mock/mock-assertion.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { FluentAssertion } from "../src/assertion/_internal.mjs";
import { mockAssertionInstantiation } from "./mock-assertion-instantiation.mjs";

function mockAssertion(value?: unknown): FluentAssertion
{
const ASSERTION: FluentAssertion = new FluentAssertion(mockAssertionInstantiation());

Reflect.set(ASSERTION, "actualValue", value);

return ASSERTION;
}

export { mockAssertion };
17 changes: 17 additions & 0 deletions packages/assert/mock/mock-child-assertion.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { FluentAssertion } from "../src/assertion/_internal.mjs";

function mockChildAssertion(parent: FluentAssertion, value: unknown, name: string): FluentAssertion
{
const ASSERTION: FluentAssertion = new FluentAssertion({
// @ts-expect-error: Access to private property.
root: parent.root,
parent: parent,
name: name,
});

Reflect.set(ASSERTION, "actualValue", value);

return ASSERTION;
}

export { mockChildAssertion };
12 changes: 12 additions & 0 deletions packages/assert/mock/mock-void-assertion.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { type FluentAssertion, VoidAssertion } from "../src/assertion/_internal.mjs";

function mockVoidAssertion(parent: FluentAssertion): VoidAssertion
{
return new VoidAssertion({
// @ts-expect-error: Access to private property.
root: parent.root,
parent: parent,
});
}

export { mockVoidAssertion };
47 changes: 47 additions & 0 deletions packages/assert/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@vitruvius-labs/assert",
"version": "0.1.0",
"description": "A fluent assertion library.",
"author": {
"name": "VitruviusLabs"
},
"contributors": [
"Nicolas \"SmashingQuasar\" Lebacq <contact@vitruvius-labs.com>",
"Benjamin Blum <benjamin.blum.98@gmail.com>"
],
"license": "MIT",
"private": false,
"type": "module",
"files": [
"./build/**/*"
],
"exports": {
".": {
"import": "./build/esm/_index.mjs",
"types": "./build/types/_index.d.mts"
}
},
"scripts": {
"clean": "rm -rf reports coverage build dist lib .eslintcache",
"compile": "tsc -p tsconfig.build.json",
"build": "pnpm clean && pnpm compile",
"eslint:check": "eslint",
"eslint:fix": "eslint --fix",
"test:unit": "tsx --test */**/*.spec.mts",
"test:unit:only": "tsx --test --test-only */**/*.spec.mts",
"test:unit:stryker": "pnpm test:unit",
"test:mutation": "stryker run",
"node:coverage": "NODE_V8_COVERAGE=./reports/node-coverage tsx --experimental-test-coverage --test */**/*.spec.mts",
"c8:coverage": "c8 tsx --test-reporter spec --test */**/*.spec.mts",
"ts:check": "tsc -p tsconfig.json --noEmit",
"spell:check": "cspell -c ../../.vscode/cspell.json .",
"ci:lint": "pnpm eslint:check",
"ci:ts:check": "pnpm ts:check",
"ci:spell:check": "pnpm spell:check",
"ci:test:unit": "pnpm test:unit",
"ci:full": "pnpm ci:lint && pnpm ci:ts:check && pnpm ci:spell:check && pnpm ci:test:unit",
"ci:publish": "pnpm publish --access public --no-git-checks",
"ci:publish:dry": "pnpm publish --access public --dry-run --no-git-checks",
"ci:build": "pnpm build"
}
}
5 changes: 5 additions & 0 deletions packages/assert/src/_index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { FluentAssertion } from "./assertion/fluent-assertion.mjs";
import type { VoidAssertion } from "./assertion/void-assertion.mjs";
import { expect } from "./assertion/expect.mjs";

export { type FluentAssertion, type VoidAssertion, expect };
5 changes: 5 additions & 0 deletions packages/assert/src/assertion/_internal.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* Guarantee the loading order */
export * from "./base-assertion.mjs";
export * from "./fluent-assertion.mjs";
export * from "./root-assertion.mjs";
export * from "./void-assertion.mjs";
Loading