Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Jest and Babel #99

Merged
merged 2 commits into from
Nov 22, 2024
Merged
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
13 changes: 0 additions & 13 deletions babel.config.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,8 @@ export default [
'sonarjs/label-has-associated-control': 'error',
'sonarjs/no-self-import': 'error',
'sonarjs/no-unused-expressions': 'off',
'sonarjs/rules-of-hooks': 'error'
'sonarjs/rules-of-hooks': 'error',
'n/no-unsupported-features/node-builtins': 'off'
}
}
]
4 changes: 0 additions & 4 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
moduleFileExtensions: ['js', 'jsx', 'json'],

transform: {
'^.+\\.js?$': 'babel-jest'
},

transformIgnorePatterns: ['node_modules/(?!(@hckrnews|@htrojs)/)'],

moduleNameMapper: {
Expand Down
2,603 changes: 342 additions & 2,261 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trojs/mutator",
"description": "Mutate the value when set some data",
"version": "1.0.0",
"version": "1.0.1",
"author": {
"name": "Pieter Wigboldus",
"url": "https://trojs.org/"
Expand All @@ -11,9 +11,8 @@
"lint": "eslint",
"lint:fix": "eslint --fix",
"lint:report": "eslint src/*.js -f json -o report.json",
"test": "jest",
"test:watch": "jest src --watch",
"coveralls": "jest && codecov && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"test": "c8 node --test src/__tests__/*.js",
"test:watch": "c8 node --test --watch src/__tests__/*.js",
"cpd": "node_modules/jscpd/bin/jscpd src",
"vulnerabilities": "npm audit --only=prod"
},
Expand All @@ -24,15 +23,10 @@
],
"main": "src/default.js",
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/eslint-parser": "^7.14.7",
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
"@babel/preset-env": "^7.9.5",
"@eslint/js": "^9.15.0",
"@jest/globals": "^29.0.0",
"@stylistic/eslint-plugin": "^2.11.0",
"@stylistic/eslint-plugin-js": "^2.11.0",
"babel-jest": "^29.0.0",
"c8": "^10.1.2",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
Expand All @@ -42,7 +36,6 @@
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-sonarjs": "^2.0.4",
"globals": "^15.12.0",
"jest": "^29.0.0",
"jscpd": "^4.0.0",
"prettier": "^3.0.0"
},
Expand Down
28 changes: 14 additions & 14 deletions src/__tests__/default.unit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, describe, it } from '@jest/globals'
import { describe, it } from 'node:test'
import assert from 'node:assert'
import DefaultMutator from '../default.js'

class ExampleMutator extends DefaultMutator {
setSkuAttribute (sku) {
return `*${sku}*`
Expand Down Expand Up @@ -34,7 +34,7 @@ describe('Test the filter mutator', () => {
test6: 0,
test7: 1
})
expect({ ...result }).toEqual({
assert.deepEqual({ ...result }, {
test: 'ok',
test5: false,
test6: 0,
Expand All @@ -44,7 +44,7 @@ describe('Test the filter mutator', () => {

it('It should set the item', () => {
const result = ExampleMutator.create({ sku: 42, test: 'ok' })
expect({ ...result }).toEqual({ sku: '*42*', test: 'ok' })
assert.deepEqual({ ...result }, { sku: '*42*', test: 'ok' })
})

it('It should set the item only if the value isnt null', () => {
Expand All @@ -53,40 +53,40 @@ describe('Test the filter mutator', () => {
test: 'ok',
test2: null
})
expect({ ...result }).toEqual({ test: 'ok' })
assert.deepEqual({ ...result }, { test: 'ok' })
})

it('It should only call a setter', () => {
const result = ExampleMutator.create({ sku: 42 })
expect({ ...result }).toEqual({ sku: '*42*' })
assert.deepEqual({ ...result }, { sku: '*42*' })
})

it('It should handle the product.group', () => {
const result = ExampleMutator.create({ product: { group: 'test' } })
expect({ ...result }).toEqual({ product: { group: '*test*' } })
assert.deepEqual({ ...result }, { product: { group: '*test*' } })
})

it('It should handle the product_group', () => {
const result = ExampleMutator.create({ product_group: 'test' })
expect({ ...result }).toEqual({ product_group: '*test*' })
assert.deepEqual({ ...result }, { product_group: '*test*' })
})

it('It should not call a setter', () => {
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' })
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' })
assert.deepEqual({ ...result }, { test: 'ok', test2: 'also ok' })
})

it('It should hydrate the object with new data', () => {
const result = ExampleMutator.create({ test: 'ok', test2: 'also ok' })
expect({ ...result }).toEqual({ test: 'ok', test2: 'also ok' })
assert.deepEqual({ ...result }, { test: 'ok', test2: 'also ok' })
result.hydrate({ sku: 43 })
expect({ ...result }).toEqual({
assert.deepEqual({ ...result }, {
sku: '*43*',
test: 'ok',
test2: 'also ok'
})
result.hydrate({ test: 'another text' })
expect({ ...result }).toEqual({
assert.deepEqual({ ...result }, {
sku: '*43*',
test: 'another text',
test2: 'also ok'
Expand All @@ -102,7 +102,7 @@ describe('Test the filter mutator', () => {
last: 99
}
})
expect({ ...result }).toEqual({
assert.deepEqual({ ...result },{
noMutation: 'ok',
sub: {
first: 1,
Expand All @@ -117,7 +117,7 @@ describe('Test the filter mutator', () => {
product: { group: 'test' },
another: { test: 'ok' }
})
expect({ ...result }).toEqual({
assert.deepEqual({ ...result },{
product: { group: '*test*' },
another: { test: 'ok' }
})
Expand Down
23 changes: 13 additions & 10 deletions src/__tests__/string-helper.unit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, describe, it } from '@jest/globals'
import { describe, it } from 'node:test'
import assert from 'node:assert'
import { capitalizeWords } from '../string-helper.js'

const testCases = [
Expand All @@ -23,13 +24,15 @@ const testCases = [
expectedResult: 'TEstTeStTesT'
}
]
describe('Test the item filter method', () => {

describe.each(testCases)(
'Test the item filter method',
({ description, input, expectedResult }) => {
it(description, () => {
const result = capitalizeWords(input)
expect(result).toEqual(expectedResult)
})
}
)
testCases.forEach(
({ description, input, expectedResult }) => {
it(description, () => {
const result = capitalizeWords(input)
assert.deepEqual(result, expectedResult)
})
}
)

})